Skip to content

Commit 21fc119

Browse files
committed
[DSE] Only consider provenance captures
As a memory analysis, DSE only captures about provenance captures. Address captures can be ignored as they cannot be used to read or modify memory.
1 parent 0525581 commit 21fc119

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,7 +1213,8 @@ struct DSEState {
12131213

12141214
auto I = InvisibleToCallerAfterRet.insert({V, false});
12151215
if (I.second && isInvisibleToCallerOnUnwind(V) && isNoAliasCall(V))
1216-
I.first->second = !PointerMayBeCaptured(V, /*ReturnCaptures=*/true);
1216+
I.first->second = capturesNothing(PointerMayBeCaptured(
1217+
V, /*ReturnCaptures=*/true, CaptureComponents::Provenance));
12171218
return I.first->second;
12181219
}
12191220

@@ -1230,7 +1231,8 @@ struct DSEState {
12301231
// with the killing MemoryDef. But we refrain from doing so for now to
12311232
// limit compile-time and this does not cause any changes to the number
12321233
// of stores removed on a large test set in practice.
1233-
I.first->second = PointerMayBeCaptured(V, /*ReturnCaptures=*/false);
1234+
I.first->second = capturesAnything(PointerMayBeCaptured(
1235+
V, /*ReturnCaptures=*/false, CaptureComponents::Provenance));
12341236
return !I.first->second;
12351237
}
12361238

llvm/test/Transforms/DeadStoreElimination/assume.ll

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ define void @f() {
88
; CHECK-NEXT: [[TMP1:%.*]] = call noalias ptr @_Znwm(i64 32)
99
; CHECK-NEXT: [[TMP2:%.*]] = icmp ugt ptr [[TMP1]], @global
1010
; CHECK-NEXT: call void @llvm.assume(i1 [[TMP2]])
11-
; CHECK-NEXT: store i8 0, ptr [[TMP1]], align 1
1211
; CHECK-NEXT: ret void
1312
;
1413
%tmp1 = call noalias ptr @_Znwm(i64 32)
@@ -23,7 +22,6 @@ define void @f2() {
2322
; CHECK-NEXT: [[TMP1:%.*]] = call noalias ptr @_Znwm(i64 32)
2423
; CHECK-NEXT: [[TMP2:%.*]] = icmp ugt ptr [[TMP1]], @global
2524
; CHECK-NEXT: call void @llvm.assume(i1 [[TMP2]])
26-
; CHECK-NEXT: store i8 0, ptr [[TMP1]], align 1
2725
; CHECK-NEXT: call void @quux(ptr @global)
2826
; CHECK-NEXT: ret void
2927
;

llvm/test/Transforms/DeadStoreElimination/simple.ll

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,6 @@ define void @malloc_address_only_escape() {
322322
; CHECK-LABEL: @malloc_address_only_escape(
323323
; CHECK-NEXT: [[M:%.*]] = call ptr @malloc(i64 24)
324324
; CHECK-NEXT: call void @use.ptr(ptr captures(address) [[M]])
325-
; CHECK-NEXT: store i8 0, ptr [[M]], align 1
326325
; CHECK-NEXT: ret void
327326
;
328327
%m = call ptr @malloc(i64 24)

0 commit comments

Comments
 (0)