• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -rewrite-statepoints-for-gc -S < %s | FileCheck %s
2; RUN: opt -passes=rewrite-statepoints-for-gc -S < %s | FileCheck %s
3
4; Test to make sure we destroy LCSSA's single entry phi nodes before
5; running liveness
6
7declare void @consume(...) "gc-leaf-function"
8
9define void @test6(i64 addrspace(1)* %obj) gc "statepoint-example" {
10; CHECK-LABEL: @test6
11entry:
12  br label %next
13
14next:                                             ; preds = %entry
15; CHECK-LABEL: next:
16; CHECK-NEXT: gc.statepoint
17; CHECK-NEXT: gc.relocate
18; CHECK-NEXT: bitcast
19; CHECK-NEXT: @consume(i64 addrspace(1)* %obj.relocated.casted)
20; CHECK-NEXT: @consume(i64 addrspace(1)* %obj.relocated.casted)
21; Need to delete unreachable gc.statepoint call
22  %obj2 = phi i64 addrspace(1)* [ %obj, %entry ]
23  call void @foo() [ "deopt"() ]
24  call void (...) @consume(i64 addrspace(1)* %obj2)
25  call void (...) @consume(i64 addrspace(1)* %obj)
26  ret void
27}
28
29define void @test7() gc "statepoint-example" {
30; CHECK-LABEL: test7
31; CHECK-NOT: gc.statepoint
32; Need to delete unreachable gc.statepoint invoke - tested separately given
33; a correct implementation could only remove the instructions, not the block
34  ret void
35
36unreached:                                        ; preds = %unreached
37  %obj = phi i64 addrspace(1)* [ null, %unreached ]
38  call void @foo() [ "deopt"() ]
39  call void (...) @consume(i64 addrspace(1)* %obj)
40  br label %unreached
41}
42
43define void @test8() gc "statepoint-example" personality i32 ()* undef {
44; CHECK-LABEL: test8
45; CHECK-NOT: gc.statepoint
46; Bound the last check-not
47  ret void
48
49unreached:                                        ; No predecessors!
50  invoke void @foo() [ "deopt"() ]
51; CHECK-LABEL: @foo
52          to label %normal_return unwind label %exceptional_return
53
54normal_return:                                    ; preds = %unreached
55  ret void
56
57exceptional_return:                               ; preds = %unreached
58  %landing_pad4 = landingpad { i8*, i32 }
59          cleanup
60  ret void
61}
62
63declare void @foo()
64