summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenPGO.cpp
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2014-03-20 22:50:08 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2014-03-20 22:50:08 +0000
commit7c41451bc935043f75157ec8aacc0fa423793faf (patch)
tree6b42a3a635e3e2564f4939f112da4e75171b685b /clang/lib/CodeGen/CodeGenPGO.cpp
parent73f78627401201983e8110577290eeee9ae0cd6e (diff)
downloadbcm5719-llvm-7c41451bc935043f75157ec8aacc0fa423793faf.tar.gz
bcm5719-llvm-7c41451bc935043f75157ec8aacc0fa423793faf.zip
PGO: Don't define instrumentation data available_externally
Variables with available_externally linkage can be dropped at will. This causes link errors, since there are still references to the instrumentation! linkonce_odr is almost equivalent, so use that instead. As a drive-by fix (I don't have an Elf system, so I'm not sure how to write a testcase), use linkonce linkage for the instrumentation of extern_weak functions. <rdar://problem/15943240> llvm-svn: 204408
Diffstat (limited to 'clang/lib/CodeGen/CodeGenPGO.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenPGO.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenPGO.cpp b/clang/lib/CodeGen/CodeGenPGO.cpp
index 0dfecfc36cd..99109f42e41 100644
--- a/clang/lib/CodeGen/CodeGenPGO.cpp
+++ b/clang/lib/CodeGen/CodeGenPGO.cpp
@@ -824,7 +824,22 @@ void CodeGenPGO::assignRegionCounters(const Decl *D, llvm::Function *Fn) {
if (!D)
return;
setFuncName(Fn);
+
+ // Set the linkage for variables based on the function linkage. Usually, we
+ // want to match it, but available_externally and extern_weak both have the
+ // wrong semantics.
VarLinkage = Fn->getLinkage();
+ switch (VarLinkage) {
+ case llvm::GlobalValue::ExternalWeakLinkage:
+ VarLinkage = llvm::GlobalValue::LinkOnceAnyLinkage;
+ break;
+ case llvm::GlobalValue::AvailableExternallyLinkage:
+ VarLinkage = llvm::GlobalValue::LinkOnceODRLinkage;
+ break;
+ default:
+ break;
+ }
+
mapRegionCounters(D);
if (InstrumentRegions)
emitCounterVariables();
OpenPOWER on IntegriCloud