1 ; RUN: llc -mtriple=i686-unknown-unknown < %s | FileCheck %s
2 ; RUN: llc -mtriple=i686-unknown-unknown -O0 < %s | FileCheck %s -check-prefix=CHECK0
4 %struct.interrupt_frame = type { i32, i32, i32, i32, i32 }
6 @sink_address = global ptr null
7 @sink_i32 = global i32 0
10 ; Spills eax, putting original esp at +4.
11 ; No stack adjustment if declared with no error code
12 define x86_intrcc void @test_isr_no_ecode(ptr byval(%struct.interrupt_frame) %frame) {
13 ; CHECK-LABEL: test_isr_no_ecode:
15 ; CHECK: movl 12(%esp), %eax
18 ; CHECK0-LABEL: test_isr_no_ecode:
20 ; CHECK0: leal 4(%esp), %eax
21 ; CHECK0: movl 8(%eax), %eax
24 %pflags = getelementptr inbounds %struct.interrupt_frame, ptr %frame, i32 0, i32 2
25 %flags = load i32, ptr %pflags, align 4
26 call void asm sideeffect "", "r"(i32 %flags)
30 ; Spills eax and ecx, putting original esp at +8. Stack is adjusted up another 4 bytes
31 ; before return, popping the error code.
32 define x86_intrcc void @test_isr_ecode(ptr byval(%struct.interrupt_frame) %frame, i32 %ecode) {
33 ; CHECK-LABEL: test_isr_ecode
36 ; CHECK: movl 8(%esp), %eax
37 ; CHECK: movl 20(%esp), %ecx
40 ; CHECK: addl $4, %esp
42 ; CHECK0-LABEL: test_isr_ecode
45 ; CHECK0: movl 8(%esp), %ecx
46 ; CHECK0: leal 12(%esp), %eax
47 ; CHECK0: movl 8(%eax), %eax
50 ; CHECK0: addl $4, %esp
52 %pflags = getelementptr inbounds %struct.interrupt_frame, ptr %frame, i32 0, i32 2
53 %flags = load i32, ptr %pflags, align 4
54 call x86_fastcallcc void asm sideeffect "", "r,r"(i32 %flags, i32 %ecode)
58 ; All clobbered registers must be saved
59 define x86_intrcc void @test_isr_clobbers(ptr byval(%struct.interrupt_frame) %frame, i32 %ecode) {
60 call void asm sideeffect "", "~{eax},~{ebx},~{ebp}"()
61 ; CHECK-LABEL: test_isr_clobbers
68 ; CHECK: addl $4, %esp
70 ; CHECK0-LABEL: test_isr_clobbers
77 ; CHECK0: addl $4, %esp
82 @f80 = common global x86_fp80 0xK00000000000000000000, align 4
84 ; Test that the presence of x87 does not crash the FP stackifier
85 define x86_intrcc void @test_isr_x87(ptr byval(%struct.interrupt_frame) %frame) {
86 ; CHECK-LABEL: test_isr_x87
90 ; CHECK-NEXT: fstpt f80
93 %ld = load x86_fp80, ptr @f80, align 4
94 %add = fadd x86_fp80 %ld, 0xK3FFF8000000000000000
95 store x86_fp80 %add, ptr @f80, align 4
99 ; Use a frame pointer to check the offsets. No return address, arguments start
101 define dso_local x86_intrcc void @test_fp_1(ptr byval(%struct.interrupt_frame) %p) #0 {
102 ; CHECK-LABEL: test_fp_1:
103 ; CHECK: # %bb.0: # %entry
104 ; CHECK-NEXT: pushl %ebp
105 ; CHECK-NEXT: movl %esp, %ebp
107 ; CHECK-DAG: leal 4(%ebp), %[[R1:[^ ]*]]
108 ; CHECK-DAG: leal 20(%ebp), %[[R2:[^ ]*]]
109 ; CHECK: movl %[[R1]], sink_address
110 ; CHECK: movl %[[R2]], sink_address
114 %arrayidx2 = getelementptr inbounds %struct.interrupt_frame, ptr %p, i32 0, i32 4
115 store volatile ptr %p, ptr @sink_address
116 store volatile ptr %arrayidx2, ptr @sink_address
120 ; The error code is between EBP and the interrupt_frame.
121 define dso_local x86_intrcc void @test_fp_2(ptr byval(%struct.interrupt_frame) %p, i32 %err) #0 {
122 ; CHECK-LABEL: test_fp_2:
123 ; CHECK: # %bb.0: # %entry
124 ; CHECK-NEXT: pushl %ebp
125 ; CHECK-NEXT: movl %esp, %ebp
127 ; CHECK-DAG: movl 4(%ebp), %[[R3:[^ ]*]]
128 ; CHECK-DAG: leal 8(%ebp), %[[R1:[^ ]*]]
129 ; CHECK-DAG: leal 24(%ebp), %[[R2:[^ ]*]]
130 ; CHECK: movl %[[R1]], sink_address
131 ; CHECK: movl %[[R2]], sink_address
132 ; CHECK: movl %[[R3]], sink_i32
136 %arrayidx2 = getelementptr inbounds %struct.interrupt_frame, ptr %p, i32 0, i32 4
137 store volatile ptr %p, ptr @sink_address
138 store volatile ptr %arrayidx2, ptr @sink_address
139 store volatile i32 %err, ptr @sink_i32
143 ; Test argument copy elision when copied to a local alloca.
144 define x86_intrcc void @test_copy_elide(ptr byval(%struct.interrupt_frame) %frame, i32 %err) #0 {
145 ; CHECK-LABEL: test_copy_elide:
146 ; CHECK: # %bb.0: # %entry
147 ; CHECK-NEXT: pushl %ebp
148 ; CHECK-NEXT: movl %esp, %ebp
150 ; CHECK: leal 4(%ebp), %[[R1:[^ ]*]]
151 ; CHECK: movl %[[R1]], sink_address
153 %err.addr = alloca i32, align 4
154 store i32 %err, ptr %err.addr, align 4
155 store volatile ptr %err.addr, ptr @sink_address
159 attributes #0 = { nounwind "frame-pointer"="all" }