summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorwhitequark <whitequark@whitequark.org>2017-10-15 12:29:01 +0000
committerwhitequark <whitequark@whitequark.org>2017-10-15 12:29:01 +0000
commitb2ce9ffede511a22b5d244d344272f212553b900 (patch)
tree75b450508848fef5eda75852c51a8c3798c5542f /llvm/lib/Transforms
parentc8d67979c038cb71ebef426fe311859dfe431e19 (diff)
downloadbcm5719-llvm-b2ce9ffede511a22b5d244d344272f212553b900.tar.gz
bcm5719-llvm-b2ce9ffede511a22b5d244d344272f212553b900.zip
[MergeFunctions] Replace all uses of unnamed_addr functions.
This reduces code size for constructs like vtables or interrupt tables that refer to functions in global initializers. Differential Revision: https://reviews.llvm.org/D34805 llvm-svn: 315852
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/IPO/MergeFunctions.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/IPO/MergeFunctions.cpp b/llvm/lib/Transforms/IPO/MergeFunctions.cpp
index a43b69f3413..95a05d87348 100644
--- a/llvm/lib/Transforms/IPO/MergeFunctions.cpp
+++ b/llvm/lib/Transforms/IPO/MergeFunctions.cpp
@@ -628,9 +628,15 @@ void MergeFunctions::filterInstsUnrelatedToPDI(
// call sites to point to F even when within the same translation unit.
void MergeFunctions::writeThunk(Function *F, Function *G) {
if (!G->isInterposable() && !MergeFunctionsPDI) {
- // Redirect direct callers of G to F. (See note on MergeFunctionsPDI
- // above).
- replaceDirectCallers(G, F);
+ if (G->hasGlobalUnnamedAddr()) {
+ // If G's address is not significant, replace it entirely.
+ Constant *BitcastF = ConstantExpr::getBitCast(F, G->getType());
+ G->replaceAllUsesWith(BitcastF);
+ } else {
+ // Redirect direct callers of G to F. (See note on MergeFunctionsPDI
+ // above).
+ replaceDirectCallers(G, F);
+ }
}
// If G was internal then we may have replaced all uses of G with F. If so,
OpenPOWER on IntegriCloud