diff options
author | whitequark <whitequark@whitequark.org> | 2017-10-15 12:29:01 +0000 |
---|---|---|
committer | whitequark <whitequark@whitequark.org> | 2017-10-15 12:29:01 +0000 |
commit | e53e8bdb9baba4e9f5ae32c50c04184780c07a0b (patch) | |
tree | 68f1c5b979399192ff9b5a7b6871ba1bcaec9f41 /lib/Transforms/IPO | |
parent | 49fe891017a6ae7a39112fcd4bcf37e1f0330d53 (diff) |
[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
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315852 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO')
-rw-r--r-- | lib/Transforms/IPO/MergeFunctions.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/Transforms/IPO/MergeFunctions.cpp b/lib/Transforms/IPO/MergeFunctions.cpp index a43b69f3413..95a05d87348 100644 --- a/lib/Transforms/IPO/MergeFunctions.cpp +++ b/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, |