Skip to content

Commit 76745d2

Browse files
committed
Revert "[PGO] Make emitted symbols hidden"
This reverts commit 0487728. Looks like this is still breaking the test Profile-x86_64 :: instrprof-darwin-dead-strip.c (see comment on https://reviews.llvm.org/D135340).
1 parent 891eb20 commit 76745d2

File tree

18 files changed

+47
-23
lines changed

18 files changed

+47
-23
lines changed

clang/lib/Driver/ToolChains/Darwin.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,11 +1353,16 @@ void Darwin::addProfileRTLibs(const ArgList &Args,
13531353
// If we have a symbol export directive and we're linking in the profile
13541354
// runtime, automatically export symbols necessary to implement some of the
13551355
// runtime's functionality.
1356-
if (hasExportSymbolDirective(Args) && ForGCOV) {
1357-
addExportedSymbol(CmdArgs, "___gcov_dump");
1358-
addExportedSymbol(CmdArgs, "___gcov_reset");
1359-
addExportedSymbol(CmdArgs, "_writeout_fn_list");
1360-
addExportedSymbol(CmdArgs, "_reset_fn_list");
1356+
if (hasExportSymbolDirective(Args)) {
1357+
if (ForGCOV) {
1358+
addExportedSymbol(CmdArgs, "___gcov_dump");
1359+
addExportedSymbol(CmdArgs, "___gcov_reset");
1360+
addExportedSymbol(CmdArgs, "_writeout_fn_list");
1361+
addExportedSymbol(CmdArgs, "_reset_fn_list");
1362+
} else {
1363+
addExportedSymbol(CmdArgs, "___llvm_profile_filename");
1364+
addExportedSymbol(CmdArgs, "___llvm_profile_raw_version");
1365+
}
13611366
}
13621367

13631368
// Align __llvm_prf_{cnts,data} sections to the maximum expected page

clang/test/Driver/darwin-ld.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,18 @@
338338
// RUN: FileCheck -check-prefix=PROFILE_SECTALIGN %s < %t.log
339339
// PROFILE_SECTALIGN: "-sectalign" "__DATA" "__llvm_prf_cnts" "0x4000" "-sectalign" "__DATA" "__llvm_prf_data" "0x4000"
340340

341+
// RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate -exported_symbols_list /dev/null -### %t.o 2> %t.log
342+
// RUN: FileCheck -check-prefix=PROFILE_EXPORT %s < %t.log
343+
// RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate -Wl,-exported_symbols_list,/dev/null -### %t.o 2> %t.log
344+
// RUN: FileCheck -check-prefix=PROFILE_EXPORT %s < %t.log
345+
// RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate -Wl,-exported_symbol,foo -### %t.o 2> %t.log
346+
// RUN: FileCheck -check-prefix=PROFILE_EXPORT %s < %t.log
347+
// RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate -Xlinker -exported_symbol -Xlinker foo -### %t.o 2> %t.log
348+
// RUN: FileCheck -check-prefix=PROFILE_EXPORT %s < %t.log
349+
// RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate -Xlinker -exported_symbols_list -Xlinker /dev/null -### %t.o 2> %t.log
350+
// RUN: FileCheck -check-prefix=PROFILE_EXPORT %s < %t.log
351+
// PROFILE_EXPORT: "-exported_symbol" "___llvm_profile_filename" "-exported_symbol" "___llvm_profile_raw_version"
352+
//
341353
// RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate --coverage -### %t.o 2> %t.log
342354
// RUN: FileCheck -check-prefix=NO_PROFILE_EXPORT %s < %t.log
343355
// NO_PROFILE_EXPORT-NOT: "-exported_symbol"

compiler-rt/lib/profile/InstrProfilingNameVar.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
* user has not specified one. Set this up by moving the runtime's copy of this
1515
* symbol to an object file within the archive.
1616
*/
17-
COMPILER_RT_WEAK COMPILER_RT_VISIBILITY char INSTR_PROF_PROFILE_NAME_VAR[1] = {0};
17+
COMPILER_RT_WEAK char INSTR_PROF_PROFILE_NAME_VAR[1] = {0};

compiler-rt/lib/profile/InstrProfilingVersionVar.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@
1313
* The runtime should only provide its own definition of this symbol when the
1414
* user has not specified one. Set this up by moving the runtime's copy of this
1515
* symbol to an object file within the archive.
16+
*
17+
* Hide this symbol everywhere except Apple platforms, where its presence is
18+
* checked by the TAPI tool.
1619
*/
17-
COMPILER_RT_VISIBILITY COMPILER_RT_WEAK uint64_t INSTR_PROF_RAW_VERSION_VAR =
20+
#if !defined(__APPLE__)
21+
#define VERSION_VAR_VISIBILITY COMPILER_RT_VISIBILITY
22+
#else
23+
#define VERSION_VAR_VISIBILITY
24+
#endif
25+
VERSION_VAR_VISIBILITY COMPILER_RT_WEAK uint64_t INSTR_PROF_RAW_VERSION_VAR =
1826
INSTR_PROF_RAW_VERSION;

llvm/lib/ProfileData/InstrProf.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,6 @@ 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);
12141213
Triple TT(M.getTargetTriple());
12151214
if (TT.supportsCOMDAT()) {
12161215
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::HiddenVisibility);
383+
IRLevelVersionVariable->setVisibility(GlobalValue::DefaultVisibility);
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 = hidden constant i64 {{[0-9]+}}, comdat
17+
; GEN-COMDAT: @__llvm_profile_raw_version = 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 = hidden constant i64 {{[0-9]+}}, comdat
12+
; GEN: @__llvm_profile_raw_version = 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 = hidden constant i64 {{[0-9]+}}, comdat
13+
; CHECK: @__llvm_profile_raw_version = 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 = hidden constant i64 {{[0-9]+}}, comdat
12+
; GEN: @__llvm_profile_raw_version = 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

0 commit comments

Comments
 (0)