brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.6 KiB · 0f33031 Raw
76 lines · plain
1; There are two main cases where comdats are necessary:2; 1. standard inline functions (weak_odr / linkonce_odr)3; 2. available externally functions (C99 inline / extern template / dllimport)4; Check that we do the right thing for the two object formats with comdats, ELF5; and COFF.6;7; Test comdat functions. Non-comdat functions are tested in linkage.ll.8; RUN: split-file %s %t9; RUN: cat %t/main.ll %t/disable.ll > %t0.ll10; RUN: cat %t/main.ll %t/enable.ll > %t1.ll11; RUN: opt < %t0.ll -mtriple=x86_64-linux -passes=instrprof -S | FileCheck %s --check-prefixes=ELF,ELF012; RUN: opt < %t1.ll -mtriple=x86_64-linux -passes=instrprof -S | FileCheck %s --check-prefixes=ELF,ELF113; RUN: opt < %t0.ll -mtriple=x86_64-windows -passes=instrprof -S | FileCheck %s --check-prefixes=COFF,COFF014; RUN: opt < %t1.ll -mtriple=x86_64-windows -passes=instrprof -S | FileCheck %s --check-prefixes=COFF,COFF115 16;--- main.ll17declare void @llvm.instrprof.increment(ptr, i64, i32, i32)18 19$foo_inline = comdat any20$foo_extern = comdat any21$foo_private_profn = comdat any22 23@__profn_foo_inline = linkonce_odr hidden constant [10 x i8] c"foo_inline"24@__profn_foo_extern = linkonce_odr hidden constant [10 x i8] c"foo_extern"25@__profn_foo_private_profn = private constant [17 x i8] c"foo_private_profn"26 27;; When value profiling is disabled, __profd_ variables are not referenced by28;; code. We can use private linkage. When enabled, __profd_ needs to be29;; non-local which requires separate comdat on COFF due to a link.exe limitation.30 31; ELF:   @__profc_foo_inline = linkonce_odr hidden global {{.*}}, section "__llvm_prf_cnts", comdat, align 832; ELF0:  @__profd_foo_inline = private global {{.*}}, section "__llvm_prf_data", comdat($__profc_foo_inline), align 833; ELF1:  @__profd_foo_inline = linkonce_odr hidden global {{.*}}, section "__llvm_prf_data", comdat($__profc_foo_inline), align 834; COFF0: @__profc_foo_inline = linkonce_odr hidden global {{.*}}, section ".lprfc$M", comdat, align 835; COFF0: @__profd_foo_inline = internal global {{.*}}, section ".lprfd$M", comdat($__profc_foo_inline), align 836; COFF1: @__profc_foo_inline = linkonce_odr hidden global {{.*}}, section ".lprfc$M", comdat, align 837; COFF1: @__profd_foo_inline = linkonce_odr hidden global {{.*}}, section ".lprfd$M", comdat, align 838define weak_odr void @foo_inline() comdat {39  call void @llvm.instrprof.increment(ptr @__profn_foo_inline, i64 0, i32 1, i32 0)40  ret void41}42 43; ELF:   @__profc_foo_extern = linkonce_odr hidden global{{.*}}, section "__llvm_prf_cnts", comdat, align 844; ELF0:  @__profd_foo_extern = private global{{.*}}, section "__llvm_prf_data", comdat($__profc_foo_extern), align 845; ELF1:  @__profd_foo_extern = linkonce_odr hidden global{{.*}}, section "__llvm_prf_data", comdat($__profc_foo_extern), align 846; COFF:  @__profc_foo_extern = linkonce_odr hidden global{{.*}}, section ".lprfc$M", comdat, align 847; COFF0: @__profd_foo_extern = internal global{{.*}}, section ".lprfd$M", comdat($__profc_foo_extern), align 848; COFF1: @__profd_foo_extern = linkonce_odr hidden global{{.*}}, section ".lprfd$M", comdat, align 849define available_externally void @foo_extern() {50  call void @llvm.instrprof.increment(ptr @__profn_foo_extern, i64 0, i32 1, i32 0)51  ret void52}53 54; ELF:   @__profc_foo_private_profn = private global{{.*}}, section "__llvm_prf_cnts", comdat, align 855; ELF0:  @__profd_foo_private_profn = private global{{.*}}, section "__llvm_prf_data", comdat($__profc_foo_private_profn), align 856; ELF1:  @__profd_foo_private_profn = private global{{.*}}, section "__llvm_prf_data", comdat($__profc_foo_private_profn), align 857; COFF:  @__profc_foo_private_profn = internal global{{.*}}, section ".lprfc$M", comdat, align 858; COFF0: @__profd_foo_private_profn = internal global{{.*}}, section ".lprfd$M", comdat($__profc_foo_private_profn), align 859; COFF1: @__profd_foo_private_profn = internal global{{.*}}, section ".lprfd$M", comdat, align 860define void @foo_private_profn() comdat {61  call void @llvm.instrprof.increment(ptr @__profn_foo_private_profn, i64 0, i32 1, i32 0)62  ret void63}64 65; ELF:   @llvm.compiler.used = appending global [3 x ptr] [ptr @__profd_foo_inline, ptr @__profd_foo_extern, ptr @__profd_foo_private_profn]66; COFF0: @llvm.compiler.used = appending global [4 x ptr] [ptr @__llvm_profile_runtime_user, ptr @__profd_foo_inline, ptr @__profd_foo_extern, ptr @__profd_foo_private_profn]67; COFF1: @llvm.used = appending global [5 x ptr] [ptr @__llvm_profile_runtime_user, ptr @__profd_foo_inline, ptr @__profd_foo_extern, ptr @__profd_foo_private_profn, ptr @__llvm_prf_nm]68 69;--- disable.ll70!llvm.module.flags = !{!0}71!0 = !{i32 2, !"EnableValueProfiling", i32 0}72 73;--- enable.ll74!llvm.module.flags = !{!0}75!0 = !{i32 2, !"EnableValueProfiling", i32 1}76