InstrProf: Make the __llvm_profile_runtime_user symbol hidden
authorJustin Bogner <mail@justinbogner.com>
Wed, 25 Feb 2015 22:52:20 +0000 (22:52 +0000)
committerJustin Bogner <mail@justinbogner.com>
Wed, 25 Feb 2015 22:52:20 +0000 (22:52 +0000)
This symbol exists only to pull in the required pieces of the runtime,
so nothing ever needs to refer to it. Making it hidden avoids the
potential for issues with duplicate symbols when linking profiled
libraries together.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230566 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Instrumentation/InstrProfiling.cpp
test/Instrumentation/InstrProfiling/linkage.ll

index 2a3d15421de9dec58b646bbc0377a7449c541ae6..b5a491f3a4061f601afb8c278f1133ab0878e16b 100644 (file)
@@ -288,6 +288,7 @@ void InstrProfiling::emitRuntimeHook() {
   User->addFnAttr(Attribute::NoInline);
   if (Options.NoRedZone)
     User->addFnAttr(Attribute::NoRedZone);
+  User->setVisibility(GlobalValue::HiddenVisibility);
 
   IRBuilder<> IRB(BasicBlock::Create(M->getContext(), "", User));
   auto *Load = IRB.CreateLoad(Var);
index 0e3dd05510a83f5c31591601347d13323934de48..0a92d5db446aaffd61eddedf7fcd5ad15e8ffc18 100644 (file)
@@ -40,7 +40,7 @@ declare void @llvm.instrprof.increment(i8*, i64, i32, i32)
 
 ; CHECK: @__llvm_profile_runtime = external global i32
 
-; CHECK: define linkonce_odr i32 @__llvm_profile_runtime_user() {{.*}} {
+; CHECK: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() {{.*}} {
 ; CHECK:   %[[REG:.*]] = load i32* @__llvm_profile_runtime
 ; CHECK:   ret i32 %[[REG]]
 ; CHECK: }