Skip to content

Commit

Permalink
[AArch64] Mark the read of the threadpointer has having unmodeled sid…
Browse files Browse the repository at this point in the history
…e effects to prevent misoptimization in programs where the executing thread may change across a function call.

In principle, this change could be made more precise to enable some
optimizations of this operation, including removal of redundant reads
when there is no intervening function call.  But it is not clear what
attributes currently exist that could be attached to this operation to
model its behavior more precisely.
  • Loading branch information
neboat committed Oct 9, 2023
1 parent 4c3ac45 commit 32d3a6a
Show file tree
Hide file tree
Showing 2 changed files with 517 additions and 0 deletions.
2 changes: 2 additions & 0 deletions llvm/lib/Target/AArch64/AArch64InstrInfo.td
Original file line number Diff line number Diff line change
Expand Up @@ -1513,8 +1513,10 @@ def : Pat<(AArch64mrs imm:$id),

// The thread pointer (on Linux, at least, where this has been implemented) is
// TPIDR_EL0.
let hasSideEffects = 1 in {
def MOVbaseTLS : Pseudo<(outs GPR64:$dst), (ins),
[(set GPR64:$dst, AArch64threadpointer)]>, Sched<[WriteSys]>;
}

// This gets lowered into a 24-byte instruction sequence
let Defs = [ X9, X16, X17, NZCV ], Size = 24 in {
Expand Down
Loading

0 comments on commit 32d3a6a

Please sign in to comment.