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