Brendon Cahoon | 7769a08 | 2017-04-17 19:11:04 +0000 | [diff] [blame^] | 1 | ; RUN: opt -codegenprepare -S < %s | FileCheck %s |
| 2 | |
| 3 | ; Test that an invalid CFG is not created by splitIndirectCriticalEdges |
| 4 | ; transformation when the 'target' block is a loop to itself. |
| 5 | |
| 6 | ; CHECK: .split: |
| 7 | ; CHECK: br label %while.body.clone |
| 8 | ; CHECK: if.else1: |
| 9 | ; CHECK: indirectbr |
| 10 | ; CHECK: while.body.clone: |
| 11 | ; CHECK: br label %.split |
| 12 | |
| 13 | define void @test() { |
| 14 | entry: |
| 15 | br label %if.else |
| 16 | |
| 17 | if.else: |
| 18 | br i1 undef, label %while.body, label %preheader |
| 19 | |
| 20 | preheader: |
| 21 | br label %if.else1 |
| 22 | |
| 23 | if.then: |
| 24 | unreachable |
| 25 | |
| 26 | while.body: |
| 27 | %dest.sroa = phi i32 [ %1, %while.body ], [ undef, %if.else1 ], [ undef, %if.else ] |
| 28 | %0 = inttoptr i32 %dest.sroa to i8* |
| 29 | %incdec.ptr = getelementptr inbounds i8, i8* %0, i32 -1 |
| 30 | %1 = ptrtoint i8* %incdec.ptr to i32 |
| 31 | store i8 undef, i8* %incdec.ptr, align 1 |
| 32 | br label %while.body |
| 33 | |
| 34 | if.else1: |
| 35 | indirectbr i8* undef, [label %if.then, label %while.body, label %if.else, label %if.else1] |
| 36 | } |
| 37 | |