2015-12-22 06:26:49 +08:00
|
|
|
;; Check that PGO instrumented variables associated with linkonce odr
|
|
|
|
;; functions are placed in the same comdat section.
|
2015-05-28 03:34:01 +08:00
|
|
|
|
2015-12-22 05:52:27 +08:00
|
|
|
|
2015-05-28 03:34:01 +08:00
|
|
|
; RUN: opt < %s -mtriple=x86_64-apple-macosx10.10.0 -instrprof -S | FileCheck %s
|
2016-05-11 07:37:19 +08:00
|
|
|
; RUN: opt < %s -mtriple=x86_64-apple-macosx10.10.0 -passes=instrprof -S | FileCheck %s
|
2015-05-28 03:34:01 +08:00
|
|
|
; RUN: opt < %s -mtriple=x86_64-unknown-linux -instrprof -S | FileCheck %s
|
2016-04-19 01:47:38 +08:00
|
|
|
; RUN: opt < %s -mtriple=x86_64-unknown-linux -passes=instrprof -S | FileCheck %s
|
2015-12-22 09:18:49 +08:00
|
|
|
; RUN: opt < %s -mtriple=x86_64-pc-win32-coff -instrprof -S | FileCheck %s --check-prefix=COFF
|
2016-05-11 07:37:19 +08:00
|
|
|
; RUN: opt < %s -mtriple=x86_64-pc-win32-coff -passes=instrprof -S | FileCheck %s --check-prefix=COFF
|
2015-05-28 03:34:01 +08:00
|
|
|
|
|
|
|
$_Z3barIvEvv = comdat any
|
|
|
|
|
2015-12-15 08:32:56 +08:00
|
|
|
@__profn__Z3barIvEvv = linkonce_odr hidden constant [11 x i8] c"_Z3barIvEvv", align 1
|
2015-05-28 03:34:01 +08:00
|
|
|
|
2017-02-15 04:03:48 +08:00
|
|
|
; CHECK-NOT: __profn__Z3barIvEvv
|
2019-10-01 02:11:22 +08:00
|
|
|
; CHECK: @__profc__Z3barIvEvv = linkonce_odr hidden global [1 x i64] zeroinitializer, section "{{.*}}__llvm_prf_cnts", comdat, align 8
|
|
|
|
; CHECK: @__profd__Z3barIvEvv = linkonce_odr hidden global { i64, i64, i64*, i8*, i8*, i32, [2 x i16] } { i64 4947693190065689389, i64 0, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc__Z3barIvEvv, i32 0, i32 0), i8*{{.*}}, i8* null, i32 1, [2 x i16] zeroinitializer }, section "{{.*}}__llvm_prf_data{{.*}}", comdat, align 8
|
2016-02-09 02:13:49 +08:00
|
|
|
; CHECK: @__llvm_prf_nm = private constant [{{.*}} x i8] c"{{.*}}", section "{{.*}}__llvm_prf_names"
|
2015-05-28 03:34:01 +08:00
|
|
|
|
2016-02-09 02:13:49 +08:00
|
|
|
|
2017-02-15 04:03:48 +08:00
|
|
|
; COFF-NOT: __profn__Z3barIvEvv
|
[PGO] Use linkonce_odr linkage for __profd_ variables in comdat groups
This fixes relocations against __profd_ symbols in discarded sections,
which is PR41380.
In general, instrumentation happens very early, and optimization and
inlining happens afterwards. The counters for a function are calculated
early, and after inlining, counters for an inlined function may be
widely referenced by other functions.
For C++ inline functions of all kinds (linkonce_odr &
available_externally mainly), instr profiling wants to deduplicate these
__profc_ and __profd_ globals. Otherwise the binary would be quite
large.
I made __profd_ and __profc_ comdat in r355044, but I chose to make
__profd_ internal. At the time, I was only dealing with coverage, and in
that case, none of the instrumentation needs to reference __profd_.
However, if you use PGO, then instrumentation passes add calls to
__llvm_profile_instrument_range which reference __profd_ globals. The
solution is to make these globals externally visible by using
linkonce_odr linkage for data as was done for counters.
This is safe because PGO adds a CFG hash to the names of the data and
counter globals, so if different TUs have different globals, they will
get different data and counter arrays.
Reviewers: xur, hans
Differential Revision: https://reviews.llvm.org/D67579
llvm-svn: 372020
2019-09-17 02:49:09 +08:00
|
|
|
; COFF: @__profc__Z3barIvEvv = linkonce_odr hidden global [1 x i64] zeroinitializer, section "{{.*}}prfc$M", comdat, align 8
|
2019-09-18 05:10:49 +08:00
|
|
|
; COFF: @__profd__Z3barIvEvv = linkonce_odr hidden global { i64, i64, i64*, i8*, i8*, i32, [2 x i16] } { i64 4947693190065689389, i64 0, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc__Z3barIvEvv, i32 0, i32 0), i8*{{.*}}, i8* null, i32 1, [2 x i16] zeroinitializer }, section "{{.*}}prfd{{.*}}", comdat, align 8
|
2015-12-22 05:52:27 +08:00
|
|
|
|
|
|
|
|
2015-05-28 03:34:01 +08:00
|
|
|
declare void @llvm.instrprof.increment(i8*, i64, i32, i32) #1
|
|
|
|
|
|
|
|
define linkonce_odr void @_Z3barIvEvv() comdat {
|
|
|
|
entry:
|
2015-12-15 08:32:56 +08:00
|
|
|
call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn__Z3barIvEvv, i32 0, i32 0), i64 0, i32 1, i32 0)
|
2015-05-28 03:34:01 +08:00
|
|
|
ret void
|
|
|
|
}
|