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 i32* @test(i32* %a) personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
19 %p = bitcast i32* %a to i8*
20 br i1 undef, label %if.end, label %if.else
22 if.else: ; preds = %entry
23 br i1 undef, label %cond.false.i, label %if.else.else
25 if.else.else: ; preds = %if.else
26 br i1 undef, label %cond.true.i, label %cond.false.i
28 cond.true.i: ; preds = %if.else.else
31 cond.false.i: ; preds = %if.else.else, %if.else
32 %call.i = invoke i32 @f()
33 to label %invoke.cont unwind label %catch.dispatch
35 catch.dispatch: ; preds = %cond.false.i
36 %tmp0 = catchswitch within none [label %catch] unwind label %ehcleanup
38 catch: ; preds = %catch.dispatch
39 %tmp1 = catchpad within %tmp0 [i8* null, i32 64, i8* null]
40 %p.0 = getelementptr inbounds i8, i8* %p, i64 0
41 store i8 0, i8* %p.0, align 8
42 invoke void @_CxxThrowException(i8* null, %eh.ThrowInfo* null) [ "funclet"(token %tmp1) ]
43 to label %noexc unwind label %ehcleanup
45 noexc: ; preds = %catch
48 invoke.cont: ; preds = %cond.false.i, %cond.true.i
49 %cond.i = phi i32 [ %call, %cond.true.i ], [ %call.i, %cond.false.i ]
50 %cmp = icmp eq i32 %cond.i, -1
51 %tmp3 = select i1 %cmp, i32 4, i32 0
54 if.end: ; preds = %invoke.cont, %entry
55 %state.0 = phi i32 [ %tmp3, %invoke.cont ], [ 4, %entry ]
56 %p.1 = getelementptr inbounds i8, i8* %p, i64 0
57 invoke void @g(i8* %p.1, i32 %state.0)
58 to label %invoke.cont.1 unwind label %ehcleanup
60 invoke.cont.1: ; preds = %if.end
63 ehcleanup: ; preds = %if.end, %catch, %catch.dispatch
64 %tmp4 = cleanuppad within none []
65 cleanupret from %tmp4 unwind to caller
68 %eh.ThrowInfo = type { i32, i32, i32, i32 }
70 declare i32 @__CxxFrameHandler3(...)
72 declare void @_CxxThrowException(i8*, %eh.ThrowInfo*)
75 declare void @g(i8*, i32)