[SimplifyCFG] Only consider provenance capture in store speculation (#138548)
The capture check here is to protect against concurrent accesses from other threads. This requires the provenance to escape.
This commit is contained in:
parent
fb21efa258
commit
eee958285b
@ -3067,7 +3067,9 @@ static Value *isSafeToSpeculateStore(Instruction *I, BasicBlock *BrBB,
|
|||||||
Value *Obj = getUnderlyingObject(StorePtr);
|
Value *Obj = getUnderlyingObject(StorePtr);
|
||||||
bool ExplicitlyDereferenceableOnly;
|
bool ExplicitlyDereferenceableOnly;
|
||||||
if (isWritableObject(Obj, ExplicitlyDereferenceableOnly) &&
|
if (isWritableObject(Obj, ExplicitlyDereferenceableOnly) &&
|
||||||
!PointerMayBeCaptured(Obj, /*ReturnCaptures=*/false) &&
|
capturesNothing(
|
||||||
|
PointerMayBeCaptured(Obj, /*ReturnCaptures=*/false,
|
||||||
|
CaptureComponents::Provenance)) &&
|
||||||
(!ExplicitlyDereferenceableOnly ||
|
(!ExplicitlyDereferenceableOnly ||
|
||||||
isDereferenceablePointer(StorePtr, StoreTy,
|
isDereferenceablePointer(StorePtr, StoreTy,
|
||||||
LI->getDataLayout()))) {
|
LI->getDataLayout()))) {
|
||||||
|
@ -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: [[ARRAYIDX:%.*]] = getelementptr inbounds [2 x i32], ptr [[A]], i64 0, i64 [[I:%.*]]
|
||||||
; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[ARRAYIDX]], align 4
|
; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[ARRAYIDX]], align 4
|
||||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[TMP0]], [[B:%.*]]
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[TMP0]], [[B:%.*]]
|
||||||
; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
|
; CHECK-NEXT: [[SPEC_STORE_SELECT:%.*]] = select i1 [[CMP]], i32 [[B]], i32 [[TMP0]]
|
||||||
; CHECK: if.then:
|
; CHECK-NEXT: store i32 [[SPEC_STORE_SELECT]], ptr [[ARRAYIDX]], align 4
|
||||||
; CHECK-NEXT: store i32 [[B]], ptr [[ARRAYIDX]], align 4
|
|
||||||
; CHECK-NEXT: br label [[IF_END]]
|
|
||||||
; CHECK: if.end:
|
|
||||||
; CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[A]], 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: [[ARRAYIDX2:%.*]] = getelementptr inbounds [2 x i32], ptr [[A]], i64 0, i64 1
|
||||||
; CHECK-NEXT: [[TMP2:%.*]] = load i32, ptr [[ARRAYIDX2]], align 4
|
; CHECK-NEXT: [[TMP2:%.*]] = load i32, ptr [[ARRAYIDX2]], align 4
|
||||||
|
Loading…
x
Reference in New Issue
Block a user