103 lines · plain
1; RUN: llc -function-sections -mtriple=x86_64-windows-itanium < %s | FileCheck %s2; RUN: llc -function-sections -mtriple=x86_64-windows-msvc < %s | FileCheck %s3; RUN: llc -function-sections -mtriple=x86_64-w64-windows-gnu < %s | FileCheck %s --check-prefix=GNU4; RUN: llc -function-sections -mtriple=x86_64-pc-cygwin < %s | FileCheck %s --check-prefix=GNU5; RUN: llc -function-sections -mtriple=i686-w64-windows-gnu < %s | FileCheck %s --check-prefix=GNU326; RUN: llc -function-sections -mtriple=i686-pc-cygwin < %s | FileCheck %s --check-prefix=GNU327; RUN: llc -function-sections -mtriple=x86_64-w64-windows-gnu < %s -filetype=obj | llvm-objdump - --headers | FileCheck %s --check-prefix=GNUOBJ8; RUN: llc -function-sections -mtriple=x86_64-pc-cygwin < %s -filetype=obj | llvm-objdump - --headers | FileCheck %s --check-prefix=GNUOBJ9 10; GCC and MSVC handle comdats completely differently. Make sure we do the right11; thing for each.12 13; Modeled on this C++ source, with additional modifications for14; -ffunction-sections:15; int bar(int);16; __declspec(selectany) int gv = 42;17; inline int foo(int x) { return bar(x) + gv; }18; int main() { return foo(1); }19 20$_Z3fooi = comdat any21 22$gv = comdat any23 24@gv = weak_odr dso_local global i32 42, comdat, align 425 26; Function Attrs: norecurse uwtable27define dso_local i32 @main() #0 {28entry:29 %call = tail call i32 @_Z3fooi(i32 1)30 ret i32 %call31}32 33; CHECK: .section .text,"xr",one_only,main,unique,034; CHECK: main:35; GNU: .section .text$main,"xr",one_only,main,unique,036; GNU: main:37; GNU32: .section .text$main,"xr",one_only,_main,unique,038; GNU32: _main:39 40define dso_local x86_fastcallcc i32 @fastcall(i32 %x, i32 %y) {41 %rv = add i32 %x, %y42 ret i32 %rv43}44 45; CHECK: .section .text,"xr",one_only,fastcall,unique,146; CHECK: fastcall:47; GNU: .section .text$fastcall,"xr",one_only,fastcall,unique,148; GNU: fastcall:49; GNU32: .section .text$fastcall,"xr",one_only,@fastcall@8,unique,150; GNU32: @fastcall@8:51 52; Function Attrs: inlinehint uwtable53define linkonce_odr dso_local i32 @_Z3fooi(i32 %x) #1 comdat {54entry:55 %call = tail call i32 @_Z3bari(i32 %x)56 %0 = load i32, ptr @gv, align 457 %add = add nsw i32 %0, %call58 ret i32 %add59}60 61; CHECK: .section .text,"xr",discard,_Z3fooi,unique,262; CHECK: _Z3fooi:63; CHECK: .section .data,"dw",discard,gv64; CHECK: gv:65; CHECK: .long 4266 67; GNU: .section .text$_Z3fooi,"xr",discard,_Z3fooi,unique,268; GNU: _Z3fooi:69; GNU: .section .data$gv,"dw",discard,gv70; GNU: gv:71; GNU: .long 4272 73; GNU32: .section .text$_Z3fooi,"xr",discard,__Z3fooi,unique,274; GNU32: __Z3fooi:75; GNU32: .section .data$gv,"dw",discard,_gv76; GNU32: _gv:77; GNU32: .long 4278 79 80define linkonce_odr dso_local i32 @_Z3fooj(i32 %x) !section_prefix !0 {81entry:82 %call = tail call i32 @_Z3bari(i32 %x)83 %0 = load i32, ptr @gv, align 484 %add = add nsw i32 %0, %call85 ret i32 %add86}87 88; Make sure the assembler puts the .xdata and .pdata in sections with the right89; names.90; GNUOBJ: .text$_Z3fooi91; GNUOBJ: .xdata$_Z3fooi92; GNUOBJ: .text$unlikely$_Z3fooj93; GNUOBJ: .xdata$unlikely$_Z3fooj94; GNUOBJ: .data$gv95; GNUOBJ: .pdata$_Z3fooi96; GNUOBJ: .pdata$unlikely$_Z3fooj97 98declare dso_local i32 @_Z3bari(i32)99 100attributes #0 = { norecurse uwtable }101attributes #1 = { inlinehint uwtable }102!0 = !{!"function_section_prefix", !"unlikely"}103