1 ; RUN: llc -regalloc=greedy -mtriple=x86_64-pc-windows-msvc < %s -o - | FileCheck %s
3 ; This test checks for proper handling of a condition where the greedy register
4 ; allocator encounters a very short interval that contains no uses but does
5 ; contain an EH pad unwind edge, which requires spilling. Previously the
6 ; register allocator marked a interval like this as unspillable, resulting in
7 ; a compilation failure.
10 ; The following checks that the value %p is reloaded within the catch handler.
11 ; CHECK-LABEL: "?catch$8@?0?test@4HA":
12 ; CHECK: .seh_endprologue
13 ; CHECK: movq -16(%rbp), %rax
14 ; CHECK: movb $0, (%rax)
16 define ptr @test(ptr %a) personality ptr @__CxxFrameHandler3 {
19 br i1 undef, label %if.end, label %if.else
21 if.else: ; preds = %entry
22 br i1 undef, label %cond.false.i, label %if.else.else
24 if.else.else: ; preds = %if.else
25 br i1 undef, label %cond.true.i, label %cond.false.i
27 cond.true.i: ; preds = %if.else.else
30 cond.false.i: ; preds = %if.else.else, %if.else
31 %call.i = invoke i32 @f()
32 to label %invoke.cont unwind label %catch.dispatch
34 catch.dispatch: ; preds = %cond.false.i
35 %tmp0 = catchswitch within none [label %catch] unwind label %ehcleanup
37 catch: ; preds = %catch.dispatch
38 %tmp1 = catchpad within %tmp0 [ptr null, i32 64, ptr null]
39 store i8 0, ptr %a, align 8
40 invoke void @_CxxThrowException(ptr null, ptr null) [ "funclet"(token %tmp1) ]
41 to label %noexc unwind label %ehcleanup
43 noexc: ; preds = %catch
46 invoke.cont: ; preds = %cond.false.i, %cond.true.i
47 %cond.i = phi i32 [ %call, %cond.true.i ], [ %call.i, %cond.false.i ]
48 %cmp = icmp eq i32 %cond.i, -1
49 %tmp3 = select i1 %cmp, i32 4, i32 0
52 if.end: ; preds = %invoke.cont, %entry
53 %state.0 = phi i32 [ %tmp3, %invoke.cont ], [ 4, %entry ]
54 invoke void @g(ptr %a, i32 %state.0)
55 to label %invoke.cont.1 unwind label %ehcleanup
57 invoke.cont.1: ; preds = %if.end
60 ehcleanup: ; preds = %if.end, %catch, %catch.dispatch
61 %tmp4 = cleanuppad within none []
62 cleanupret from %tmp4 unwind to caller
65 %eh.ThrowInfo = type { i32, i32, i32, i32 }
67 declare i32 @__CxxFrameHandler3(...)
69 declare void @_CxxThrowException(ptr, ptr)
72 declare void @g(ptr, i32)