diff options
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); |