diff options
author | Nikita Popov <npopov@redhat.com> | 2025-02-27 17:00:22 +0100 |
---|---|---|
committer | Nikita Popov <npopov@redhat.com> | 2025-02-27 17:03:24 +0100 |
commit | b2aba39001f6909965c4a9af47969e83717601c0 (patch) | |
tree | 41307867992f9048de961db9232cdefa817f46c2 /llvm/lib/CodeGen/StackProtector.cpp | |
parent | 7defbf987a551771c275129c70fe4e59dc5125cc (diff) | |
download | llvm-b2aba39001f6909965c4a9af47969e83717601c0.zip llvm-b2aba39001f6909965c4a9af47969e83717601c0.tar.gz llvm-b2aba39001f6909965c4a9af47969e83717601c0.tar.bz2 |
[StackProtector] Handle atomicrmw xchg in HasAddressTaken heuristic
Atomicrmw xchg can directly take a pointer operand, so we should
treat it similarly to store or cmpxchg.
In practice, I believe that all targets that support stack protectors
will convert this to an integer atomicrmw xchg in AtomicExpand, so
there is no issue in practice. We still should handle it correctly
if that doesn't happen.
Diffstat (limited to 'llvm/lib/CodeGen/StackProtector.cpp')
-rw-r--r-- | llvm/lib/CodeGen/StackProtector.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/StackProtector.cpp b/llvm/lib/CodeGen/StackProtector.cpp index 0ce305c..232e84fb 100644 --- a/llvm/lib/CodeGen/StackProtector.cpp +++ b/llvm/lib/CodeGen/StackProtector.cpp @@ -275,6 +275,10 @@ static bool HasAddressTaken(const Instruction *AI, TypeSize AllocSize, if (AI == cast<AtomicCmpXchgInst>(I)->getNewValOperand()) return true; break; + case Instruction::AtomicRMW: + if (AI == cast<AtomicRMWInst>(I)->getValOperand()) + return true; + break; case Instruction::PtrToInt: if (AI == cast<PtrToIntInst>(I)->getOperand(0)) return true; @@ -327,13 +331,9 @@ static bool HasAddressTaken(const Instruction *AI, TypeSize AllocSize, break; } case Instruction::Load: - case Instruction::AtomicRMW: case Instruction::Ret: // These instructions take an address operand, but have load-like or // other innocuous behavior that should not trigger a stack protector. - // atomicrmw conceptually has both load and store semantics, but the - // value being stored must be integer; so if a pointer is being stored, - // we'll catch it in the PtrToInt case above. break; default: // Conservatively return true for any instruction that takes an address |