Skip to content

Commit 3d56644

Browse files
committed
[DSE] Add test for potential caching bug (NFC)
This one would miscompile if read-clobber checks switched to using the EarlierAccess location, but the read cache was retained.
1 parent 3203143 commit 3d56644

File tree

1 file changed

+33
-0
lines changed
  • llvm/test/Transforms/DeadStoreElimination/MSSA

1 file changed

+33
-0
lines changed

llvm/test/Transforms/DeadStoreElimination/MSSA/overlap.ll

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,36 @@ else:
9696
load i8, i8* %a1
9797
ret void
9898
}
99+
100+
; Variation on the previous test case, where only the store to %a0 is dead,
101+
; but not the one to %a1. This tests for a potential caching bug.
102+
define void @test4(i1 %c) {
103+
; CHECK-LABEL: @test4(
104+
; CHECK-NEXT: [[A:%.*]] = alloca [2 x i8], align 1
105+
; CHECK-NEXT: [[A0:%.*]] = getelementptr [2 x i8], [2 x i8]* [[A]], i32 0, i32 0
106+
; CHECK-NEXT: [[A1:%.*]] = getelementptr [2 x i8], [2 x i8]* [[A]], i32 0, i32 1
107+
; CHECK-NEXT: store i8 1, i8* [[A1]], align 1
108+
; CHECK-NEXT: store i8 1, i8* [[A0]], align 1
109+
; CHECK-NEXT: br i1 [[C:%.*]], label [[IF:%.*]], label [[ELSE:%.*]]
110+
; CHECK: if:
111+
; CHECK-NEXT: store [2 x i8] zeroinitializer, [2 x i8]* [[A]], align 1
112+
; CHECK-NEXT: br label [[ELSE]]
113+
; CHECK: else:
114+
; CHECK-NEXT: [[TMP1:%.*]] = load i8, i8* [[A1]], align 1
115+
; CHECK-NEXT: ret void
116+
;
117+
%a = alloca [2 x i8]
118+
%a0 = getelementptr [2 x i8], [2 x i8]* %a, i32 0, i32 0
119+
%a1 = getelementptr [2 x i8], [2 x i8]* %a, i32 0, i32 1
120+
store i8 1, i8* %a1
121+
store i8 1, i8* %a0
122+
br i1 %c, label %if, label %else
123+
124+
if:
125+
store [2 x i8] zeroinitializer, [2 x i8]* %a
126+
br label %else
127+
128+
else:
129+
load i8, i8* %a1
130+
ret void
131+
}

0 commit comments

Comments
 (0)