Skip to content

Commit 51f2f59

Browse files
committed
[InstCombine] Convert test to opaque pointers (NFC)
Slightly adjust the test so it uses non-zero GEP indices, otherwise these would get folded away with opaque pointers.
1 parent c93e7de commit 51f2f59

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

llvm/test/Transforms/InstCombine/catchswitch-phi.ll

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,57 +5,57 @@ target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128-ni:1"
55
target triple = "wasm32-unknown-unknown"
66

77
%struct.quux = type { i32 }
8-
%struct.blam = type <{ %struct.quux }>
8+
%struct.blam = type <{ i32, %struct.quux }>
99

1010
declare void @foo()
11-
declare void @bar(%struct.quux*)
11+
declare void @bar(ptr)
1212
declare i32 @baz()
1313
declare i32 @__gxx_wasm_personality_v0(...)
1414
; Function Attrs: noreturn
1515
declare void @llvm.wasm.rethrow() #0
1616

1717
; Test that a PHI in catchswitch BB are excluded from combining into a non-PHI
1818
; instruction.
19-
define void @test0(i1 %c1) personality i8* bitcast (i32 (...)* @__gxx_wasm_personality_v0 to i8*) {
19+
define void @test0(i1 %c1) personality ptr @__gxx_wasm_personality_v0 {
2020
; CHECK-LABEL: @test0(
2121
; CHECK-NEXT: bb:
2222
; CHECK-NEXT: [[TMP0:%.*]] = alloca [[STRUCT_BLAM:%.*]], align 4
2323
; CHECK-NEXT: br i1 [[C1:%.*]], label [[BB1:%.*]], label [[BB2:%.*]]
2424
; CHECK: bb1:
25-
; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds [[STRUCT_BLAM]], %struct.blam* [[TMP0]], i32 0, i32 0
25+
; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds [[STRUCT_BLAM]], ptr [[TMP0]], i32 0, i32 1
2626
; CHECK-NEXT: invoke void @foo()
2727
; CHECK-NEXT: to label [[BB3:%.*]] unwind label [[BB4:%.*]]
2828
; CHECK: bb2:
29-
; CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds [[STRUCT_BLAM]], %struct.blam* [[TMP0]], i32 0, i32 0
29+
; CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds [[STRUCT_BLAM]], ptr [[TMP0]], i32 0, i32 1
3030
; CHECK-NEXT: invoke void @foo()
3131
; CHECK-NEXT: to label [[BB3]] unwind label [[BB4]]
3232
; CHECK: bb3:
3333
; CHECK-NEXT: unreachable
3434
; CHECK: bb4:
35-
; CHECK-NEXT: [[TMP3:%.*]] = phi %struct.quux* [ [[TMP1]], [[BB1]] ], [ [[TMP2]], [[BB2]] ]
35+
; CHECK-NEXT: [[TMP3:%.*]] = phi ptr [ [[TMP1]], [[BB1]] ], [ [[TMP2]], [[BB2]] ]
3636
; CHECK-NEXT: [[TMP4:%.*]] = catchswitch within none [label %bb5] unwind label [[BB7:%.*]]
3737
; CHECK: bb5:
38-
; CHECK-NEXT: [[TMP5:%.*]] = catchpad within [[TMP4]] [i8* null]
38+
; CHECK-NEXT: [[TMP5:%.*]] = catchpad within [[TMP4]] [ptr null]
3939
; CHECK-NEXT: invoke void @foo() [ "funclet"(token [[TMP5]]) ]
4040
; CHECK-NEXT: to label [[BB6:%.*]] unwind label [[BB7]]
4141
; CHECK: bb6:
4242
; CHECK-NEXT: unreachable
4343
; CHECK: bb7:
4444
; CHECK-NEXT: [[TMP6:%.*]] = cleanuppad within none []
45-
; CHECK-NEXT: call void @bar(%struct.quux* [[TMP3]]) [ "funclet"(token [[TMP6]]) ]
45+
; CHECK-NEXT: call void @bar(ptr nonnull [[TMP3]]) [ "funclet"(token [[TMP6]]) ]
4646
; CHECK-NEXT: unreachable
4747
;
4848
bb:
4949
%tmp0 = alloca %struct.blam, align 4
5050
br i1 %c1, label %bb1, label %bb2
5151

5252
bb1: ; preds = %bb
53-
%tmp1 = getelementptr inbounds %struct.blam, %struct.blam* %tmp0, i32 0, i32 0
53+
%tmp1 = getelementptr inbounds %struct.blam, ptr %tmp0, i32 0, i32 1
5454
invoke void @foo()
5555
to label %bb3 unwind label %bb4
5656

5757
bb2: ; preds = %bb
58-
%tmp2 = getelementptr inbounds %struct.blam, %struct.blam* %tmp0, i32 0, i32 0
58+
%tmp2 = getelementptr inbounds %struct.blam, ptr %tmp0, i32 0, i32 1
5959
invoke void @foo()
6060
to label %bb3 unwind label %bb4
6161

@@ -66,11 +66,11 @@ bb4: ; preds = %bb2, %bb1
6666
; This PHI should not be combined into a non-PHI instruction, because
6767
; catchswitch BB cannot have any non-PHI instruction other than catchswitch
6868
; itself.
69-
%tmp3 = phi %struct.quux* [ %tmp1, %bb1 ], [ %tmp2, %bb2 ]
69+
%tmp3 = phi ptr [ %tmp1, %bb1 ], [ %tmp2, %bb2 ]
7070
%tmp4 = catchswitch within none [label %bb5] unwind label %bb7
7171

7272
bb5: ; preds = %bb4
73-
%tmp5 = catchpad within %tmp4 [i8* null]
73+
%tmp5 = catchpad within %tmp4 [ptr null]
7474
invoke void @foo() [ "funclet"(token %tmp5) ]
7575
to label %bb6 unwind label %bb7
7676

@@ -79,13 +79,13 @@ bb6: ; preds = %bb5
7979

8080
bb7: ; preds = %bb5, %bb4
8181
%tmp6 = cleanuppad within none []
82-
call void @bar(%struct.quux* %tmp3) [ "funclet"(token %tmp6) ]
82+
call void @bar(ptr %tmp3) [ "funclet"(token %tmp6) ]
8383
unreachable
8484
}
8585

8686
; Test that slicing-up of illegal integer type PHI does not happen in catchswitch
8787
; BBs, which can't have any non-PHI instruction before the catchswitch.
88-
define void @test1() personality i8* bitcast (i32 (...)* @__gxx_wasm_personality_v0 to i8*) {
88+
define void @test1() personality ptr @__gxx_wasm_personality_v0 {
8989
; CHECK-LABEL: @test1(
9090
; CHECK-NEXT: entry:
9191
; CHECK-NEXT: invoke void @foo()
@@ -108,7 +108,7 @@ define void @test1() personality i8* bitcast (i32 (...)* @__gxx_wasm_personality
108108
; CHECK-NEXT: [[AP_1:%.*]] = phi i8 [ [[AP_0]], [[IF_END]] ], [ 0, [[INVOKE_CONT]] ]
109109
; CHECK-NEXT: [[TMP0:%.*]] = catchswitch within none [label %catch.start] unwind label [[CATCH_DISPATCH1]]
110110
; CHECK: catch.start:
111-
; CHECK-NEXT: [[TMP1:%.*]] = catchpad within [[TMP0]] [i8* null]
111+
; CHECK-NEXT: [[TMP1:%.*]] = catchpad within [[TMP0]] [ptr null]
112112
; CHECK-NEXT: br i1 false, label [[CATCH:%.*]], label [[RETHROW:%.*]]
113113
; CHECK: catch:
114114
; CHECK-NEXT: catchret from [[TMP1]] to label [[TRY_CONT]]
@@ -119,7 +119,7 @@ define void @test1() personality i8* bitcast (i32 (...)* @__gxx_wasm_personality
119119
; CHECK-NEXT: [[AP_2:%.*]] = phi i8 [ [[AP_1]], [[CATCH_DISPATCH]] ], [ [[AP_1]], [[RETHROW]] ], [ 0, [[ENTRY:%.*]] ]
120120
; CHECK-NEXT: [[TMP2:%.*]] = catchswitch within none [label %catch.start1] unwind to caller
121121
; CHECK: catch.start1:
122-
; CHECK-NEXT: [[TMP3:%.*]] = catchpad within [[TMP2]] [i8* null]
122+
; CHECK-NEXT: [[TMP3:%.*]] = catchpad within [[TMP2]] [ptr null]
123123
; CHECK-NEXT: [[TMP0:%.*]] = and i8 [[AP_2]], 1
124124
; CHECK-NEXT: [[TOBOOL1_NOT:%.*]] = icmp eq i8 [[TMP0]], 0
125125
; CHECK-NEXT: br i1 [[TOBOOL1_NOT]], label [[IF_END1:%.*]], label [[IF_THEN1:%.*]]
@@ -168,7 +168,7 @@ catch.dispatch: ; preds = %if.end, %invoke.con
168168
%tmp0 = catchswitch within none [label %catch.start] unwind label %catch.dispatch1
169169

170170
catch.start: ; preds = %catch.dispatch
171-
%tmp1 = catchpad within %tmp0 [i8* null]
171+
%tmp1 = catchpad within %tmp0 [ptr null]
172172
br i1 0, label %catch, label %rethrow
173173

174174
catch: ; preds = %catch.start
@@ -183,7 +183,7 @@ catch.dispatch1: ; preds = %rethrow, %catch.dis
183183
%tmp2 = catchswitch within none [label %catch.start1] unwind to caller
184184

185185
catch.start1: ; preds = %catch.dispatch1
186-
%tmp3 = catchpad within %tmp2 [i8* null]
186+
%tmp3 = catchpad within %tmp2 [ptr null]
187187
%tobool1 = trunc i8 %ap.2 to i1
188188
br i1 %tobool1, label %if.then1, label %if.end1
189189

0 commit comments

Comments
 (0)