1 ; RUN: llc -mtriple=x86_64-unknown-unknown < %s | FileCheck %s
2 ; RUN: llc -mtriple=x86_64-unknown-unknown -O0 < %s | FileCheck %s -check-prefix=CHECK0
4 %struct.interrupt_frame = type { i64, i64, i64, i64, i64 }
6 @llvm.used = appending global [4 x i8*] [i8* bitcast (void (%struct.interrupt_frame*)* @test_isr_no_ecode to i8*), i8* bitcast (void (%struct.interrupt_frame*, i64)* @test_isr_ecode to i8*), i8* bitcast (void (%struct.interrupt_frame*, i64)* @test_isr_clobbers to i8*), i8* bitcast (void (%struct.interrupt_frame*)* @test_isr_x87 to i8*)], section "llvm.metadata"
8 ; Spills rax, putting original esp at +8.
9 ; No stack adjustment if declared with no error code
10 define x86_intrcc void @test_isr_no_ecode(%struct.interrupt_frame* %frame) {
11 ; CHECK-LABEL: test_isr_no_ecode:
13 ; CHECK: movq 24(%rsp), %rax
16 ; CHECK0-LABEL: test_isr_no_ecode:
18 ; CHECK0: leaq 8(%rsp), %rax
19 ; CHECK0: movq 16(%rax), %rax
22 %pflags = getelementptr inbounds %struct.interrupt_frame, %struct.interrupt_frame* %frame, i32 0, i32 2
23 %flags = load i64, i64* %pflags, align 4
24 call void asm sideeffect "", "r"(i64 %flags)
28 ; Spills rax and rcx, putting original rsp at +16. Stack is adjusted up another 8 bytes
29 ; before return, popping the error code.
30 define x86_intrcc void @test_isr_ecode(%struct.interrupt_frame* %frame, i64 %ecode) {
31 ; CHECK-LABEL: test_isr_ecode
35 ; CHECK: movq 24(%rsp), %rax
36 ; CHECK: movq 48(%rsp), %rcx
39 ; CHECK: addq $16, %rsp
41 ; CHECK0-LABEL: test_isr_ecode
45 ; CHECK0: movq 24(%rsp), %rax
46 ; CHECK0: leaq 32(%rsp), %rcx
47 ; CHECK0: movq 16(%rcx), %rcx
50 ; CHECK0: addq $16, %rsp
52 %pflags = getelementptr inbounds %struct.interrupt_frame, %struct.interrupt_frame* %frame, i32 0, i32 2
53 %flags = load i64, i64* %pflags, align 4
54 call void asm sideeffect "", "r,r"(i64 %flags, i64 %ecode)
58 ; All clobbered registers must be saved
59 define x86_intrcc void @test_isr_clobbers(%struct.interrupt_frame* %frame, i64 %ecode) {
60 call void asm sideeffect "", "~{rax},~{rbx},~{rbp},~{r11},~{xmm0}"()
61 ; CHECK-LABEL: test_isr_clobbers
68 ; CHECK: movaps {{.*}}, %xmm0
73 ; CHECK: addq $16, %rsp
75 ; CHECK0-LABEL: test_isr_clobbers
81 ; CHECK0: movaps %xmm0
82 ; CHECK0: movaps {{.*}}, %xmm0
87 ; CHECK0: addq $16, %rsp
92 @f80 = common global x86_fp80 0xK00000000000000000000, align 4
94 ; Test that the presence of x87 does not crash the FP stackifier
95 define x86_intrcc void @test_isr_x87(%struct.interrupt_frame* %frame) {
96 ; CHECK-LABEL: test_isr_x87
100 ; CHECK-NEXT: fstpt f80
103 %ld = load x86_fp80, x86_fp80* @f80, align 4
104 %add = fadd x86_fp80 %ld, 0xK3FFF8000000000000000
105 store x86_fp80 %add, x86_fp80* @f80, align 4