summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenPGO.cpp
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2015-03-20 06:34:38 +0000
committerJustin Bogner <mail@justinbogner.com>2015-03-20 06:34:38 +0000
commite9fe0a298c4c1602b94c2f49ab19a753eaadc87c (patch)
tree5a1bd0ef7c13bda446c52e21d4164f8bfc627fc1 /clang/lib/CodeGen/CodeGenPGO.cpp
parent3a8eb896c9d6696402bf113653c4c20b237c7009 (diff)
downloadbcm5719-llvm-e9fe0a298c4c1602b94c2f49ab19a753eaadc87c.tar.gz
bcm5719-llvm-e9fe0a298c4c1602b94c2f49ab19a753eaadc87c.zip
InstrProf: Make profile variables private to reduce binary size overhead
When we instrument a program for profiling, we copy the linkage of an instrumented function so that our datastructures merge in the same way as the function. This avoids redundant copies for things like linkonce, but ends up emitting names we never need to reference for normal and internal symbols. Promoting internal and external linkage to private for these variables reduces the size overhead of profiling drastically. llvm-svn: 232799
Diffstat (limited to 'clang/lib/CodeGen/CodeGenPGO.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenPGO.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CodeGenPGO.cpp b/clang/lib/CodeGen/CodeGenPGO.cpp
index a88335d0ac7..557828db0d0 100644
--- a/clang/lib/CodeGen/CodeGenPGO.cpp
+++ b/clang/lib/CodeGen/CodeGenPGO.cpp
@@ -58,12 +58,16 @@ void CodeGenPGO::setFuncName(llvm::Function *Fn) {
}
void CodeGenPGO::createFuncNameVar(llvm::GlobalValue::LinkageTypes Linkage) {
- // Usually, we want to match the function's linkage, but
- // available_externally and extern_weak both have the wrong semantics.
+ // We generally want to match the function's linkage, but available_externally
+ // and extern_weak both have the wrong semantics, and anything that doesn't
+ // need to link across compilation units doesn't need to be visible at all.
if (Linkage == llvm::GlobalValue::ExternalWeakLinkage)
Linkage = llvm::GlobalValue::LinkOnceAnyLinkage;
else if (Linkage == llvm::GlobalValue::AvailableExternallyLinkage)
Linkage = llvm::GlobalValue::LinkOnceODRLinkage;
+ else if (Linkage == llvm::GlobalValue::InternalLinkage ||
+ Linkage == llvm::GlobalValue::ExternalLinkage)
+ Linkage = llvm::GlobalValue::PrivateLinkage;
auto *Value =
llvm::ConstantDataArray::getString(CGM.getLLVMContext(), FuncName, false);
OpenPOWER on IntegriCloud