1 ; RUN: opt -S -rewrite-statepoints-for-gc < %s | FileCheck %s
3 ; Regression test to incorrectly testing fixed state causing infinite loop.
5 target triple = "x86_64-unknown-linux-gnu"
7 declare void @bar(i8 addrspace(1)* nocapture readonly)
8 declare noalias i8 addrspace(1)* @foo()
10 define i8 addrspace(1)* @test(i1 %c, i1 %c1, i1 %c2, i1 %c3, i1 %c4, i1 %c5, i1 %c.exit) gc "statepoint-example" {
12 br i1 %c, label %ph.L, label %ph.R
14 %ph.L.p.b = call noalias nonnull i8 addrspace(1)* @foo()
15 %ph.L.p = getelementptr i8, i8 addrspace(1)* %ph.L.p.b, i64 8
18 %ph.R.p = call noalias nonnull i8 addrspace(1)* @foo()
21 %ph.M.p = phi i8 addrspace(1)* [ %ph.L.p, %ph.L ], [ %ph.R.p, %ph.R ]
25 %header.p = phi i8 addrspace(1)* [ %ph.M.p, %ph.M ], [ %backedge.p, %backedge]
26 br i1 %c1, label %loop.M, label %loop.R
29 br i1 %c2, label %loop.R.M, label %loop.R.R
32 %loop.R.R.p = call noalias nonnull i8 addrspace(1)* @foo()
36 %loop.R.M.p = phi i8 addrspace(1)* [ %header.p, %loop.R ], [ %loop.R.R.p, %loop.R.R ]
40 %loop.M.p = phi i8 addrspace(1)* [ %loop.R.M.p, %loop.R.M ], [ %header.p, %header ]
41 br i1 %c4, label %backedge, label %pre.backedge.R
44 br i1 %c5, label %pre.backedge.R.L, label %pre.backedge.R.R
46 %pre.backedge.R.L.p.b = call noalias nonnull i8 addrspace(1)* @foo()
47 %pre.backedge.R.L.p = getelementptr i8, i8 addrspace(1)* %pre.backedge.R.L.p.b, i64 8
48 br label %pre.backedge.R.M
50 %pre.backedge.R.R.p = call noalias nonnull i8 addrspace(1)* @foo()
51 br label %pre.backedge.R.M
53 %pre.backedge.R.M.p = phi i8 addrspace(1)* [ %pre.backedge.R.L.p, %pre.backedge.R.L ], [ %pre.backedge.R.R.p, %pre.backedge.R.R ]
57 %backedge.p = phi i8 addrspace(1)* [ %pre.backedge.R.M.p, %pre.backedge.R.M ], [ %loop.M.p, %loop.M ]
58 br i1 %c.exit, label %header, label %exit
60 exit: ; preds = %3, %1
61 call void @bar(i8 addrspace(1)* align 8 %header.p) [ "deopt"() ]
62 ret i8 addrspace(1)* %header.p