• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3
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.
6
7; Generated with this C++ source:
8; int bar(int);
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); }
12
13$_Z3fooi = comdat any
14
15$gv = comdat any
16
17@gv = weak_odr dso_local global i32 42, comdat, align 4
18
19; Function Attrs: norecurse uwtable
20define dso_local i32 @main() #0 {
21entry:
22  %call = tail call i32 @_Z3fooi(i32 1)
23  ret i32 %call
24}
25
26; GNU: main:
27
28; Function Attrs: inlinehint uwtable
29define linkonce_odr dso_local i32 @_Z3fooi(i32 %x) #1 comdat personality i8* bitcast (i32 (...)* @__gxx_personality_seh0 to i8*) {
30entry:
31  %call = invoke i32 @_Z3bari(i32 %x)
32          to label %invoke.cont unwind label %lpad
33
34invoke.cont:                                      ; preds = %entry
35  %0 = load i32, i32* @gv, align 4
36  %add = add nsw i32 %0, %call
37  br label %return
38
39lpad:                                             ; preds = %entry
40  %1 = landingpad { i8*, i32 }
41          catch i8* null
42  %2 = extractvalue { i8*, i32 } %1, 0
43  %3 = tail call i8* @__cxa_begin_catch(i8* %2) #3
44  tail call void @__cxa_end_catch()
45  br label %return
46
47return:                                           ; preds = %lpad, %invoke.cont
48  %retval.0 = phi i32 [ %add, %invoke.cont ], [ 0, %lpad ]
49  ret i32 %retval.0
50}
51
52; The .xdata section below doesn't have the usual comdat symbol attached, which requires
53; a different syntax for the assembly output.
54
55; GNU: .section        .text$_Z3fooi,"xr",discard,_Z3fooi
56; GNU: _Z3fooi:
57; GNU: .section        .xdata$_Z3fooi,"dr"
58; GNU: .linkonce       discard
59; GNU: GCC_except_table1:
60; GNU: .section        .data$gv,"dw",discard,gv
61; GNU: gv:
62; GNU: .long 42
63
64; Make sure the assembler puts the .xdata and .pdata in sections with the right
65; names.
66; GNUOBJ: .text$_Z3fooi
67; GNUOBJ: .xdata$_Z3fooi
68; GNUOBJ: .data$gv
69; GNUOBJ: .pdata$_Z3fooi
70
71declare dso_local i32 @_Z3bari(i32)
72
73declare dso_local i32 @__gxx_personality_seh0(...)
74
75declare dso_local i8* @__cxa_begin_catch(i8*) local_unnamed_addr
76
77declare dso_local void @__cxa_end_catch() local_unnamed_addr
78
79attributes #0 = { norecurse uwtable }
80attributes #1 = { inlinehint uwtable }
81attributes #3 = { nounwind }
82