1; RUN: llc < %s -mtriple=x86_64 | FileCheck %s --check-prefixes=CHECK,NORMAL
2; RUN: llc < %s -mtriple=x86_64 -unique-section-names=false | FileCheck %s --check-prefixes=CHECK,NOUNIQUE
3; RUN: llc < %s -mtriple=x86_64 -function-sections | FileCheck %s --check-prefixes=CHECK,SEP
4; RUN: llc < %s -mtriple=x86_64 -function-sections -unique-section-names=false | FileCheck %s --check-prefixes=CHECK,SEP_NOUNIQUE
5
6;; Don't use `,unique` if GNU as<2.35.
7; RUN: llc < %s -mtriple=x86_64 -function-sections -unique-section-names=false -no-integrated-as | FileCheck %s --check-prefixes=CHECK,SEP_NOUNIQUE_GAS
8
9@_ZTIi = external constant i8*
10
11;; If the function is in a comdat group, the generated .gcc_except_table should
12;; be placed in the same group, so that .gcc_except_table can be discarded if
13;; the comdat is not prevailing. If -funique-section-names, append the function name.
14$group = comdat any
15define i32 @group() uwtable comdat personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
16; CHECK-LABEL:       group:
17; CHECK:             .cfi_endproc
18; NORMAL-NEXT:       .section .gcc_except_table.group,"aG",@progbits,group,comdat{{$}}
19; NOUNIQUE-NEXT:     .section .gcc_except_table,"aG",@progbits,group,comdat{{$}}
20; SEP-NEXT:          .section .gcc_except_table.group,"aG",@progbits,group,comdat{{$}}
21; SEP_NOUNIQUE-NEXT: .section .gcc_except_table,"aG",@progbits,group,comdat,unique,2
22; SEP_NOUNIQUE_GAS-NEXT: .section .gcc_except_table,"aG",@progbits,group,comdat{{$}}
23entry:
24  invoke void @ext() to label %try.cont unwind label %lpad
25lpad:
26  %0 = landingpad { i8*, i32 } catch i8* bitcast (i8** @_ZTIi to i8*)
27  br label %eh.resume
28try.cont:
29  ret i32 0
30eh.resume:
31  resume { i8*, i32 } %0
32}
33
34;; If the function is not in a comdat group, but function sections is enabled,
35;; use a separate section by either using a unique ID (integrated assembler) or
36;; a suffix (GNU as<2.35).
37define i32 @foo() uwtable personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
38; CHECK-LABEL:       foo:
39; CHECK:             .cfi_endproc
40; NORMAL-NEXT:       .section .gcc_except_table,"a",@progbits{{$}}
41; NOUNIQUE-NEXT:     .section .gcc_except_table,"a",@progbits{{$}}
42; SEP-NEXT:          .section .gcc_except_table.foo,"a",@progbits{{$}}
43; SEP_NOUNIQUE-NEXT: .section .gcc_except_table,"a",@progbits,unique,4
44; SEP_NOUNIQUE_GAS-NEXT: .section .gcc_except_table,"a",@progbits{{$}}
45entry:
46  invoke void @ext() to label %try.cont unwind label %lpad
47lpad:
48  %0 = landingpad { i8*, i32 } catch i8* bitcast (i8** @_ZTIi to i8*)
49  br label %eh.resume
50try.cont:
51  ret i32 0
52eh.resume:
53  resume { i8*, i32 } %0
54}
55
56declare void @ext()
57
58declare i32 @__gxx_personality_v0(...)
59