• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -function-sections -mtriple=x86_64-windows-itanium < %s | FileCheck %s
2; RUN: llc -function-sections -mtriple=x86_64-windows-msvc < %s | FileCheck %s
3; RUN: llc -function-sections -mtriple=x86_64-w64-windows-gnu < %s | FileCheck %s --check-prefix=GNU
4; RUN: llc -function-sections -mtriple=i686-w64-windows-gnu < %s | FileCheck %s --check-prefix=GNU32
5; RUN: llc -function-sections -mtriple=x86_64-w64-windows-gnu < %s -filetype=obj | llvm-objdump - --headers | FileCheck %s --check-prefix=GNUOBJ
6
7; GCC and MSVC handle comdats completely differently. Make sure we do the right
8; thing for each.
9
10; Modeled on this C++ source, with additional modifications for
11; -ffunction-sections:
12; int bar(int);
13; __declspec(selectany) int gv = 42;
14; inline int foo(int x) { return bar(x) + gv; }
15; int main() { return foo(1); }
16
17$_Z3fooi = comdat any
18
19$gv = comdat any
20
21@gv = weak_odr dso_local global i32 42, comdat, align 4
22
23; Function Attrs: norecurse uwtable
24define dso_local i32 @main() #0 {
25entry:
26  %call = tail call i32 @_Z3fooi(i32 1)
27  ret i32 %call
28}
29
30; CHECK: .section        .text,"xr",one_only,main
31; CHECK: main:
32; GNU: .section        .text$main,"xr",one_only,main
33; GNU: main:
34; GNU32: .section        .text$main,"xr",one_only,_main
35; GNU32: _main:
36
37define dso_local x86_fastcallcc i32 @fastcall(i32 %x, i32 %y) {
38  %rv = add i32 %x, %y
39  ret i32 %rv
40}
41
42; CHECK: .section        .text,"xr",one_only,fastcall
43; CHECK: fastcall:
44; GNU: .section        .text$fastcall,"xr",one_only,fastcall
45; GNU: fastcall:
46; GNU32: .section        .text$fastcall,"xr",one_only,@fastcall@8
47; GNU32: @fastcall@8:
48
49; Function Attrs: inlinehint uwtable
50define linkonce_odr dso_local i32 @_Z3fooi(i32 %x) #1 comdat {
51entry:
52  %call = tail call i32 @_Z3bari(i32 %x)
53  %0 = load i32, i32* @gv, align 4
54  %add = add nsw i32 %0, %call
55  ret i32 %add
56}
57
58; CHECK: .section        .text,"xr",discard,_Z3fooi
59; CHECK: _Z3fooi:
60; CHECK: .section        .data,"dw",discard,gv
61; CHECK: gv:
62; CHECK: .long 42
63
64; GNU: .section        .text$_Z3fooi,"xr",discard,_Z3fooi
65; GNU: _Z3fooi:
66; GNU: .section        .data$gv,"dw",discard,gv
67; GNU: gv:
68; GNU: .long 42
69
70; GNU32: .section        .text$_Z3fooi,"xr",discard,__Z3fooi
71; GNU32: __Z3fooi:
72; GNU32: .section        .data$gv,"dw",discard,_gv
73; GNU32: _gv:
74; GNU32: .long 42
75
76
77define linkonce_odr dso_local i32 @_Z3fooj(i32 %x) !section_prefix !0 {
78entry:
79  %call = tail call i32 @_Z3bari(i32 %x)
80  %0 = load i32, i32* @gv, align 4
81  %add = add nsw i32 %0, %call
82  ret i32 %add
83}
84
85; Make sure the assembler puts the .xdata and .pdata in sections with the right
86; names.
87; GNUOBJ: .text$_Z3fooi
88; GNUOBJ: .xdata$_Z3fooi
89; GNUOBJ: .text$unlikely$_Z3fooj
90; GNUOBJ: .xdata$unlikely$_Z3fooj
91; GNUOBJ: .data$gv
92; GNUOBJ: .pdata$_Z3fooi
93; GNUOBJ: .pdata$unlikely$_Z3fooj
94
95declare dso_local i32 @_Z3bari(i32)
96
97attributes #0 = { norecurse uwtable }
98attributes #1 = { inlinehint uwtable }
99!0 = !{!"function_section_prefix", !"unlikely"}
100