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
7 ; GCC and MSVC handle comdats completely differently. Make sure we do the right
10 ; Modeled on this C++ source, with additional modifications for
11 ; -ffunction-sections:
13 ; __declspec(selectany) int gv = 42;
14 ; inline int foo(int x) { return bar(x) + gv; }
15 ; int main() { return foo(1); }
21 @gv = weak_odr dso_local global i32 42, comdat, align 4
23 ; Function Attrs: norecurse uwtable
24 define dso_local i32 @main() #0 {
26 %call = tail call i32 @_Z3fooi(i32 1)
30 ; CHECK: .section .text,"xr",one_only,main
32 ; GNU: .section .text$main,"xr",one_only,main
34 ; GNU32: .section .text$main,"xr",one_only,_main
37 define dso_local x86_fastcallcc i32 @fastcall(i32 %x, i32 %y) {
42 ; CHECK: .section .text,"xr",one_only,fastcall
44 ; GNU: .section .text$fastcall,"xr",one_only,fastcall
46 ; GNU32: .section .text$fastcall,"xr",one_only,@fastcall@8
49 ; Function Attrs: inlinehint uwtable
50 define linkonce_odr dso_local i32 @_Z3fooi(i32 %x) #1 comdat {
52 %call = tail call i32 @_Z3bari(i32 %x)
53 %0 = load i32, ptr @gv, align 4
54 %add = add nsw i32 %0, %call
58 ; CHECK: .section .text,"xr",discard,_Z3fooi
60 ; CHECK: .section .data,"dw",discard,gv
64 ; GNU: .section .text$_Z3fooi,"xr",discard,_Z3fooi
66 ; GNU: .section .data$gv,"dw",discard,gv
70 ; GNU32: .section .text$_Z3fooi,"xr",discard,__Z3fooi
72 ; GNU32: .section .data$gv,"dw",discard,_gv
77 define linkonce_odr dso_local i32 @_Z3fooj(i32 %x) !section_prefix !0 {
79 %call = tail call i32 @_Z3bari(i32 %x)
80 %0 = load i32, ptr @gv, align 4
81 %add = add nsw i32 %0, %call
85 ; Make sure the assembler puts the .xdata and .pdata in sections with the right
87 ; GNUOBJ: .text$_Z3fooi
88 ; GNUOBJ: .xdata$_Z3fooi
89 ; GNUOBJ: .text$unlikely$_Z3fooj
90 ; GNUOBJ: .xdata$unlikely$_Z3fooj
92 ; GNUOBJ: .pdata$_Z3fooi
93 ; GNUOBJ: .pdata$unlikely$_Z3fooj
95 declare dso_local i32 @_Z3bari(i32)
97 attributes #0 = { norecurse uwtable }
98 attributes #1 = { inlinehint uwtable }
99 !0 = !{!"function_section_prefix", !"unlikely"}