Skip to content

Commit de2ae96

Browse files
committedOct 11, 2016
[InstrProf] Add support for dead_strip+live_support functionality
On Darwin, marking a section as "regular,live_support" means that a symbol in the section should only be kept live if it has a reference to something that is live. Otherwise, the linker is free to dead-strip it. Turn this functionality on for the __llvm_prf_data section. This means that counters and data associated with dead functions will be removed from dead-stripped binaries. This will result in smaller profiles and binaries, and should speed up profile collection. Tested with check-profile, llvm-lit test/tools/llvm-{cov,profdata}, and check-llvm. Differential Revision: https://reviews.llvm.org/D25456 llvm-svn: 283947
1 parent a09d11e commit de2ae96

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed
 

‎llvm/include/llvm/ProfileData/InstrProf.h

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ inline StringRef getInstrProfNameSectionName(bool AddSegment) {
5555
/// data.
5656
inline StringRef getInstrProfDataSectionName(bool AddSegment) {
5757
return AddSegment ? "__DATA," INSTR_PROF_DATA_SECT_NAME_STR
58+
",regular,live_support"
5859
: INSTR_PROF_DATA_SECT_NAME_STR;
5960
}
6061

‎llvm/test/Instrumentation/InstrProfiling/PR23499.ll

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ $_Z3barIvEvv = comdat any
1515

1616
; CHECK: @__profn__Z3barIvEvv = private constant [11 x i8] c"_Z3barIvEvv", align 1
1717
; CHECK: @__profc__Z3barIvEvv = linkonce_odr hidden global [1 x i64] zeroinitializer, section "{{.*}}__llvm_prf_cnts", comdat($__profv__Z3barIvEvv), align 8
18-
; CHECK: @__profd__Z3barIvEvv = linkonce_odr hidden global { i64, i64, i64*, i8*, i8*, i32, [1 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, [1 x i16] zeroinitializer }, section "{{.*}}__llvm_prf_data", comdat($__profv__Z3barIvEvv), align 8
18+
; CHECK: @__profd__Z3barIvEvv = linkonce_odr hidden global { i64, i64, i64*, i8*, i8*, i32, [1 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, [1 x i16] zeroinitializer }, section "{{.*}}__llvm_prf_data{{.*}}", comdat($__profv__Z3barIvEvv), align 8
1919
; CHECK: @__llvm_prf_nm = private constant [{{.*}} x i8] c"{{.*}}", section "{{.*}}__llvm_prf_names"
2020

2121

2222
; COFF: @__profn__Z3barIvEvv = private constant [11 x i8] c"_Z3barIvEvv", align 1
2323
; COFF: @__profc__Z3barIvEvv = linkonce_odr hidden global [1 x i64] zeroinitializer, section "{{.*}}__llvm_prf_cnts", comdat, align 8
24-
; COFF: @__profd__Z3barIvEvv = linkonce_odr hidden global { i64, i64, i64*, i8*, i8*, i32, [1 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, [1 x i16] zeroinitializer }, section "{{.*}}__llvm_prf_data", comdat($__profc__Z3barIvEvv), align 8
24+
; COFF: @__profd__Z3barIvEvv = linkonce_odr hidden global { i64, i64, i64*, i8*, i8*, i32, [1 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, [1 x i16] zeroinitializer }, section "{{.*}}__llvm_prf_data{{.*}}", comdat($__profc__Z3barIvEvv), align 8
2525

2626

2727
declare void @llvm.instrprof.increment(i8*, i64, i32, i32) #1

‎llvm/test/Instrumentation/InstrProfiling/platform.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
; MACHO: @__profc_foo = hidden global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8
1919
; ELF: @__profc_foo = hidden global [1 x i64] zeroinitializer, section "__llvm_prf_cnts", align 8
2020

21-
; MACHO: @__profd_foo = hidden {{.*}}, section "__DATA,__llvm_prf_data", align 8
21+
; MACHO: @__profd_foo = hidden {{.*}}, section "__DATA,__llvm_prf_data,regular,live_support", align 8
2222
; LINUX: @__profd_foo = hidden {{.*}}, section "__llvm_prf_data", align 8
2323
; FREEBSD: @__profd_foo = hidden {{.*}}, section "__llvm_prf_data", align 8
2424
; PS4: @__profd_foo = hidden {{.*}}, section "__llvm_prf_data", align 8

‎llvm/test/Instrumentation/InstrProfiling/profiling.ll

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@ target triple = "x86_64-apple-macosx10.10.0"
1111
; CHECK: @__profn_baz = private constant [3 x i8] c"baz"
1212

1313
; CHECK: @__profc_foo = hidden global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8
14-
; CHECK: @__profd_foo = hidden {{.*}}, section "__DATA,__llvm_prf_data", align 8
14+
; CHECK: @__profd_foo = hidden {{.*}}, section "__DATA,__llvm_prf_data,regular,live_support", align 8
1515
define void @foo() {
1616
call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_foo, i32 0, i32 0), i64 0, i32 1, i32 0)
1717
ret void
1818
}
1919

2020
; CHECK: @__profc_bar = hidden global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8
21-
; CHECK: @__profd_bar = hidden {{.*}}, section "__DATA,__llvm_prf_data", align 8
21+
; CHECK: @__profd_bar = hidden {{.*}}, section "__DATA,__llvm_prf_data,regular,live_support", align 8
2222
define void @bar() {
2323
call void @llvm.instrprof.increment(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @__profn_bar, i32 0, i32 0), i64 0, i32 1, i32 0)
2424
ret void
2525
}
2626

2727
; CHECK: @__profc_baz = hidden global [3 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8
28-
; CHECK: @__profd_baz = hidden {{.*}}, section "__DATA,__llvm_prf_data", align 8
28+
; CHECK: @__profd_baz = hidden {{.*}}, section "__DATA,__llvm_prf_data,regular,live_support", align 8
2929
define void @baz() {
3030
call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_baz, i32 0, i32 0), i64 0, i32 3, i32 0)
3131
call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_baz, i32 0, i32 0), i64 0, i32 3, i32 1)

0 commit comments

Comments
 (0)