1 ; RUN: llc -mtriple=x86_64-w64-windows-gnu < %s | FileCheck %s --check-prefix=GNU
2 ; RUN: llc -mtriple=x86_64-w64-windows-gnu < %s -filetype=obj | llvm-objdump - --headers | FileCheck %s --check-prefix=GNUOBJ
4 ; When doing GCC style comdats for MinGW, the .xdata sections don't have a normal comdat
5 ; symbol attached, which requires a bit of adjustments for the assembler output.
7 ; Generated with this C++ source:
9 ; __declspec(selectany) int gv = 42;
10 ; inline int foo(int x) { try { return bar(x) + gv; } catch (...) { return 0; } }
11 ; int main() { return foo(1); }
17 @gv = weak_odr dso_local global i32 42, comdat, align 4
19 ; Function Attrs: norecurse uwtable
20 define dso_local i32 @main() #0 {
22 %call = tail call i32 @_Z3fooi(i32 1)
28 ; Function Attrs: inlinehint uwtable
29 define linkonce_odr dso_local i32 @_Z3fooi(i32 %x) #1 comdat personality ptr @__gxx_personality_seh0 {
31 %call = invoke i32 @_Z3bari(i32 %x)
32 to label %invoke.cont unwind label %lpad
34 invoke.cont: ; preds = %entry
35 %0 = load i32, ptr @gv, align 4
36 %add = add nsw i32 %0, %call
39 lpad: ; preds = %entry
40 %1 = landingpad { ptr, i32 }
42 %2 = extractvalue { ptr, i32 } %1, 0
43 %3 = tail call ptr @__cxa_begin_catch(ptr %2) #3
44 tail call void @__cxa_end_catch()
47 return: ; preds = %lpad, %invoke.cont
48 %retval.0 = phi i32 [ %add, %invoke.cont ], [ 0, %lpad ]
52 ; The .xdata section below doesn't have the usual comdat symbol attached, which requires
53 ; a different syntax for the assembly output.
55 ; GNU: .section .text$_Z3fooi,"xr",discard,_Z3fooi
57 ; GNU: .section .xdata$_Z3fooi,"dr"
58 ; GNU: .linkonce discard
59 ; GNU: GCC_except_table1:
60 ; GNU: .section .data$gv,"dw",discard,gv
64 ; Make sure the assembler puts the .xdata and .pdata in sections with the right
66 ; GNUOBJ: .text$_Z3fooi
67 ; GNUOBJ: .xdata$_Z3fooi
69 ; GNUOBJ: .pdata$_Z3fooi
71 declare dso_local i32 @_Z3bari(i32)
73 declare dso_local i32 @__gxx_personality_seh0(...)
75 declare dso_local ptr @__cxa_begin_catch(ptr) local_unnamed_addr
77 declare dso_local void @__cxa_end_catch() local_unnamed_addr
79 attributes #0 = { norecurse uwtable }
80 attributes #1 = { inlinehint uwtable }
81 attributes #3 = { nounwind }