Daniel Neilson | 82daad3 | 2018-03-05 22:27:30 +0000 | [diff] [blame] | 1 | ; RUN: opt -S -rewrite-statepoints-for-gc < %s | FileCheck %s |
| 2 | ; RUN: opt -S -passes=rewrite-statepoints-for-gc < %s | FileCheck %s |
| 3 | ; |
| 4 | ; Regression test: |
| 5 | ; After the rewritable callsite collection if any callsite was found |
| 6 | ; in a block that was reported unreachable by DominanceTree then |
| 7 | ; removeUnreachableBlocks() was called. But it is stronger than |
| 8 | ; DominatorTree::isReachableFromEntry(), i.e. removeUnreachableBlocks |
| 9 | ; can remove some blocks for which isReachableFromEntry() returns true. |
| 10 | ; This resulted in stale pointers to the collected but removed |
| 11 | ; callsites. Such stale pointers caused crash when accessed. |
| 12 | declare void @f(i8 addrspace(1)* %obj) |
| 13 | |
| 14 | define void @test(i8 addrspace(1)* %arg) gc "statepoint-example" { |
| 15 | ; CHECK-LABEL: test( |
| 16 | ; CHECK-NEXT: @f |
| 17 | call void @f(i8 addrspace(1)* %arg) #1 |
| 18 | br i1 true, label %not_zero, label %zero |
| 19 | |
| 20 | not_zero: |
| 21 | ret void |
| 22 | |
| 23 | ; This block is reachable but removed by removeUnreachableBlocks() |
| 24 | zero: |
| 25 | ; CHECK-NOT: @f |
| 26 | call void @f(i8 addrspace(1)* %arg) #1 |
| 27 | ret void |
| 28 | |
| 29 | unreach: |
| 30 | call void @f(i8 addrspace(1)* %arg) #1 |
| 31 | ret void |
| 32 | } |
| 33 | |
| 34 | attributes #1 = { norecurse noimplicitfloat } |