Skip to content

Commit 3f7dc5c

Browse files
committed
[GVNHoist] Convert test to opaque pointers (NFC)
Adjust the GEPs to be non-trivial, to preserve test intent.
1 parent 436576a commit 3f7dc5c

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

llvm/test/Transforms/GVNHoist/hoist-pr28606.ll

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
55
target triple = "i686-pc-windows-msvc18.0.0"
66

7-
%struct.S = type { i8* }
7+
%struct.S = type { ptr, ptr }
88

9-
declare void @f(<{ %struct.S }>* inalloca(<{ %struct.S }>))
9+
declare void @f(ptr inalloca(<{ %struct.S }>))
1010

1111

1212
; Check that we don't clone the %x alloca and insert it in the live range of
@@ -15,45 +15,43 @@ define void @test(i1 %b) {
1515
; CHECK-LABEL: @test(
1616
; CHECK-NEXT: entry:
1717
; CHECK-NEXT: [[X:%.*]] = alloca i8, align 1
18-
; CHECK-NEXT: [[INALLOCA_SAVE:%.*]] = call i8* @llvm.stacksave()
18+
; CHECK-NEXT: [[INALLOCA_SAVE:%.*]] = call ptr @llvm.stacksave()
1919
; CHECK-NEXT: [[ARGMEM:%.*]] = alloca inalloca <{ [[STRUCT_S:%.*]] }>, align 4
20-
; CHECK-NEXT: [[TMP0:%.*]] = getelementptr inbounds <{ [[STRUCT_S]] }>, <{ [[STRUCT_S]] }>* [[ARGMEM]], i32 0, i32 0
21-
; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds [[STRUCT_S]], %struct.S* [[TMP0]], i32 0, i32 0
22-
; CHECK-NEXT: store i8* [[X]], i8** [[TMP1]], align 4
20+
; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[ARGMEM]], i32 0, i32 1
21+
; CHECK-NEXT: store ptr [[X]], ptr [[TMP1]], align 4
2322
; CHECK-NEXT: br i1 [[B:%.*]], label [[TRUE:%.*]], label [[FALSE:%.*]]
2423
; CHECK: true:
25-
; CHECK-NEXT: [[P:%.*]] = getelementptr inbounds [[STRUCT_S]], %struct.S* [[TMP0]], i32 0, i32 0
24+
; CHECK-NEXT: [[P:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[ARGMEM]], i32 0, i32 1
2625
; CHECK-NEXT: br label [[EXIT:%.*]]
2726
; CHECK: false:
28-
; CHECK-NEXT: [[P2:%.*]] = getelementptr inbounds [[STRUCT_S]], %struct.S* [[TMP0]], i32 0, i32 0
27+
; CHECK-NEXT: [[P2:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[ARGMEM]], i32 0, i32 1
2928
; CHECK-NEXT: br label [[EXIT]]
3029
; CHECK: exit:
31-
; CHECK-NEXT: call void @f(<{ [[STRUCT_S]] }>* inalloca(<{ [[STRUCT_S]] }>) [[ARGMEM]])
32-
; CHECK-NEXT: call void @llvm.stackrestore(i8* [[INALLOCA_SAVE]])
30+
; CHECK-NEXT: call void @f(ptr inalloca(<{ [[STRUCT_S]] }>) [[ARGMEM]])
31+
; CHECK-NEXT: call void @llvm.stackrestore(ptr [[INALLOCA_SAVE]])
3332
; CHECK-NEXT: ret void
3433
;
3534
entry:
3635
%x = alloca i8
37-
%inalloca.save = call i8* @llvm.stacksave()
36+
%inalloca.save = call ptr @llvm.stacksave()
3837
%argmem = alloca inalloca <{ %struct.S }>, align 4
39-
%0 = getelementptr inbounds <{ %struct.S }>, <{ %struct.S }>* %argmem, i32 0, i32 0
4038
br i1 %b, label %true, label %false
4139

4240
true:
43-
%p = getelementptr inbounds %struct.S, %struct.S* %0, i32 0, i32 0
44-
store i8* %x, i8** %p, align 4
41+
%p = getelementptr inbounds %struct.S, ptr %argmem, i32 0, i32 1
42+
store ptr %x, ptr %p, align 4
4543
br label %exit
4644

4745
false:
48-
%p2 = getelementptr inbounds %struct.S, %struct.S* %0, i32 0, i32 0
49-
store i8* %x, i8** %p2, align 4
46+
%p2 = getelementptr inbounds %struct.S, ptr %argmem, i32 0, i32 1
47+
store ptr %x, ptr %p2, align 4
5048
br label %exit
5149

5250
exit:
53-
call void @f(<{ %struct.S }>* inalloca(<{ %struct.S }>) %argmem)
54-
call void @llvm.stackrestore(i8* %inalloca.save)
51+
call void @f(ptr inalloca(<{ %struct.S }>) %argmem)
52+
call void @llvm.stackrestore(ptr %inalloca.save)
5553
ret void
5654
}
5755

58-
declare i8* @llvm.stacksave()
59-
declare void @llvm.stackrestore(i8*)
56+
declare ptr @llvm.stacksave()
57+
declare void @llvm.stackrestore(ptr)

0 commit comments

Comments
 (0)