1 ; RUN: opt -passes=rewrite-statepoints-for-gc -S < %s | FileCheck %s
3 ; Test to make sure we destroy LCSSA's single entry phi nodes before
6 declare void @consume(...) "gc-leaf-function"
8 define void @test6(ptr addrspace(1) %obj) gc "statepoint-example" {
13 next: ; preds = %entry
15 ; CHECK-NEXT: gc.statepoint
16 ; CHECK-NEXT: gc.relocate
17 ; CHECK-NEXT: @consume(ptr addrspace(1) %obj.relocated)
18 ; CHECK-NEXT: @consume(ptr addrspace(1) %obj.relocated)
19 ; Need to delete unreachable gc.statepoint call
20 %obj2 = phi ptr addrspace(1) [ %obj, %entry ]
21 call void @foo() [ "deopt"() ]
22 call void (...) @consume(ptr addrspace(1) %obj2)
23 call void (...) @consume(ptr addrspace(1) %obj)
27 define void @test7() gc "statepoint-example" {
29 ; CHECK-NOT: gc.statepoint
30 ; Need to delete unreachable gc.statepoint invoke - tested separately given
31 ; a correct implementation could only remove the instructions, not the block
34 unreached: ; preds = %unreached
35 %obj = phi ptr addrspace(1) [ null, %unreached ]
36 call void @foo() [ "deopt"() ]
37 call void (...) @consume(ptr addrspace(1) %obj)
41 define void @test8() gc "statepoint-example" personality ptr undef {
43 ; CHECK-NOT: gc.statepoint
44 ; Bound the last check-not
47 unreached: ; No predecessors!
48 invoke void @foo() [ "deopt"() ]
50 to label %normal_return unwind label %exceptional_return
52 normal_return: ; preds = %unreached
55 exceptional_return: ; preds = %unreached
56 %landing_pad4 = landingpad { ptr, i32 }