Skip to content

Commit 4ea1a64

Browse files
committed
[PGO] Make emitted symbols hidden
Differential Revision: https://reviews.llvm.org/D135340
1 parent 3411263 commit 4ea1a64

File tree

15 files changed

+27
-15
lines changed

15 files changed

+27
-15
lines changed

llvm/lib/ProfileData/InstrProf.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,6 +1210,7 @@ void createProfileFileNameVar(Module &M, StringRef InstrProfileOutput) {
12101210
GlobalVariable *ProfileNameVar = new GlobalVariable(
12111211
M, ProfileNameConst->getType(), true, GlobalValue::WeakAnyLinkage,
12121212
ProfileNameConst, INSTR_PROF_QUOTE(INSTR_PROF_PROFILE_NAME_VAR));
1213+
ProfileNameVar->setVisibility(GlobalValue::HiddenVisibility);
12131214
Triple TT(M.getTargetTriple());
12141215
if (TT.supportsCOMDAT()) {
12151216
ProfileNameVar->setLinkage(GlobalValue::ExternalLinkage);

llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ static GlobalVariable *createIRLevelProfileFlagVar(Module &M, bool IsCS) {
380380
auto IRLevelVersionVariable = new GlobalVariable(
381381
M, IntTy64, true, GlobalValue::WeakAnyLinkage,
382382
Constant::getIntegerValue(IntTy64, APInt(64, ProfileVersion)), VarName);
383-
IRLevelVersionVariable->setVisibility(GlobalValue::DefaultVisibility);
383+
IRLevelVersionVariable->setVisibility(GlobalValue::HiddenVisibility);
384384
Triple TT(M.getTargetTriple());
385385
if (TT.supportsCOMDAT()) {
386386
IRLevelVersionVariable->setLinkage(GlobalValue::ExternalLinkage);

llvm/test/Transforms/PGOProfile/branch1.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ target triple = "x86_64-unknown-linux-gnu"
1414
; GEN-DARWIN-LINKONCE: target triple = "x86_64-apple-darwin"
1515

1616
; GEN-COMDAT: $__llvm_profile_raw_version = comdat any
17-
; GEN-COMDAT: @__llvm_profile_raw_version = constant i64 {{[0-9]+}}, comdat
17+
; GEN-COMDAT: @__llvm_profile_raw_version = hidden constant i64 {{[0-9]+}}, comdat
1818
; GEN-LINKONCE: @__llvm_profile_raw_version = linkonce constant i64 {{[0-9]+}}
1919
; GEN: @__profn_test_br_1 = private constant [9 x i8] c"test_br_1"
2020

llvm/test/Transforms/PGOProfile/branch2.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16
99
target triple = "x86_64-unknown-linux-gnu"
1010

1111
; GEN: $__llvm_profile_raw_version = comdat any
12-
; GEN: @__llvm_profile_raw_version = constant i64 {{[0-9]+}}, comdat
12+
; GEN: @__llvm_profile_raw_version = hidden constant i64 {{[0-9]+}}, comdat
1313
; GEN: @__profn_test_br_2 = private constant [9 x i8] c"test_br_2"
1414

1515
define i32 @test_br_2(i32 %i) {

llvm/test/Transforms/PGOProfile/comdat_internal.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ $foo = comdat any
1010

1111
@bar = global ptr @foo, align 8
1212

13-
; CHECK: @__llvm_profile_raw_version = constant i64 {{[0-9]+}}, comdat
13+
; CHECK: @__llvm_profile_raw_version = hidden constant i64 {{[0-9]+}}, comdat
1414
; CHECK-NOT: __profn__stdin__foo
1515
; CHECK: @__profc__stdin__foo.[[#FOO_HASH]] = private global [1 x i64] zeroinitializer, section "__llvm_prf_cnts", comdat, align 8
1616
; CHECK: @__profd__stdin__foo.[[#FOO_HASH]] = private global { i64, i64, i64, ptr, ptr, i32, [2 x i16] } { i64 -5640069336071256030, i64 [[#FOO_HASH]], i64 sub (i64 ptrtoint (ptr @__profc__stdin__foo.742261418966908927 to i64), i64 ptrtoint (ptr @__profd__stdin__foo.742261418966908927 to i64)), ptr null

llvm/test/Transforms/PGOProfile/criticaledge.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16
99
target triple = "x86_64-unknown-linux-gnu"
1010

1111
; GEN: $__llvm_profile_raw_version = comdat any
12-
; GEN: @__llvm_profile_raw_version = constant i64 {{[0-9]+}}, comdat
12+
; GEN: @__llvm_profile_raw_version = hidden constant i64 {{[0-9]+}}, comdat
1313
; GEN: @__profn_test_criticalEdge = private constant [17 x i8] c"test_criticalEdge"
1414
; GEN: @__profn__stdin__bar = private constant [11 x i8] c"<stdin>:bar"
1515

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
; RUN: opt < %s -passes='thinlto-pre-link<O2>' --cs-profilegen-file=file -cspgo-kind=cspgo-instr-gen-pipeline -S | FileCheck %s
2+
3+
; CHECK: $__llvm_profile_filename = comdat any
4+
; CHECK: @__llvm_profile_filename = hidden local_unnamed_addr constant [5 x i8] c"file\00", comdat
5+
6+
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
7+
target triple = "x86_64-unknown-linux-gnu"
8+
9+
define i32 @test() {
10+
ret i32 0
11+
}

llvm/test/Transforms/PGOProfile/instr_entry_bb.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16
77
target triple = "x86_64-unknown-linux-gnu"
88

99
; GEN: $__llvm_profile_raw_version = comdat any
10-
; GEN: @__llvm_profile_raw_version = constant i64 {{[0-9]+}}, comdat
10+
; GEN: @__llvm_profile_raw_version = hidden constant i64 {{[0-9]+}}, comdat
1111
; GEN: @__profn_test_br_2 = private constant [9 x i8] c"test_br_2"
1212

1313
define i32 @test_br_2(i32 %i) {

llvm/test/Transforms/PGOProfile/landingpad.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ target triple = "x86_64-unknown-linux-gnu"
1111
@val = global i32 0, align 4
1212
@_ZTIi = external constant ptr
1313
; GEN: $__llvm_profile_raw_version = comdat any
14-
; GEN: @__llvm_profile_raw_version = constant i64 {{[0-9]+}}, comdat
14+
; GEN: @__llvm_profile_raw_version = hidden constant i64 {{[0-9]+}}, comdat
1515
; GEN: @__profn_bar = private constant [3 x i8] c"bar"
1616
; GEN: @__profn_foo = private constant [3 x i8] c"foo"
1717

llvm/test/Transforms/PGOProfile/loop1.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16
99
target triple = "x86_64-unknown-linux-gnu"
1010

1111
; GEN: $__llvm_profile_raw_version = comdat any
12-
; GEN: @__llvm_profile_raw_version = constant i64 {{[0-9]+}}, comdat
12+
; GEN: @__llvm_profile_raw_version = hidden constant i64 {{[0-9]+}}, comdat
1313
; GEN: @__profn_test_simple_for = private constant [15 x i8] c"test_simple_for"
1414

1515
define i32 @test_simple_for(i32 %n) {

0 commit comments

Comments
 (0)