diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2016-02-21 13:51:43 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2016-02-21 13:51:43 +0000 |
| commit | 3f4bde29a30d8c43db5cbe8f5541ebc5d1fdc6af (patch) | |
| tree | 87140683fc3fee4e14b3c37e2aa7a4031d473f49 /test/CodeGen | |
| parent | a322a4af1fe8b989fe5d1bbc15de8736a26c03ca (diff) | |
Notes
Diffstat (limited to 'test/CodeGen')
| -rw-r--r-- | test/CodeGen/AArch64/fcopysign.ll | 23 | ||||
| -rw-r--r-- | test/CodeGen/WinEH/wineh-noret-cleanup.ll | 80 | ||||
| -rw-r--r-- | test/CodeGen/X86/pr26625.ll | 20 | ||||
| -rw-r--r-- | test/CodeGen/X86/regalloc-spill-at-ehpad.ll | 75 | ||||
| -rw-r--r-- | test/CodeGen/X86/shrink-wrap-chkstk.ll | 35 |
5 files changed, 233 insertions, 0 deletions
diff --git a/test/CodeGen/AArch64/fcopysign.ll b/test/CodeGen/AArch64/fcopysign.ll new file mode 100644 index 000000000000..6bda33cf76ef --- /dev/null +++ b/test/CodeGen/AArch64/fcopysign.ll @@ -0,0 +1,23 @@ +; RUN: llc -o - %s | FileCheck %s +; Check that selection dag legalization of fcopysign works in cases with +; different modes for the arguments. +target triple = "aarch64--" + +declare fp128 @llvm.copysign.f128(fp128, fp128) + +@val = global double zeroinitializer, align 8 + +; CHECK-LABEL: copysign0 +; CHECK: ldr [[REG:x[0-9]+]], [x8, :lo12:val] +; CHECK: and [[ANDREG:x[0-9]+]], [[REG]], #0x8000000000000000 +; CHECK: lsr x[[LSRREGNUM:[0-9]+]], [[ANDREG]], #56 +; CHECK: bfxil w[[LSRREGNUM]], w{{[0-9]+}}, #0, #7 +; CHECK: strb w[[LSRREGNUM]], +; CHECK: ldr q{{[0-9]+}}, +define fp128 @copysign0() { +entry: + %v = load double, double* @val, align 8 + %conv = fpext double %v to fp128 + %call = tail call fp128 @llvm.copysign.f128(fp128 0xL00000000000000007FFF000000000000, fp128 %conv) #2 + ret fp128 %call +} diff --git a/test/CodeGen/WinEH/wineh-noret-cleanup.ll b/test/CodeGen/WinEH/wineh-noret-cleanup.ll new file mode 100644 index 000000000000..7d4d833aa9ba --- /dev/null +++ b/test/CodeGen/WinEH/wineh-noret-cleanup.ll @@ -0,0 +1,80 @@ +; RUN: sed -e s/.Cxx:// %s | llc -mtriple=x86_64-pc-windows-msvc | FileCheck %s --check-prefix=CXX +; RUN: sed -e s/.Seh:// %s | llc -mtriple=x86_64-pc-windows-msvc | FileCheck %s --check-prefix=SEH + +declare i32 @__CxxFrameHandler3(...) +declare i32 @__C_specific_handler(...) +declare void @dummy_filter() + +declare void @f(i32) + +;Cxx: define void @test() personality i32 (...)* @__CxxFrameHandler3 { +;Seh: define void @test() personality i32 (...)* @__C_specific_handler { +entry: + invoke void @f(i32 1) + to label %invoke.cont unwind label %catch.dispatch + +catch.dispatch: + %cs1 = catchswitch within none [label %catch.body] unwind label %catch.dispatch.2 + +catch.body: +;Cxx: %catch = catchpad within %cs1 [i8* null, i32 u0x40, i8* null] +;Seh: %catch = catchpad within %cs1 [void ()* @dummy_filter] + invoke void @f(i32 2) [ "funclet"(token %catch) ] + to label %unreachable unwind label %terminate + +terminate: + %cleanup = cleanuppad within %catch [] + call void @f(i32 3) [ "funclet"(token %cleanup) ] + unreachable + +unreachable: + unreachable + +invoke.cont: + ret void + +catch.dispatch.2: + %cs2 = catchswitch within none [label %catch.body.2] unwind to caller + +catch.body.2: +;Cxx: %catch2 = catchpad within %cs2 [i8* null, i32 u0x40, i8* null] +;Seh: %catch2 = catchpad within %cs2 [void ()* @dummy_filter] + unreachable +} + +; CXX-LABEL: test: +; CXX-LABEL: $ip2state$test: +; CXX-NEXT: .long .Lfunc_begin0@IMGREL +; CXX-NEXT: .long -1 +; CXX-NEXT: .long .Ltmp0@IMGREL+1 +; CXX-NEXT: .long 1 +; CXX-NEXT: .long .Ltmp1@IMGREL+1 +; CXX-NEXT: .long -1 +; CXX-NEXT: .long "?catch$3@?0?test@4HA"@IMGREL +; CXX-NEXT: .long 2 +; CXX-NEXT: .long .Ltmp2@IMGREL+1 +; CXX-NEXT: .long 3 +; CXX-NEXT: .long .Ltmp3@IMGREL+1 +; CXX-NEXT: .long 2 +; CXX-NEXT: .long "?catch$5@?0?test@4HA"@IMGREL +; CXX-NEXT: .long 4 + +; SEH-LABEL: test: +; SEH-LABEL: .Llsda_begin0: +; SEH-NEXT: .long .Ltmp0@IMGREL+1 +; SEH-NEXT: .long .Ltmp1@IMGREL+1 +; SEH-NEXT: .long dummy_filter@IMGREL +; SEH-NEXT: .long .LBB0_3@IMGREL +; SEH-NEXT: .long .Ltmp0@IMGREL+1 +; SEH-NEXT: .long .Ltmp1@IMGREL+1 +; SEH-NEXT: .long dummy_filter@IMGREL +; SEH-NEXT: .long .LBB0_5@IMGREL +; SEH-NEXT: .long .Ltmp2@IMGREL+1 +; SEH-NEXT: .long .Ltmp3@IMGREL+1 +; SEH-NEXT: .long "?dtor$2@?0?test@4HA"@IMGREL +; SEH-NEXT: .long 0 +; SEH-NEXT: .long .Ltmp2@IMGREL+1 +; SEH-NEXT: .long .Ltmp3@IMGREL+1 +; SEH-NEXT: .long dummy_filter@IMGREL +; SEH-NEXT: .long .LBB0_5@IMGREL +; SEH-NEXT: .Llsda_end0: diff --git a/test/CodeGen/X86/pr26625.ll b/test/CodeGen/X86/pr26625.ll new file mode 100644 index 000000000000..1b2e227bb59a --- /dev/null +++ b/test/CodeGen/X86/pr26625.ll @@ -0,0 +1,20 @@ +; RUN: llc < %s -mcpu=i686 2>&1 | FileCheck %s +; PR26625 + +target datalayout = "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128" +target triple = "i386" + +define float @x0(float %f) #0 { +entry: + %call = tail call float @sqrtf(float %f) #1 + ret float %call +; CHECK-LABEL: x0: +; CHECK: flds +; CHECK-NEXT: fsqrt +; CHECK-NOT: vsqrtss +} + +declare float @sqrtf(float) #0 + +attributes #0 = { nounwind optsize readnone } +attributes #1 = { nounwind optsize readnone } diff --git a/test/CodeGen/X86/regalloc-spill-at-ehpad.ll b/test/CodeGen/X86/regalloc-spill-at-ehpad.ll new file mode 100644 index 000000000000..32cc9e781fb6 --- /dev/null +++ b/test/CodeGen/X86/regalloc-spill-at-ehpad.ll @@ -0,0 +1,75 @@ +; RUN: llc -regalloc=greedy -mtriple=x86_64-pc-windows-msvc < %s -o - | FileCheck %s + +; This test checks for proper handling of a condition where the greedy register +; allocator encounters a very short interval that contains no uses but does +; contain an EH pad unwind edge, which requires spilling. Previously the +; register allocator marked a interval like this as unspillable, resulting in +; a compilation failure. + + +; The following checks that the value %p is reloaded within the catch handler. +; CHECK-LABEL: "?catch$8@?0?test@4HA": +; CHECK: .seh_endprologue +; CHECK: movq -16(%rbp), %rax +; CHECK: movb $0, (%rax) + +define i32* @test(i32* %a) personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) { +entry: + %call = call i32 @f() + %p = bitcast i32* %a to i8* + br i1 undef, label %if.end, label %if.else + +if.else: ; preds = %entry + br i1 undef, label %cond.false.i, label %if.else.else + +if.else.else: ; preds = %if.else + br i1 undef, label %cond.true.i, label %cond.false.i + +cond.true.i: ; preds = %if.else.else + br label %invoke.cont + +cond.false.i: ; preds = %if.else.else, %if.else + %call.i = invoke i32 @f() + to label %invoke.cont unwind label %catch.dispatch + +catch.dispatch: ; preds = %cond.false.i + %tmp0 = catchswitch within none [label %catch] unwind label %ehcleanup + +catch: ; preds = %catch.dispatch + %tmp1 = catchpad within %tmp0 [i8* null, i32 64, i8* null] + %p.0 = getelementptr inbounds i8, i8* %p, i64 0 + store i8 0, i8* %p.0, align 8 + invoke void @_CxxThrowException(i8* null, %eh.ThrowInfo* null) [ "funclet"(token %tmp1) ] + to label %noexc unwind label %ehcleanup + +noexc: ; preds = %catch + unreachable + +invoke.cont: ; preds = %cond.false.i, %cond.true.i + %cond.i = phi i32 [ %call, %cond.true.i ], [ %call.i, %cond.false.i ] + %cmp = icmp eq i32 %cond.i, -1 + %tmp3 = select i1 %cmp, i32 4, i32 0 + br label %if.end + +if.end: ; preds = %invoke.cont, %entry + %state.0 = phi i32 [ %tmp3, %invoke.cont ], [ 4, %entry ] + %p.1 = getelementptr inbounds i8, i8* %p, i64 0 + invoke void @g(i8* %p.1, i32 %state.0) + to label %invoke.cont.1 unwind label %ehcleanup + +invoke.cont.1: ; preds = %if.end + ret i32* %a + +ehcleanup: ; preds = %if.end, %catch, %catch.dispatch + %tmp4 = cleanuppad within none [] + cleanupret from %tmp4 unwind to caller +} + +%eh.ThrowInfo = type { i32, i32, i32, i32 } + +declare i32 @__CxxFrameHandler3(...) + +declare void @_CxxThrowException(i8*, %eh.ThrowInfo*) + +declare i32 @f() +declare void @g(i8*, i32) diff --git a/test/CodeGen/X86/shrink-wrap-chkstk.ll b/test/CodeGen/X86/shrink-wrap-chkstk.ll index c0b2b45e676f..aecae89aee56 100644 --- a/test/CodeGen/X86/shrink-wrap-chkstk.ll +++ b/test/CodeGen/X86/shrink-wrap-chkstk.ll @@ -1,6 +1,8 @@ ; RUN: llc < %s -enable-shrink-wrap=true | FileCheck %s ; chkstk cannot come before the usual prologue, since it adjusts ESP. +; If chkstk is used in the prologue, we also have to be careful about preserving +; EAX if it is used. target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32" target triple = "i686-pc-windows-msvc18.0.0" @@ -35,3 +37,36 @@ bb2: ; CHECK: retl declare void @inalloca_params(<{ %struct.S }>* inalloca) + +declare i32 @doSomething(i32, i32*) + +; In this test case, we force usage of EAX before the prologue, and have to +; compensate before calling __chkstk. It would also be valid for us to avoid +; shrink wrapping in this case. + +define x86_fastcallcc i32 @use_eax_before_prologue(i32 inreg %a, i32 inreg %b) { + %tmp = alloca i32, i32 1024, align 4 + %tmp2 = icmp slt i32 %a, %b + br i1 %tmp2, label %true, label %false + +true: + store i32 %a, i32* %tmp, align 4 + %tmp4 = call i32 @doSomething(i32 0, i32* %tmp) + br label %false + +false: + %tmp.0 = phi i32 [ %tmp4, %true ], [ %a, %0 ] + ret i32 %tmp.0 +} + +; CHECK-LABEL: @use_eax_before_prologue@8: # @use_eax_before_prologue +; CHECK: movl %ecx, %eax +; CHECK: cmpl %edx, %eax +; CHECK: jge LBB1_2 +; CHECK: pushl %eax +; CHECK: movl $4100, %eax +; CHECK: calll __chkstk +; CHECK: movl 4100(%esp), %eax +; CHECK: calll _doSomething +; CHECK: LBB1_2: +; CHECK: retl |
