[llvm] 3d438ce - [InstrProf] Mark __llvm_profile_runtime hidden to match libclang_rt.profile definition

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 11 11:29:25 PDT 2022


Author: Justin Cady
Date: 2022-07-11T11:29:20-07:00
New Revision: 3d438ceed10d73f951226d398abf867822b68cb1

URL: https://github.com/llvm/llvm-project/commit/3d438ceed10d73f951226d398abf867822b68cb1
DIFF: https://github.com/llvm/llvm-project/commit/3d438ceed10d73f951226d398abf867822b68cb1.diff

LOG: [InstrProf] Mark __llvm_profile_runtime hidden to match libclang_rt.profile definition

Mark the symbol hidden to match INSTR_PROF_PROFILE_RUNTIME_VAR in compiler-rt.

Fixes second issue discussed at https://discourse.llvm.org/t/63090

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D128842

Added: 
    

Modified: 
    llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
    llvm/test/Instrumentation/InstrProfiling/profiling.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
index 7843b15228308..3572cb3b50e23 100644
--- a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
+++ b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
@@ -1244,6 +1244,7 @@ bool InstrProfiling::emitRuntimeHook() {
   auto *Var =
       new GlobalVariable(*M, Int32Ty, false, GlobalValue::ExternalLinkage,
                          nullptr, getInstrProfRuntimeHookVarName());
+  Var->setVisibility(GlobalValue::HiddenVisibility);
 
   if (TT.isOSBinFormatELF() && !TT.isPS()) {
     // Mark the user variable as used so that it isn't stripped out.

diff  --git a/llvm/test/Instrumentation/InstrProfiling/profiling.ll b/llvm/test/Instrumentation/InstrProfiling/profiling.ll
index d65dac6a1e3da..15cc53caf91e8 100644
--- a/llvm/test/Instrumentation/InstrProfiling/profiling.ll
+++ b/llvm/test/Instrumentation/InstrProfiling/profiling.ll
@@ -8,11 +8,13 @@
 ; RUN: opt < %s -mtriple=x86_64-sie-ps5 -passes=instrprof -S | FileCheck %s --check-prefixes=ELF,PS
 ; RUN: opt < %s  -mtriple=x86_64-pc-win32-coff -passes=instrprof -S | FileCheck %s --check-prefixes=COFF
 ; RUN: opt < %s -mtriple=powerpc64-ibm-aix-xcoff -passes=instrprof -S | FileCheck %s --check-prefixes=XCOFF
+; RUN: opt < %s -mtriple=x86_64-pc-freebsd13 -passes=instrprof -S | FileCheck %s --check-prefixes=ELF
 
-; MACHO: @__llvm_profile_runtime = external global i32
-; ELF_GENERIC: @__llvm_profile_runtime = external global i32
+; MACHO: @__llvm_profile_runtime = external hidden global i32
+; ELF_GENERIC: @__llvm_profile_runtime = external hidden global i32
 ; ELF-NOT: @__llvm_profile_runtime = external global i32
-; XCOFF: @__llvm_profile_runtime = external global i32
+; XCOFF: @__llvm_profile_runtime = external hidden global i32
+; COFF: @__llvm_profile_runtime = external hidden global i32
 
 ; ELF: $__profc_foo = comdat nodeduplicate
 ; ELF: $__profc_foo_weak = comdat nodeduplicate


        


More information about the llvm-commits mailing list