1 ; RUN: opt < %s -rewrite-statepoints-for-gc -S | FileCheck %s
2 ; RUN: opt < %s -passes=rewrite-statepoints-for-gc -S | FileCheck %s
4 ; Assertions are almost autogenerated except for last testcase widget, which was
5 ; updated (with -DAG instead of -NEXT) to fix buildbot failure reproducible only on two boxes.
7 ; Uses of extractelement that are of scalar type should not have the BDV
8 ; incorrectly identified as a vector type.
9 define void @widget() gc "statepoint-example" {
10 ; CHECK-LABEL: @widget(
12 ; CHECK-NEXT: [[BASE_EE:%.*]] = extractelement <2 x i8 addrspace(1)*> zeroinitializer, i32 1, !is_base_value !0
13 ; CHECK-NEXT: [[TMP:%.*]] = extractelement <2 x i8 addrspace(1)*> undef, i32 1
14 ; CHECK-NEXT: br i1 undef, label [[BB7:%.*]], label [[BB9:%.*]]
16 ; CHECK-NEXT: [[TMP8:%.*]] = getelementptr inbounds i8, i8 addrspace(1)* [[TMP]], i64 12
17 ; CHECK-NEXT: br label [[BB11:%.*]]
19 ; CHECK-NEXT: [[TMP10:%.*]] = getelementptr inbounds i8, i8 addrspace(1)* [[TMP]], i64 12
20 ; CHECK-NEXT: br i1 undef, label [[BB11]], label [[BB15:%.*]]
22 ; CHECK-NEXT: [[TMP12_BASE:%.*]] = phi i8 addrspace(1)* [ [[BASE_EE]], [[BB7]] ], [ [[BASE_EE]], [[BB9]] ], !is_base_value !0
23 ; CHECK-NEXT: [[TMP12:%.*]] = phi i8 addrspace(1)* [ [[TMP8]], [[BB7]] ], [ [[TMP10]], [[BB9]] ]
24 ; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @snork, i32 0, i32 0, i32 0, i32 0) [ "deopt"(i32 undef), "gc-live"(i8 addrspace(1)* [[TMP12_BASE]], i8 addrspace(1)* [[TMP12]]) ]
25 ; CHECK-NEXT: [[TMP12_BASE_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
26 ; CHECK-NEXT: [[TMP12_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 0, i32 1)
27 ; CHECK-NEXT: br label [[BB15]]
29 ; CHECK-NEXT: [[TMP16_BASE:%.*]] = phi i8 addrspace(1)* [ [[BASE_EE]], [[BB9]] ], [ [[TMP12_BASE_RELOCATED]], [[BB11]] ], !is_base_value !0
30 ; CHECK-NEXT: [[TMP16:%.*]] = phi i8 addrspace(1)* [ [[TMP10]], [[BB9]] ], [ [[TMP12_RELOCATED]], [[BB11]] ]
31 ; CHECK-NEXT: br i1 undef, label [[BB17:%.*]], label [[BB20:%.*]]
33 ; CHECK-NEXT: [[STATEPOINT_TOKEN1:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @snork, i32 0, i32 0, i32 0, i32 0) [ "deopt"(i32 undef), "gc-live"(i8 addrspace(1)* [[TMP16_BASE]], i8 addrspace(1)* [[TMP16]]) ]
34 ; CHECK-NEXT: [[TMP16_BASE_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN1]], i32 0, i32 0)
35 ; CHECK-NEXT: [[TMP16_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN1]], i32 0, i32 1)
36 ; CHECK-NEXT: br label [[BB20]]
38 ; CHECK-DAG: [[DOT05:%.*]] = phi i8 addrspace(1)* [ [[TMP16_BASE_RELOCATED]], [[BB17]] ], [ [[TMP16_BASE]], [[BB15]] ]
39 ; CHECK-DAG: [[DOT0:%.*]] = phi i8 addrspace(1)* [ [[TMP16_RELOCATED]], [[BB17]] ], [ [[TMP16]], [[BB15]] ]
40 ; CHECK-NEXT: [[STATEPOINT_TOKEN2:%.*]] = call token (i64, i32, void (i8 addrspace(1)*)*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidp1i8f(i64 2882400000, i32 0, void (i8 addrspace(1)*)* @foo, i32 1, i32 0, i8 addrspace(1)* [[DOT0]], i32 0, i32 0) [ "gc-live"(i8 addrspace(1)* [[DOT05]], i8 addrspace(1)* [[DOT0]]) ]
41 ; CHECK-NEXT: [[TMP16_BASE_RELOCATED3:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN2]], i32 0, i32 0)
42 ; CHECK-NEXT: [[TMP16_RELOCATED4:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN2]], i32 0, i32 1)
43 ; CHECK-NEXT: ret void
46 %tmp = extractelement <2 x i8 addrspace(1)*> undef, i32 1
47 br i1 undef, label %bb7, label %bb9
50 %tmp8 = getelementptr inbounds i8, i8 addrspace(1)* %tmp, i64 12
53 bb9: ; preds = %bb6, %bb6
54 %tmp10 = getelementptr inbounds i8, i8 addrspace(1)* %tmp, i64 12
55 br i1 undef, label %bb11, label %bb15
57 bb11: ; preds = %bb9, %bb7
58 %tmp12 = phi i8 addrspace(1)* [ %tmp8, %bb7 ], [ %tmp10, %bb9 ]
59 call void @snork() [ "deopt"(i32 undef) ]
62 bb15: ; preds = %bb11, %bb9, %bb9
63 %tmp16 = phi i8 addrspace(1)* [ %tmp10, %bb9 ], [ %tmp12, %bb11 ]
64 br i1 undef, label %bb17, label %bb20
67 call void @snork() [ "deopt"(i32 undef) ]
70 bb20: ; preds = %bb17, %bb15, %bb15
71 call void @foo(i8 addrspace(1)* %tmp16)
76 declare void @foo(i8 addrspace(1)*)