Andrew Kaylor | 9efb233 | 2015-12-03 18:55:28 +0000 | [diff] [blame] | 1 | ; RUN: llc -mtriple=x86_64-pc-windows-msvc < %s | FileCheck %s |
Andrew Kaylor | 9efb233 | 2015-12-03 18:55:28 +0000 | [diff] [blame] | 2 | |
| 3 | declare i32 @__CxxFrameHandler3(...) |
| 4 | |
| 5 | declare void @throw() |
| 6 | declare i16 @f() |
| 7 | |
| 8 | define i16 @test1(i16 %a, i8* %b) personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) { |
| 9 | entry: |
| 10 | %cmp = icmp eq i16 %a, 10 |
| 11 | br i1 %cmp, label %if.then, label %if.else |
| 12 | |
| 13 | if.then: |
| 14 | %call1 = invoke i16 @f() |
| 15 | to label %cleanup unwind label %catch.dispatch |
| 16 | |
| 17 | if.else: |
| 18 | %call2 = invoke i16 @f() |
| 19 | to label %cleanup unwind label %catch.dispatch |
| 20 | |
| 21 | catch.dispatch: |
David Majnemer | 8a1c45d | 2015-12-12 05:38:55 +0000 | [diff] [blame] | 22 | %cs = catchswitch within none [ label %catch, label %catch.2 ] unwind to caller |
Andrew Kaylor | 9efb233 | 2015-12-03 18:55:28 +0000 | [diff] [blame] | 23 | |
| 24 | catch: |
David Majnemer | 8a1c45d | 2015-12-12 05:38:55 +0000 | [diff] [blame] | 25 | catchpad within %cs [i8* null, i32 8, i8* null] |
| 26 | call void @throw() noreturn |
| 27 | br label %unreachable |
Andrew Kaylor | 9efb233 | 2015-12-03 18:55:28 +0000 | [diff] [blame] | 28 | |
| 29 | catch.2: |
David Majnemer | 8a1c45d | 2015-12-12 05:38:55 +0000 | [diff] [blame] | 30 | catchpad within %cs [i8* null, i32 64, i8* null] |
Andrew Kaylor | 9efb233 | 2015-12-03 18:55:28 +0000 | [diff] [blame] | 31 | store i8 1, i8* %b |
David Majnemer | 8a1c45d | 2015-12-12 05:38:55 +0000 | [diff] [blame] | 32 | call void @throw() noreturn |
| 33 | br label %unreachable |
Andrew Kaylor | 9efb233 | 2015-12-03 18:55:28 +0000 | [diff] [blame] | 34 | |
| 35 | cleanup: |
| 36 | %retval = phi i16 [ %call1, %if.then ], [ %call2, %if.else ] |
| 37 | ret i16 %retval |
| 38 | |
| 39 | unreachable: |
| 40 | unreachable |
| 41 | } |
| 42 | |
| 43 | ; This test verifies the case where two funclet blocks meet the old criteria |
| 44 | ; to be placed at the end. The order of the blocks is not important for the |
| 45 | ; purposes of this test. The failure mode is an infinite loop during |
| 46 | ; compilation. |
| 47 | ; |
| 48 | ; CHECK-LABEL: .def test1; |
| 49 | |
| 50 | define i16 @test2(i16 %a, i8* %b) personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) { |
| 51 | entry: |
| 52 | %cmp = icmp eq i16 %a, 10 |
| 53 | br i1 %cmp, label %if.then, label %if.else |
| 54 | |
| 55 | if.then: |
| 56 | %call1 = invoke i16 @f() |
| 57 | to label %cleanup unwind label %catch.dispatch |
| 58 | |
| 59 | if.else: |
| 60 | %call2 = invoke i16 @f() |
| 61 | to label %cleanup unwind label %catch.dispatch |
| 62 | |
| 63 | catch.dispatch: |
David Majnemer | 8a1c45d | 2015-12-12 05:38:55 +0000 | [diff] [blame] | 64 | %cs = catchswitch within none [ label %catch, label %catch.2, label %catch.3 ] unwind to caller |
Andrew Kaylor | 9efb233 | 2015-12-03 18:55:28 +0000 | [diff] [blame] | 65 | |
| 66 | catch: |
David Majnemer | 8a1c45d | 2015-12-12 05:38:55 +0000 | [diff] [blame] | 67 | catchpad within %cs [i8* null, i32 8, i8* null] |
| 68 | call void @throw() noreturn |
| 69 | br label %unreachable |
Andrew Kaylor | 9efb233 | 2015-12-03 18:55:28 +0000 | [diff] [blame] | 70 | |
| 71 | catch.2: |
David Majnemer | 8a1c45d | 2015-12-12 05:38:55 +0000 | [diff] [blame] | 72 | %c2 = catchpad within %cs [i8* null, i32 32, i8* null] |
Andrew Kaylor | 9efb233 | 2015-12-03 18:55:28 +0000 | [diff] [blame] | 73 | store i8 1, i8* %b |
David Majnemer | 8a1c45d | 2015-12-12 05:38:55 +0000 | [diff] [blame] | 74 | catchret from %c2 to label %cleanup |
Andrew Kaylor | 9efb233 | 2015-12-03 18:55:28 +0000 | [diff] [blame] | 75 | |
| 76 | catch.3: |
David Majnemer | 8a1c45d | 2015-12-12 05:38:55 +0000 | [diff] [blame] | 77 | %c3 = catchpad within %cs [i8* null, i32 64, i8* null] |
Andrew Kaylor | 9efb233 | 2015-12-03 18:55:28 +0000 | [diff] [blame] | 78 | store i8 2, i8* %b |
David Majnemer | 8a1c45d | 2015-12-12 05:38:55 +0000 | [diff] [blame] | 79 | catchret from %c3 to label %cleanup |
Andrew Kaylor | 9efb233 | 2015-12-03 18:55:28 +0000 | [diff] [blame] | 80 | |
| 81 | cleanup: |
| 82 | %retval = phi i16 [ %call1, %if.then ], [ %call2, %if.else ], [ -1, %catch.2 ], [ -1, %catch.3 ] |
| 83 | ret i16 %retval |
| 84 | |
| 85 | unreachable: |
| 86 | unreachable |
| 87 | } |
| 88 | |
| 89 | ; This test verifies the case where three funclet blocks all meet the old |
| 90 | ; criteria to be placed at the end. The order of the blocks is not important |
| 91 | ; for the purposes of this test. The failure mode is an infinite loop during |
| 92 | ; compilation. |
| 93 | ; |
| 94 | ; CHECK-LABEL: .def test2; |
| 95 | |
Andrew Kaylor | ff6a1ed | 2016-12-12 23:05:38 +0000 | [diff] [blame] | 96 | declare void @g() |
| 97 | |
| 98 | define void @test3() optsize personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) { |
| 99 | entry: |
| 100 | switch i32 undef, label %if.end57 [ |
| 101 | i32 64, label %sw.bb |
| 102 | i32 128, label %sw.epilog |
| 103 | i32 256, label %if.then56 |
| 104 | i32 1024, label %sw.bb |
| 105 | i32 4096, label %sw.bb33 |
| 106 | i32 16, label %sw.epilog |
| 107 | i32 8, label %sw.epilog |
| 108 | i32 32, label %sw.bb44 |
| 109 | ] |
| 110 | |
| 111 | sw.bb: |
| 112 | unreachable |
| 113 | |
| 114 | sw.bb33: |
| 115 | br i1 undef, label %if.end57, label %while.cond.i163.preheader |
| 116 | |
| 117 | while.cond.i163.preheader: |
| 118 | unreachable |
| 119 | |
| 120 | sw.bb44: |
| 121 | %temp0 = load void ()*, void ()** undef |
| 122 | invoke void %temp0() |
| 123 | to label %if.end57 unwind label %catch.dispatch |
| 124 | |
| 125 | sw.epilog: |
| 126 | %temp1 = load i8*, i8** undef |
| 127 | br label %if.end57 |
| 128 | |
| 129 | catch.dispatch: |
| 130 | %cs = catchswitch within none [label %catch1, label %catch2, label %catch3] unwind to caller |
| 131 | |
| 132 | catch1: |
| 133 | %c1 = catchpad within %cs [i8* null, i32 8, i8* null] |
| 134 | unreachable |
| 135 | |
| 136 | catch2: |
| 137 | %c2 = catchpad within %cs [i8* null, i32 32, i8* null] |
| 138 | unreachable |
| 139 | |
| 140 | catch3: |
| 141 | %c3 = catchpad within %cs [i8* null, i32 64, i8* null] |
| 142 | unreachable |
| 143 | |
| 144 | if.then56: |
| 145 | call void @g() |
| 146 | br label %if.end57 |
| 147 | |
| 148 | if.end57: |
| 149 | ret void |
| 150 | } |
| 151 | |
| 152 | ; This test exercises a complex case that produced an infinite loop during |
| 153 | ; compilation when the two cases above did not. The multiple targets from the |
| 154 | ; entry switch are not actually fundamental to the failure, but they are |
| 155 | ; necessary to suppress various control flow optimizations that would prevent |
| 156 | ; the conditions that lead to the failure. |
| 157 | ; |
| 158 | ; CHECK-LABEL: .def test3; |
| 159 | |