1 ; RUN: llc -basic-block-sections=all -mtriple x86_64-pc-linux-gnu -code-model=small < %s | FileCheck %s --check-prefixes=CHECK,CHECK-SMALL,CHECK-NON-PIC,CHECK-NON-PIC-SMALL,CHECK-NON-PIC-X64
2 ; RUN: llc -basic-block-sections=all -mtriple x86_64-pc-linux-gnux32 -code-model=small < %s | FileCheck %s --check-prefixes=CHECK,CHECK-SMALL,CHECK-NON-PIC,CHECK-NON-PIC-SMALL,CHECK-NON-PIC-X32
3 ; RUN: llc -basic-block-sections=all -mtriple x86_64-pc-linux-gnu -code-model=medium < %s | FileCheck %s --check-prefixes=CHECK,CHECK-MEDIUM,CHECK-NON-PIC,CHECK-NON-PIC-MEDIUM,CHECK-NON-PIC-X64
4 ; RUN: llc -basic-block-sections=all -mtriple x86_64-pc-linux-gnu -code-model=large < %s | FileCheck %s --check-prefixes=CHECK,CHECK-NON-PIC,CHECK-NON-PIC-LARGE,CHECK-NON-PIC-X64
5 ; RUN: llc -basic-block-sections=all -mtriple x86_64-pc-linux-gnu -relocation-model=pic -code-model=small < %s | FileCheck %s --check-prefixes=CHECK,CHECK-SMALL,CHECK-PIC,CHECK-PIC-SMALL,CHECK-PIC-X64
6 ; RUN: llc -basic-block-sections=all -mtriple x86_64-pc-linux-gnux32 -relocation-model=pic -code-model=small < %s | FileCheck %s --check-prefixes=CHECK,CHECK-SMALL,CHECK-PIC,CHECK-PIC-SMALL,CHECK-PIC-X32
7 ; RUN: llc -basic-block-sections=all -mtriple x86_64-pc-linux-gnu -relocation-model=pic -code-model=medium < %s | FileCheck %s --check-prefixes=CHECK,CHECK-MEDIUM,CHECK-PIC,CHECK-PIC-MEDIUM,CHECK-PIC-X64
8 ; RUN: llc -basic-block-sections=all -mtriple x86_64-pc-linux-gnu -relocation-model=pic -code-model=large < %s | FileCheck %s --check-prefixes=CHECK,CHECK-PIC,CHECK-PIC-LARGE,CHECK-PIC-X64
9 @_ZTIi = external constant ptr
11 define i32 @main() uwtable optsize ssp personality ptr @__gxx_personality_v0 {
12 ; Verify that each basic block section gets its own LSDA exception symbol.
15 ; CHECK-NEXT: .Lfunc_begin0:
16 ; CHECK-NEXT: .cfi_startproc
18 ;; Verify personality function and LSDA encoding for NON-PIC mode.
19 ; PersonalityEncoding = dwarf::DW_EH_PE_udata4 (small/medium)
20 ; PersonalityEncoding = dwarf::DW_EH_PE_absptr (large)
21 ; CHECK-NON-PIC-SMALL-NEXT: .cfi_personality 3, __gxx_personality_v0
22 ; CHECK-NON-PIC-MEDIUM-NEXT: .cfi_personality 3, __gxx_personality_v0
23 ; CHECK-NON-PIC-LARGE-NEXT: .cfi_personality 0, __gxx_personality_v0
24 ; LSDAEncoding = dwarf::DW_EH_PE_udata4 (small)
25 ; LSDAEncoding = dwarf::DW_EH_PE_absptr (medium/large)
26 ; CHECK-NON-PIC-SMALL-NEXT: .cfi_lsda 3, .Lexception0
27 ; CHECK-NON-PIC-MEDIUM-NEXT: .cfi_lsda 0, .Lexception0
28 ; CHECK-NON-PIC-LARGE-NEXT: .cfi_lsda 0, .Lexception0
30 ;; Verify personality function and LSDA encoding for PIC mode.
31 ; PersonalityEncoding = DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4 (small/medium)
32 ; PersonalityEncoding = DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata8 (large)
33 ; CHECK-PIC-SMALL-NEXT: .cfi_personality 155, DW.ref.__gxx_personality_v0
34 ; CHECK-PIC-MEDIUM-NEXT: .cfi_personality 155, DW.ref.__gxx_personality_v0
35 ; CHECK-PIC-LARGE-NEXT: .cfi_personality 156, DW.ref.__gxx_personality_v0
36 ; LSDAEncoding = DW_EH_PE_pcrel | DW_EH_PE_sdata4 (small)
37 ; LSDAEncoding = DW_EH_PE_pcrel | DW_EH_PE_sdata8 (medium/large)
38 ; CHECK-PIC-SMALL-NEXT: .cfi_lsda 27, .Lexception0
39 ; CHECK-PIC-MEDIUM-NEXT: .cfi_lsda 28, .Lexception0
40 ; CHECK-PIC-LARGE-NEXT: .cfi_lsda 28, .Lexception0
42 ; CHECK-LABEL: .Ltmp0:
43 ; CHECK-SMALL-NEXT: callq _Z1fv
44 ; CHECK-MEDIUM-NEXT: callq _Z1fv
45 ; CHECK-NON-PIC-LARGE-NEXT: movabsq $_Z1fv, %rax
46 ; CHECK-NON-PIC-LARGE-NEXT: callq *%rax
47 ; CHECK-PIC-LARGE-NEXT: movabsq $_Z1fv@GOT, %rax
48 ; CHECK-PIC-LARGE-NEXT: callq *(%rbx,%rax)
49 ; CHECK-LABEL: .Ltmp1:
51 ; CHECK-NOT: .cfi_lsda
53 ; CHECK-LABEL: main.__part.1:
54 ; CHECK-NEXT: .cfi_startproc
56 ; CHECK-NON-PIC-SMALL-NEXT: .cfi_personality 3, __gxx_personality_v0
57 ; CHECK-NON-PIC-MEDIUM-NEXT: .cfi_personality 3, __gxx_personality_v0
58 ; CHECK-NON-PIC-LARGE-NEXT: .cfi_personality 0, __gxx_personality_v0
59 ; CHECK-NON-PIC-SMALL-NEXT: .cfi_lsda 3, .Lexception1
60 ; CHECK-NON-PIC-MEDIUM-NEXT: .cfi_lsda 0, .Lexception1
61 ; CHECK-NON-PIC-LARGE-NEXT: .cfi_lsda 0, .Lexception1
63 ; CHECK-PIC-SMALL-NEXT: .cfi_personality 155, DW.ref.__gxx_personality_v0
64 ; CHECK-PIC-MEDIUM-NEXT: .cfi_personality 155, DW.ref.__gxx_personality_v0
65 ; CHECK-PIC-LARGE-NEXT: .cfi_personality 156, DW.ref.__gxx_personality_v0
66 ; CHECK-PIC-SMALL-NEXT: .cfi_lsda 27, .Lexception1
67 ; CHECK-PIC-MEDIUM-NEXT: .cfi_lsda 28, .Lexception1
68 ; CHECK-PIC-LARGE-NEXT: .cfi_lsda 28, .Lexception1
70 ; CHECK-NOT: .cfi_lsda
72 ; CHECK-LABEL: main.__part.2:
73 ; CHECK-NEXT: .cfi_startproc
75 ; CHECK-NON-PIC-SMALL-NEXT: .cfi_personality 3, __gxx_personality_v0
76 ; CHECK-NON-PIC-MEDIUM-NEXT: .cfi_personality 3, __gxx_personality_v0
77 ; CHECK-NON-PIC-LARGE-NEXT: .cfi_personality 0, __gxx_personality_v0
78 ; CHECK-NON-PIC-SMALL-NEXT: .cfi_lsda 3, .Lexception2
79 ; CHECK-NON-PIC-MEDIUM-NEXT: .cfi_lsda 0, .Lexception2
80 ; CHECK-NON-PIC-LARGE-NEXT: .cfi_lsda 0, .Lexception2
82 ; CHECK-PIC-SMALL-NEXT: .cfi_personality 155, DW.ref.__gxx_personality_v0
83 ; CHECK-PIC-MEDIUM-NEXT: .cfi_personality 155, DW.ref.__gxx_personality_v0
84 ; CHECK-PIC-LARGE-NEXT: .cfi_personality 156, DW.ref.__gxx_personality_v0
85 ; CHECK-PIC-SMALL-NEXT: .cfi_lsda 27, .Lexception2
86 ; CHECK-PIC-MEDIUM-NEXT: .cfi_lsda 28, .Lexception2
87 ; CHECK-PIC-LARGE-NEXT: .cfi_lsda 28, .Lexception2
90 ; CHECK-LABEL: .Ltmp2:
91 ; CHECK-LABEL: .LBB_END0_2:
93 ; CHECK-NOT: .cfi_lsda
96 invoke void @_Z1fv() optsize
97 to label %try.cont unwind label %lpad
100 %0 = landingpad { ptr, i32 }
109 resume { ptr, i32 } %0
112 declare void @_Z1fv() optsize
114 declare i32 @__gxx_personality_v0(...)
115 ;; Verify that the exception table gets split across the three basic block sections.
117 ; CHECK: .section .gcc_except_table
118 ; CHECK-NEXT: .p2align 2
119 ; CHECK-NEXT: GCC_except_table0:
120 ; CHECK-NEXT: .Lexception0:
122 ;; Verify @LPStart encoding for NON-PIC mode.
123 ; CHECK-NON-PIC-NEXT: .byte 0 # @LPStart Encoding = absptr
124 ; CHECK-NON-PIC-X64-NEXT: .quad main.__part.2
125 ; CHECK-NON-PIC-X32-NEXT: .long main.__part.2
127 ;; Verify @LPStart encoding for PIC mode.
128 ; CHECK-PIC-NEXT: .byte 16 # @LPStart Encoding = pcrel
129 ; CHECK-PIC-NEXT: [[DOT:\.Ltmp[0-9]+]]:
130 ; CHECK-PIC-X64-NEXT: .quad main.__part.2-[[DOT]]
131 ; CHECK-PIC-X32-NEXT: .long main.__part.2-[[DOT]]
133 ;; Verify @TType encoding for NON-PIC mode.
134 ; CHECK-NON-PIC-SMALL-NEXT: .byte 3 # @TType Encoding = udata4
135 ; CHECK-NON-PIC-MEDIUM-NEXT: .byte 0 # @TType Encoding = absptr
136 ; CHECK-NON-PIC-LARGE-NEXT: .byte 0 # @TType Encoding = absptr
138 ;; Verify @TType encoding for PIC mode.
139 ; CHECK-PIC-SMALL-NEXT: .byte 155 # @TType Encoding = indirect pcrel sdata4
140 ; CHECK-PIC-MEDIUM-NEXT:.byte 155 # @TType Encoding = indirect pcrel sdata4
141 ; CHECK-PIC-LARGE-NEXT: .byte 156 # @TType Encoding = indirect pcrel sdata8
143 ; CHECK-NEXT: .uleb128 .Lttbase0-.Lttbaseref0
144 ; CHECK-NEXT: .Lttbaseref0:
145 ; CHECK-NEXT: .byte 1 # Call site Encoding = uleb128
146 ; CHECK-NEXT: .uleb128 .Laction_table_base0-.Lcst_begin0
147 ; CHECK-NEXT: .Lcst_begin0:
148 ; CHECK-NEXT: .uleb128 .Ltmp0-.Lfunc_begin0 # >> Call Site 1 <<
149 ; CHECK-NEXT: .uleb128 .Ltmp1-.Ltmp0 # Call between .Ltmp0 and .Ltmp1
150 ; CHECK-NEXT: .uleb128 .Ltmp2-main.__part.2 # jumps to .Ltmp2
151 ; CHECK-NEXT: .byte 3 # On action: 2
152 ; CHECK-NEXT: .p2align 2
153 ; CHECK-NEXT: .Lexception1:
155 ; CHECK-NON-PIC-NEXT: .byte 0 # @LPStart Encoding = absptr
156 ; CHECK-NON-PIC-X64-NEXT: .quad main.__part.2
157 ; CHECK-NON-PIC-X32-NEXT: .long main.__part.2
159 ; CHECK-PIC-NEXT: .byte 16 # @LPStart Encoding = pcrel
160 ; CHECK-PIC-NEXT: [[DOT:\.Ltmp[0-9]+]]:
161 ; CHECK-PIC-X64-NEXT: .quad main.__part.2-[[DOT]]
162 ; CHECK-PIC-X32-NEXT: .long main.__part.2-[[DOT]]
164 ; CHECK-NON-PIC-SMALL-NEXT: .byte 3 # @TType Encoding = udata4
165 ; CHECK-NON-PIC-MEDIUM-NEXT: .byte 0 # @TType Encoding = absptr
166 ; CHECK-NON-PIC-LARGE-NEXT: .byte 0 # @TType Encoding = absptr
168 ; CHECK-PIC-SMALL-NEXT: .byte 155 # @TType Encoding = indirect pcrel sdata4
169 ; CHECK-PIC-MEDIUM-NEXT:.byte 155 # @TType Encoding = indirect pcrel sdata4
170 ; CHECK-PIC-LARGE-NEXT: .byte 156 # @TType Encoding = indirect pcrel sdata8
172 ; CHECK-NEXT: .uleb128 .Lttbase0-.Lttbaseref1
173 ; CHECK-NEXT: .Lttbaseref1:
174 ; CHECK-NEXT: .byte 1 # Call site Encoding = uleb128
175 ; CHECK-NEXT: .uleb128 .Laction_table_base0-.Lcst_begin1
176 ; CHECK-NEXT: .Lcst_begin1:
177 ; CHECK-NEXT: .p2align 2
178 ; CHECK-NEXT: .Lexception2:
180 ; CHECK-NON-PIC-NEXT: .byte 0 # @LPStart Encoding = absptr
181 ; CHECK-NON-PIC-X64-NEXT: .quad main.__part.2
182 ; CHECK-NON-PIC-X32-NEXT: .long main.__part.2
184 ; CHECK-PIC-NEXT: .byte 16 # @LPStart Encoding = pcrel
185 ; CHECK-PIC-NEXT: [[DOT:\.Ltmp[0-9]+]]:
186 ; CHECK-PIC-X64-NEXT: .quad main.__part.2-[[DOT]]
187 ; CHECK-PIC-X32-NEXT: .long main.__part.2-[[DOT]]
189 ; CHECK-NON-PIC-SMALL-NEXT: .byte 3 # @TType Encoding = udata4
190 ; CHECK-NON-PIC-MEDIUM-NEXT: .byte 0 # @TType Encoding = absptr
191 ; CHECK-NON-PIC-LARGE-NEXT: .byte 0 # @TType Encoding = absptr
193 ; CHECK-PIC-SMALL-NEXT: .byte 155 # @TType Encoding = indirect pcrel sdata4
194 ; CHECK-PIC-MEDIUM-NEXT: .byte 155 # @TType Encoding = indirect pcrel sdata4
195 ; CHECK-PIC-LARGE-NEXT: .byte 156 # @TType Encoding = indirect pcrel sdata8
197 ; CHECK-NEXT: .uleb128 .Lttbase0-.Lttbaseref2
198 ; CHECK-NEXT: .Lttbaseref2:
199 ; CHECK-NEXT: .byte 1 # Call site Encoding = uleb128
200 ; CHECK-NEXT: .uleb128 .Laction_table_base0-.Lcst_begin2
201 ; CHECK-NEXT: .Lcst_begin2:
202 ; CHECK-NEXT: .uleb128 main.__part.2-main.__part.2 # >> Call Site 2 <<
203 ; CHECK-NEXT: .uleb128 .LBB_END0_2-main.__part.2 # Call between main.__part.2 and .LBB_END0_2
204 ; CHECK-NEXT: .byte 0 # has no landing pad
205 ; CHECK-NEXT: .byte 0 # On action: cleanup
206 ; CHECK-NEXT: .Laction_table_base0:
207 ; CHECK-NEXT: .byte 0 # >> Action Record 1 <<
208 ; CHECK-NEXT: # Cleanup
209 ; CHECK-NEXT: .byte 0 # No further actions
210 ; CHECK-NEXT: .byte 1 # >> Action Record 2 <<
211 ; CHECK-NEXT: # Catch TypeInfo 1
212 ; CHECK-NEXT: .byte 125 # Continue to action 1
213 ; CHECK-NEXT: .p2align 2
214 ; CHECK-NEXT: # >> Catch TypeInfos <<
216 ; CHECK-NON-PIC-SMALL-NEXT: .long _ZTIi # TypeInfo 1
217 ; CHECK-NON-PIC-MEDIUM-NEXT: .quad _ZTIi # TypeInfo 1
218 ; CHECK-NON-PIC-LARGE-NEXT: .quad _ZTIi # TypeInfo 1
220 ; CHECK-PIC-NEXT: [[DOT:\.Ltmp[0-9]+]]:
221 ; CHECK-PIC-SMALL-NEXT: .long .L_ZTIi.DW.stub-[[DOT]]
222 ; CHECK-PIC-MEDIUM-NEXT: .long .L_ZTIi.DW.stub-[[DOT]]
223 ; CHECK-PIC-LARGE-NEXT: .quad .L_ZTIi.DW.stub-[[DOT]]
225 ; CHECK-NEXT: .Lttbase0:
226 ; CHECK-NEXT: .p2align 2
227 ; CHECK-NEXT: # -- End function