diff options
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 4 | ||||
-rw-r--r-- | llvm/test/Transforms/SimplifyCFG/speculate-store.ll | 7 |
2 files changed, 5 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index d94abea..7840601 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -3067,7 +3067,9 @@ static Value *isSafeToSpeculateStore(Instruction *I, BasicBlock *BrBB, Value *Obj = getUnderlyingObject(StorePtr); bool ExplicitlyDereferenceableOnly; if (isWritableObject(Obj, ExplicitlyDereferenceableOnly) && - !PointerMayBeCaptured(Obj, /*ReturnCaptures=*/false) && + capturesNothing( + PointerMayBeCaptured(Obj, /*ReturnCaptures=*/false, + CaptureComponents::Provenance)) && (!ExplicitlyDereferenceableOnly || isDereferenceablePointer(StorePtr, StoreTy, LI->getDataLayout()))) { diff --git a/llvm/test/Transforms/SimplifyCFG/speculate-store.ll b/llvm/test/Transforms/SimplifyCFG/speculate-store.ll index 22ffe21..161ec38 100644 --- a/llvm/test/Transforms/SimplifyCFG/speculate-store.ll +++ b/llvm/test/Transforms/SimplifyCFG/speculate-store.ll @@ -203,11 +203,8 @@ define i32 @load_before_store_escape_addr_only(i64 %i, i32 %b) { ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [2 x i32], ptr [[A]], i64 0, i64 [[I:%.*]] ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[ARRAYIDX]], align 4 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[TMP0]], [[B:%.*]] -; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_END:%.*]] -; CHECK: if.then: -; CHECK-NEXT: store i32 [[B]], ptr [[ARRAYIDX]], align 4 -; CHECK-NEXT: br label [[IF_END]] -; CHECK: if.end: +; CHECK-NEXT: [[SPEC_STORE_SELECT:%.*]] = select i1 [[CMP]], i32 [[B]], i32 [[TMP0]] +; CHECK-NEXT: store i32 [[SPEC_STORE_SELECT]], ptr [[ARRAYIDX]], align 4 ; CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[A]], align 4 ; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds [2 x i32], ptr [[A]], i64 0, i64 1 ; CHECK-NEXT: [[TMP2:%.*]] = load i32, ptr [[ARRAYIDX2]], align 4 |