diff options
| author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-03-20 22:50:08 +0000 |
|---|---|---|
| committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-03-20 22:50:08 +0000 |
| commit | 81e3346e95b2e3f65e894f5e31d1a8141a4bbace (patch) | |
| tree | 7373645c1f9999b520253c11c20e38d1a084de7e /lib/CodeGen/CodeGenPGO.cpp | |
| parent | eddc01635b67d2310e030631b6bc4e84820964d8 (diff) | |
| download | clang-81e3346e95b2e3f65e894f5e31d1a8141a4bbace.tar.gz clang-81e3346e95b2e3f65e894f5e31d1a8141a4bbace.tar.bz2 clang-81e3346e95b2e3f65e894f5e31d1a8141a4bbace.tar.xz | |
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>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204408 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenPGO.cpp')
| -rw-r--r-- | lib/CodeGen/CodeGenPGO.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/CodeGen/CodeGenPGO.cpp b/lib/CodeGen/CodeGenPGO.cpp index 0dfecfc36c..99109f42e4 100644 --- a/lib/CodeGen/CodeGenPGO.cpp +++ b/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(); |
