1 ; RUN: llc -regalloc=greedy -mtriple=x86_64-pc-windows-msvc < %s -o - | FileCheck %s 2 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. 8 9 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) 15 16 define i32* @test(i32* %a) personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) { 17 entry: 18 %call = call i32 @f() 19 %p = bitcast i32* %a to i8* 20 br i1 undef, label %if.end, label %if.else 21 22 if.else: ; preds = %entry 23 br i1 undef, label %cond.false.i, label %if.else.else 24 25 if.else.else: ; preds = %if.else 26 br i1 undef, label %cond.true.i, label %cond.false.i 27 28 cond.true.i: ; preds = %if.else.else 29 br label %invoke.cont 30 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 34 35 catch.dispatch: ; preds = %cond.false.i 36 %tmp0 = catchswitch within none [label %catch] unwind label %ehcleanup 37 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 44 45 noexc: ; preds = %catch 46 unreachable 47 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 52 br label %if.end 53 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 59 60 invoke.cont.1: ; preds = %if.end 61 ret i32* %a 62 63 ehcleanup: ; preds = %if.end, %catch, %catch.dispatch 64 %tmp4 = cleanuppad within none [] 65 cleanupret from %tmp4 unwind to caller 66 } 67 68 %eh.ThrowInfo = type { i32, i32, i32, i32 } 69 70 declare i32 @__CxxFrameHandler3(...) 71 72 declare void @_CxxThrowException(i8*, %eh.ThrowInfo*) 73 74 declare i32 @f() 75 declare void @g(i8*, i32) 76