From 912122080412e7d91ba5c7e3d3259803f8e776b3 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Fri, 16 May 2014 01:24:00 +0000 Subject: InstrProf: Set profile data to visibility hidden Shared objects are fairly broken for InstrProf right now -- a follow-up commit in compiler-rt will fix the rest of this. The main problem here is that at link time, profile data symbols in the shared object might get used instead of symbols from the main executable, creating invalid profile data sections. llvm-svn: 208939 --- clang/lib/CodeGen/CodeGenPGO.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'clang/lib/CodeGen/CodeGenPGO.cpp') diff --git a/clang/lib/CodeGen/CodeGenPGO.cpp b/clang/lib/CodeGen/CodeGenPGO.cpp index 9d4aaff8888..22534b828ee 100644 --- a/clang/lib/CodeGen/CodeGenPGO.cpp +++ b/clang/lib/CodeGen/CodeGenPGO.cpp @@ -140,6 +140,15 @@ llvm::GlobalVariable *CodeGenPGO::buildDataVar() { Data->setSection(getDataSection(CGM)); Data->setAlignment(8); + // Hide all these symbols so that we correctly get a copy for each + // executable. The profile format expects names and counters to be + // contiguous, so references into shared objects would be invalid. + if (!llvm::GlobalValue::isLocalLinkage(VarLinkage)) { + Name->setVisibility(llvm::GlobalValue::HiddenVisibility); + Data->setVisibility(llvm::GlobalValue::HiddenVisibility); + RegionCounters->setVisibility(llvm::GlobalValue::HiddenVisibility); + } + // Make sure the data doesn't get deleted. CGM.addUsedGlobal(Data); return Data; -- cgit v1.2.3