blob: 81c6db7f730d0137b60ddffdb6d1b78f7a99bfb1 [file] [log] [blame]
Reid Kleckner987d3312019-02-08 19:03:50 +00001; RUN: opt < %s -mtriple=x86_64-unknown-linux -instrprof -S | FileCheck %s --check-prefixes=ELF
2; RUN: opt < %s -mtriple=x86_64-pc-win32-coff -instrprof -S | FileCheck %s --check-prefixes=COFF
3; RUN: opt < %s -mtriple=x86_64-unknown-linux -passes=instrprof -S | FileCheck %s --check-prefixes=ELF
4; RUN: opt < %s -mtriple=x86_64-pc-win32-coff -passes=instrprof -S | FileCheck %s --check-prefixes=COFF
5
6; There are two main cases where comdats are necessary:
7; 1. standard inline functions (weak_odr / linkonce_odr)
8; 2. available externally functions (C99 inline / extern template / dllimport)
9; Check that we do the right thing for the two object formats with comdats, ELF
10; and COFF.
11
12declare void @llvm.instrprof.increment(i8*, i64, i32, i32)
13
14$foo_inline = comdat any
15
16@__profn_foo_inline = linkonce_odr hidden constant [10 x i8] c"foo_inline"
17
Fangrui Songe56626e2020-08-03 20:35:50 -070018; ELF: @__profc_foo_inline = linkonce_odr hidden global{{.*}}, section "__llvm_prf_cnts", comdat($__profd_foo_inline), align 8
Rong Xu36740502019-09-30 18:11:22 +000019; ELF: @__profd_foo_inline = linkonce_odr hidden global{{.*}}, section "__llvm_prf_data", comdat, align 8
Fangrui Songb9599062020-08-03 21:32:44 -070020; COFF: @__profc_foo_inline = linkonce_odr hidden global{{.*}}, section ".lprfc$M", comdat, align 8
Reid Kleckner23e872a2019-09-17 21:10:49 +000021; COFF: @__profd_foo_inline = linkonce_odr hidden global{{.*}}, section ".lprfd$M", comdat, align 8
Reid Kleckner987d3312019-02-08 19:03:50 +000022define weak_odr void @foo_inline() comdat {
23 call void @llvm.instrprof.increment(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @__profn_foo_inline, i32 0, i32 0), i64 0, i32 1, i32 0)
24 ret void
25}
26
27$foo_extern = comdat any
28
29@__profn_foo_extern = linkonce_odr hidden constant [10 x i8] c"foo_extern"
30
Fangrui Songe56626e2020-08-03 20:35:50 -070031; ELF: @__profc_foo_extern = linkonce_odr hidden global{{.*}}, section "__llvm_prf_cnts", comdat($__profd_foo_extern), align 8
Rong Xu36740502019-09-30 18:11:22 +000032; ELF: @__profd_foo_extern = linkonce_odr hidden global{{.*}}, section "__llvm_prf_data", comdat, align 8
Fangrui Songb9599062020-08-03 21:32:44 -070033; COFF: @__profc_foo_extern = linkonce_odr hidden global{{.*}}, section ".lprfc$M", comdat, align 8
Reid Kleckner23e872a2019-09-17 21:10:49 +000034; COFF: @__profd_foo_extern = linkonce_odr hidden global{{.*}}, section ".lprfd$M", comdat, align 8
Reid Kleckner987d3312019-02-08 19:03:50 +000035define available_externally void @foo_extern() {
36 call void @llvm.instrprof.increment(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @__profn_foo_extern, i32 0, i32 0), i64 0, i32 1, i32 0)
37 ret void
38}