1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
; RUN: llc < %s -mtriple=i686-linux -segmented-stacks -verify-machineinstrs | FileCheck %s -check-prefix=X32
; RUN: llc < %s -mtriple=x86_64-linux -segmented-stacks -verify-machineinstrs | FileCheck %s -check-prefix=X64
; We used to crash with filetype=obj
; RUN: llc < %s -mtriple=i686-linux -segmented-stacks -filetype=obj
; RUN: llc < %s -mtriple=x86_64-linux -segmented-stacks -filetype=obj
; Just to prevent the alloca from being optimized away
declare void @dummy_use(i32*, i32)
define void @test_basic() {
%mem = alloca i32, i32 10
call void @dummy_use (i32* %mem, i32 10)
ret void
; X32: test_basic:
; X32: cmpl %gs:48, %esp
; X32-NEXT: ja .LBB0_2
; X32: pushl $0
; X32-NEXT: pushl $60
; X32-NEXT: calll __morestack
; X32-NEXT: ret
; X64: test_basic:
; X64: cmpq %fs:112, %rsp
; X64-NEXT: ja .LBB0_2
; X64: movabsq $40, %r10
; X64-NEXT: movabsq $0, %r11
; X64-NEXT: callq __morestack
; X64-NEXT: ret
}
define i32 @test_nested(i32 * nest %closure, i32 %other) {
%addend = load i32 * %closure
%result = add i32 %other, %addend
ret i32 %result
; X32: cmpl %gs:48, %esp
; X32-NEXT: ja .LBB1_2
; X32: pushl $4
; X32-NEXT: pushl $0
; X32-NEXT: calll __morestack
; X32-NEXT: ret
; X64: cmpq %fs:112, %rsp
; X64-NEXT: ja .LBB1_2
; X64: movq %r10, %rax
; X64-NEXT: movabsq $0, %r10
; X64-NEXT: movabsq $0, %r11
; X64-NEXT: callq __morestack
; X64-NEXT: ret
; X64-NEXT: movq %rax, %r10
}
define void @test_large() {
%mem = alloca i32, i32 10000
call void @dummy_use (i32* %mem, i32 0)
ret void
; X32: leal -40012(%esp), %ecx
; X32-NEXT: cmpl %gs:48, %ecx
; X32-NEXT: ja .LBB2_2
; X32: pushl $0
; X32-NEXT: pushl $40012
; X32-NEXT: calll __morestack
; X32-NEXT: ret
; X64: leaq -40008(%rsp), %r11
; X64-NEXT: cmpq %fs:112, %r11
; X64-NEXT: ja .LBB2_2
; X64: movabsq $40008, %r10
; X64-NEXT: movabsq $0, %r11
; X64-NEXT: callq __morestack
; X64-NEXT: ret
}
define fastcc void @test_fastcc() {
%mem = alloca i32, i32 10
call void @dummy_use (i32* %mem, i32 10)
ret void
; X32: test_fastcc:
; X32: cmpl %gs:48, %esp
; X32-NEXT: ja .LBB3_2
; X32: pushl $0
; X32-NEXT: pushl $60
; X32-NEXT: calll __morestack
; X32-NEXT: ret
; X64: test_fastcc:
; X64: cmpq %fs:112, %rsp
; X64-NEXT: ja .LBB3_2
; X64: movabsq $40, %r10
; X64-NEXT: movabsq $0, %r11
; X64-NEXT: callq __morestack
; X64-NEXT: ret
}
define fastcc void @test_fastcc_large() {
%mem = alloca i32, i32 10000
call void @dummy_use (i32* %mem, i32 0)
ret void
; X32: test_fastcc_large:
; X32: leal -40012(%esp), %eax
; X32-NEXT: cmpl %gs:48, %eax
; X32-NEXT: ja .LBB4_2
; X32: pushl $0
; X32-NEXT: pushl $40012
; X32-NEXT: calll __morestack
; X32-NEXT: ret
; X64: test_fastcc_large:
; X64: leaq -40008(%rsp), %r11
; X64-NEXT: cmpq %fs:112, %r11
; X64-NEXT: ja .LBB4_2
; X64: movabsq $40008, %r10
; X64-NEXT: movabsq $0, %r11
; X64-NEXT: callq __morestack
; X64-NEXT: ret
}
|