llvm.org GIT mirror llvm / da3da38
[ValueTracking] Remove volatile check in isGuaranteedToTransferExecutionToSuccessor Summary: As clarified in D53184, volatile load and store do not trap. Therefore, we should remove volatile checks for instructions in `isGuaranteedToTransferExecutionToSuccessor`. Reviewers: jdoerfert, efriedma, nikic Reviewed By: nikic Subscribers: hiraditya, jfb, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D65375 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@367226 91177308-0d34-0410-b5e6-96231b3b80d8 Hideto Ueno 1 year, 17 days ago
2 changed file(s) with 6 addition(s) and 17 deletion(s). Raw diff Collapse all Expand all
42204220 }
42214221
42224222 bool llvm::isGuaranteedToTransferExecutionToSuccessor(const Instruction *I) {
4223 // A memory operation returns normally if it isn't volatile. A volatile
4224 // operation is allowed to trap.
4225 //
4226 // An atomic operation isn't guaranteed to return in a reasonable amount of
4227 // time because it's possible for another thread to interfere with it for an
4223 // Note: An atomic operation isn't guaranteed to return in a reasonable amount
4224 // of time because it's possible for another thread to interfere with it for an
42284225 // arbitrary length of time, but programs aren't allowed to rely on that.
4229 if (const LoadInst *LI = dyn_cast(I))
4230 return !LI->isVolatile();
4231 if (const StoreInst *SI = dyn_cast(I))
4232 return !SI->isVolatile();
4233 if (const AtomicCmpXchgInst *CXI = dyn_cast(I))
4234 return !CXI->isVolatile();
4235 if (const AtomicRMWInst *RMWI = dyn_cast(I))
4236 return !RMWI->isVolatile();
4237 if (const MemIntrinsic *MII = dyn_cast(I))
4238 return !MII->isVolatile();
42394226
42404227 // If there is no successor, then execution can't transfer to it.
42414228 if (const auto *CRI = dyn_cast(I))
346346 }
347347
348348 ; The callsite must execute in order for the attribute to transfer to the parent.
349 ; The volatile load might trap, so there's no guarantee that we'll ever get to the call.
349 ; The volatile load can't trap, so we can guarantee that we'll get to the call.
350350
351351 define i8 @parent6(i8* %a, i8* %b) {
352 ; BOTH-LABEL: @parent6(i8* %a, i8* %b)
352 ; FNATTR-LABEL: @parent6(i8* nonnull %a, i8* %b)
353 ; FIXME: missing "nonnull"
354 ; ATTRIBUTOR-LABEL: @parent6(i8* %a, i8* %b)
353355 ; BOTH-NEXT: [[C:%.*]] = load volatile i8, i8* %b
354356 ; FNATTR-NEXT: call void @use1nonnull(i8* %a)
355357 ; ATTRIBUTOR-NEXT: call void @use1nonnull(i8* nonnull %a)