Reid Kleckner | 987d331 | 2019-02-08 19:03:50 +0000 | [diff] [blame] | 1 | ; 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 | |
| 12 | declare 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 Song | e56626e | 2020-08-03 20:35:50 -0700 | [diff] [blame] | 18 | ; ELF: @__profc_foo_inline = linkonce_odr hidden global{{.*}}, section "__llvm_prf_cnts", comdat($__profd_foo_inline), align 8 |
Rong Xu | 3674050 | 2019-09-30 18:11:22 +0000 | [diff] [blame] | 19 | ; ELF: @__profd_foo_inline = linkonce_odr hidden global{{.*}}, section "__llvm_prf_data", comdat, align 8 |
Fangrui Song | b959906 | 2020-08-03 21:32:44 -0700 | [diff] [blame] | 20 | ; COFF: @__profc_foo_inline = linkonce_odr hidden global{{.*}}, section ".lprfc$M", comdat, align 8 |
Reid Kleckner | 23e872a | 2019-09-17 21:10:49 +0000 | [diff] [blame] | 21 | ; COFF: @__profd_foo_inline = linkonce_odr hidden global{{.*}}, section ".lprfd$M", comdat, align 8 |
Reid Kleckner | 987d331 | 2019-02-08 19:03:50 +0000 | [diff] [blame] | 22 | define 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 Song | e56626e | 2020-08-03 20:35:50 -0700 | [diff] [blame] | 31 | ; ELF: @__profc_foo_extern = linkonce_odr hidden global{{.*}}, section "__llvm_prf_cnts", comdat($__profd_foo_extern), align 8 |
Rong Xu | 3674050 | 2019-09-30 18:11:22 +0000 | [diff] [blame] | 32 | ; ELF: @__profd_foo_extern = linkonce_odr hidden global{{.*}}, section "__llvm_prf_data", comdat, align 8 |
Fangrui Song | b959906 | 2020-08-03 21:32:44 -0700 | [diff] [blame] | 33 | ; COFF: @__profc_foo_extern = linkonce_odr hidden global{{.*}}, section ".lprfc$M", comdat, align 8 |
Reid Kleckner | 23e872a | 2019-09-17 21:10:49 +0000 | [diff] [blame] | 34 | ; COFF: @__profd_foo_extern = linkonce_odr hidden global{{.*}}, section ".lprfd$M", comdat, align 8 |
Reid Kleckner | 987d331 | 2019-02-08 19:03:50 +0000 | [diff] [blame] | 35 | define 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 | } |