Skip to content

Commit 1ff8ebc

Browse files
committed
Add an unit test about alloca then escape
1 parent defcdb1 commit 1ff8ebc

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

llvm/test/Transforms/DeadStoreElimination/inter-procedural.ll

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,26 @@ define i16 @p1_write_then_read_caller() {
3939
ret i16 %l
4040
}
4141

42+
declare void @fn_capture(ptr noundef)
43+
; Function Attrs: mustprogress nounwind uwtable
44+
define i16 @p1_write_then_read_caller_escape() {
45+
; CHECK-LABEL: @p1_write_then_read_caller_escape(
46+
; CHECK-NEXT: [[PTR:%.*]] = alloca i16, align 2
47+
; CHECK-NEXT: store i16 0, ptr [[PTR]], align 2
48+
; CHECK-NEXT: call void @fn_capture(ptr [[PTR]])
49+
; CHECK-NEXT: call void @p1_write_then_read(ptr [[PTR]])
50+
; CHECK-NEXT: [[L:%.*]] = load i16, ptr [[PTR]], align 2
51+
; CHECK-NEXT: ret i16 [[L]]
52+
;
53+
%ptr = alloca i16
54+
store i16 0, ptr %ptr
55+
call void @fn_capture(ptr %ptr)
56+
call void @p1_write_then_read(ptr %ptr)
57+
%l = load i16, ptr %ptr
58+
ret i16 %l
59+
}
60+
61+
4262
; Function Attrs: mustprogress nounwind uwtable
4363
define i16 @p1_write_then_read_caller_with_clobber() {
4464
; CHECK-LABEL: @p1_write_then_read_caller_with_clobber(
@@ -304,6 +324,7 @@ define i16 @large_p2_may_or_partial_alias_caller2(ptr %base1, ptr %base2) {
304324
@g = global i16 123, align 2
305325

306326
declare void @read_global(ptr nocapture noundef initializes((0, 2))) nounwind
327+
memory(read, argmem: write, inaccessiblemem: none) nounwind
307328

308329
define i16 @global_var_alias() {
309330
; CHECK-LABEL: @global_var_alias(

0 commit comments

Comments
 (0)