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 i32* 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(%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, %struct.interrupt_frame* %frame, i32 0, i32 2
25 %flags = load i32, i32* %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(%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), %eax
46 ; CHECK0: leal 12(%esp), %ecx
47 ; CHECK0: movl 8(%ecx), %ecx
50 ; CHECK0: addl $4, %esp
52 %pflags = getelementptr inbounds %struct.interrupt_frame, %struct.interrupt_frame* %frame, i32 0, i32 2
53 %flags = load i32, i32* %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(%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(%struct.interrupt_frame* %frame) {
86 ; CHECK-LABEL: test_isr_x87
90 ; CHECK-NEXT: fstpt f80
93 %ld = load x86_fp80, x86_fp80* @f80, align 4
94 %add = fadd x86_fp80 %ld, 0xK3FFF8000000000000000
95 store x86_fp80 %add, x86_fp80* @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(%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 %arrayidx = getelementptr inbounds %struct.interrupt_frame, %struct.interrupt_frame* %p, i32 0, i32 0
115 %arrayidx2 = getelementptr inbounds %struct.interrupt_frame, %struct.interrupt_frame* %p, i32 0, i32 4
116 store volatile i32* %arrayidx, i32** @sink_address
117 store volatile i32* %arrayidx2, i32** @sink_address
121 ; The error code is between EBP and the interrupt_frame.
122 define dso_local x86_intrcc void @test_fp_2(%struct.interrupt_frame* %p, i32 %err) #0 {
123 ; CHECK-LABEL: test_fp_2:
124 ; CHECK: # %bb.0: # %entry
125 ; CHECK-NEXT: pushl %ebp
126 ; CHECK-NEXT: movl %esp, %ebp
128 ; CHECK-DAG: movl 4(%ebp), %[[R3:[^ ]*]]
129 ; CHECK-DAG: leal 8(%ebp), %[[R1:[^ ]*]]
130 ; CHECK-DAG: leal 24(%ebp), %[[R2:[^ ]*]]
131 ; CHECK: movl %[[R1]], sink_address
132 ; CHECK: movl %[[R2]], sink_address
133 ; CHECK: movl %[[R3]], sink_i32
137 %arrayidx = getelementptr inbounds %struct.interrupt_frame, %struct.interrupt_frame* %p, i32 0, i32 0
138 %arrayidx2 = getelementptr inbounds %struct.interrupt_frame, %struct.interrupt_frame* %p, i32 0, i32 4
139 store volatile i32* %arrayidx, i32** @sink_address
140 store volatile i32* %arrayidx2, i32** @sink_address
141 store volatile i32 %err, i32* @sink_i32
145 ; Test argument copy elision when copied to a local alloca.
146 define x86_intrcc void @test_copy_elide(%struct.interrupt_frame* %frame, i32 %err) #0 {
147 ; CHECK-LABEL: test_copy_elide:
148 ; CHECK: # %bb.0: # %entry
149 ; CHECK-NEXT: pushl %ebp
150 ; CHECK-NEXT: movl %esp, %ebp
152 ; CHECK: leal 4(%ebp), %[[R1:[^ ]*]]
153 ; CHECK: movl %[[R1]], sink_address
155 %err.addr = alloca i32, align 4
156 store i32 %err, i32* %err.addr, align 4
157 store volatile i32* %err.addr, i32** @sink_address
161 attributes #0 = { nounwind "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" }