aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2009-06-12 15:56:56 +0000
committerNick Lewycky <nicholas@mxc.ca>2009-06-12 15:56:56 +0000
commitf4dcd8a81ee3bf239caa9e3988b8fe6c0dbbd381 (patch)
tree90aabaabcaa37310a279b03150c147cfa9126b44 /lib
parent8c6d1469908c02987391862c389c727aa90080ca (diff)
downloadexternal_llvm-f4dcd8a81ee3bf239caa9e3988b8fe6c0dbbd381.zip
external_llvm-f4dcd8a81ee3bf239caa9e3988b8fe6c0dbbd381.tar.gz
external_llvm-f4dcd8a81ee3bf239caa9e3988b8fe6c0dbbd381.tar.bz2
Given two identical weak functions, produce one internal function and two weak
thunks. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73230 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/IPO/MergeFunctions.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/Transforms/IPO/MergeFunctions.cpp b/lib/Transforms/IPO/MergeFunctions.cpp
index 16083ec..e237fcd 100644
--- a/lib/Transforms/IPO/MergeFunctions.cpp
+++ b/lib/Transforms/IPO/MergeFunctions.cpp
@@ -458,8 +458,8 @@ static LinkageCategory categorize(const Function *F) {
}
static void ThunkGToF(Function *F, Function *G) {
- Function *NewG = Function::Create(G->getFunctionType(), G->getLinkage(),
- "", G->getParent());
+ Function *NewG = Function::Create(G->getFunctionType(), G->getLinkage(), "",
+ G->getParent());
BasicBlock *BB = BasicBlock::Create("", NewG);
std::vector<Value *> Args;
@@ -539,8 +539,21 @@ static bool fold(std::vector<Function *> &FnVec, unsigned i, unsigned j) {
}
break;
- case ExternalWeak:
- return false;
+ case ExternalWeak: {
+ assert(catG == ExternalWeak);
+
+ // Make them both thunks to the same internal function.
+ F->setAlignment(std::max(F->getAlignment(), G->getAlignment()));
+ Function *H = Function::Create(F->getFunctionType(), F->getLinkage(), "",
+ F->getParent());
+ H->copyAttributesFrom(F);
+ H->takeName(F);
+
+ ThunkGToF(F, G);
+ ThunkGToF(F, H);
+
+ F->setLinkage(GlobalValue::InternalLinkage);
+ } break;
case Internal:
switch (catG) {