diff options
author | Mehdi Amini <mehdi.amini@apple.com> | 2016-04-20 04:17:36 +0000 |
---|---|---|
committer | Mehdi Amini <mehdi.amini@apple.com> | 2016-04-20 04:17:36 +0000 |
commit | 2c719cc11781bba190687b3a68fea88d88e2fef8 (patch) | |
tree | 8a738579ecb02f262d0f6533b686d49307fab5f3 /llvm/lib/Transforms | |
parent | 48591dd98cd840e7add4615211691bf4bbb5640d (diff) | |
download | bcm5719-llvm-2c719cc11781bba190687b3a68fea88d88e2fef8.tar.gz bcm5719-llvm-2c719cc11781bba190687b3a68fea88d88e2fef8.zip |
FunctionImport: make sure we always select the right callee in presence of alias
From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 266854
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/IPO/FunctionImport.cpp | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/llvm/lib/Transforms/IPO/FunctionImport.cpp b/llvm/lib/Transforms/IPO/FunctionImport.cpp index eef7385dd08..9d7d78a30a1 100644 --- a/llvm/lib/Transforms/IPO/FunctionImport.cpp +++ b/llvm/lib/Transforms/IPO/FunctionImport.cpp @@ -86,12 +86,21 @@ selectCallee(const GlobalValueInfoList &CalleeInfoList, unsigned Threshold) { assert(GlobInfo->summary() && "We should not have a Global Info without summary"); auto *GVSummary = GlobInfo->summary(); - if (auto *AS = dyn_cast<AliasSummary>(GVSummary)) + if (GlobalValue::isWeakAnyLinkage(GVSummary->linkage())) + // There is no point in importing weak symbols, we can't inline them + return false; + if (auto *AS = dyn_cast<AliasSummary>(GVSummary)) { GVSummary = &AS->getAliasee(); - auto *Summary = cast<FunctionSummary>(GVSummary); + // Alias can't point to "available_externally". However when we import + // linkOnceODR the linkage does not change. So we import the alias + // and aliasee only in this case. + // FIXME: we should import alias as available_externally *function*, + // the destination module does need to know it is an alias. + if (!GlobalValue::isLinkOnceODRLinkage(GVSummary->linkage())) + return false; + } - if (GlobalValue::isWeakAnyLinkage(Summary->linkage())) - return false; + auto *Summary = cast<FunctionSummary>(GVSummary); if (Summary->instCount() > Threshold) return false; @@ -166,16 +175,9 @@ static void computeImportForFunction( if (isa<AliasSummary>(CalleeSummary)) { ResolvedCalleeSummary = cast<FunctionSummary>( &cast<AliasSummary>(CalleeSummary)->getAliasee()); - if (!GlobalValue::isLinkOnceODRLinkage( - ResolvedCalleeSummary->linkage())) { - // Alias can't point to "available_externally". However when we import - // linkOnceODR the linkage does not change. So we import the alias - // and aliasee only in this case. - // FIXME: we should import alias as available_externally *function*, the - // destination module does need to know it is an alias. - DEBUG(dbgs() << "ignored! Aliasee is not linkonce_odr.\n"); - continue; - } + assert( + GlobalValue::isLinkOnceODRLinkage(ResolvedCalleeSummary->linkage()) && + "Unexpected alias to a non-linkonceODR in import list"); } else ResolvedCalleeSummary = cast<FunctionSummary>(CalleeSummary); |