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