diff options
author | Nikita Popov <npopov@redhat.com> | 2024-09-23 09:13:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-23 09:13:09 +0200 |
commit | 5a4c6f97997f3cdfa9d98f7f0b546e331ee9cc4a (patch) | |
tree | 47713585a2a3f6a6b67e97d043539341d2a1d539 /llvm/lib/CodeGen/MachineOperand.cpp | |
parent | 80b44517f571689ede9327b3122caff3c631408e (diff) | |
download | llvm-5a4c6f97997f3cdfa9d98f7f0b546e331ee9cc4a.zip llvm-5a4c6f97997f3cdfa9d98f7f0b546e331ee9cc4a.tar.gz llvm-5a4c6f97997f3cdfa9d98f7f0b546e331ee9cc4a.tar.bz2 |
[Loads] Check context instruction for context-sensitive derefability (#109277)
If a dereferenceability fact is provided through `!dereferenceable` (or
similar), it may only hold on the given control flow path. When we use
`isSafeToSpeculativelyExecute()` to check multiple instructions, we
might make use of `!dereferenceable` information that does not hold at
the speculation target. This doesn't happen when speculating
instructions one by one, because `!dereferenceable` will be dropped
while speculating.
Fix this by checking whether the instruction with `!dereferenceable`
dominates the context instruction. If this is not the case, it means we
are speculating, and cannot guarantee that it holds at the speculation
target.
Fixes https://github.com/llvm/llvm-project/issues/108854.
Diffstat (limited to 'llvm/lib/CodeGen/MachineOperand.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineOperand.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/MachineOperand.cpp b/llvm/lib/CodeGen/MachineOperand.cpp index 6ee4762..89d32c3 100644 --- a/llvm/lib/CodeGen/MachineOperand.cpp +++ b/llvm/lib/CodeGen/MachineOperand.cpp @@ -1047,7 +1047,8 @@ bool MachinePointerInfo::isDereferenceable(unsigned Size, LLVMContext &C, return false; return isDereferenceableAndAlignedPointer( - BasePtr, Align(1), APInt(DL.getPointerSizeInBits(), Offset + Size), DL); + BasePtr, Align(1), APInt(DL.getPointerSizeInBits(), Offset + Size), DL, + dyn_cast<Instruction>(BasePtr)); } /// getConstantPool - Return a MachinePointerInfo record that refers to the |