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

Justin Cady via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 29 11:25:35 PDT 2022


justincady created this revision.
justincady added reviewers: MaskRay, efriedma.
Herald added subscribers: Enna1, ellis, StephenFan, hiraditya.
Herald added a project: All.
justincady requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This change does not mark the symbol hidden on Windows to match libclang_rt.profile's
default visibility for Windows targets.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128842

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


Index: llvm/test/Instrumentation/InstrProfiling/profiling.ll
===================================================================
--- llvm/test/Instrumentation/InstrProfiling/profiling.ll
+++ 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 global i32
 
 ; ELF: $__profc_foo = comdat nodeduplicate
 ; ELF: $__profc_foo_weak = comdat nodeduplicate
Index: llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
===================================================================
--- llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
+++ llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
@@ -1244,6 +1244,8 @@
   auto *Var =
       new GlobalVariable(*M, Int32Ty, false, GlobalValue::ExternalLinkage,
                          nullptr, getInstrProfRuntimeHookVarName());
+  if (!TT.isOSWindows())
+    Var->setVisibility(GlobalValue::HiddenVisibility);
 
   if (TT.isOSBinFormatELF() && !TT.isPS()) {
     // Mark the user variable as used so that it isn't stripped out.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128842.441099.patch
Type: text/x-patch
Size: 1892 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220629/2e7a5900/attachment.bin>


More information about the llvm-commits mailing list