aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
diff options
context:
space:
mode:
authorSchrodinger ZHU Yifan <i@zhuyi.fan>2022-07-20 15:30:38 -0700
committerFangrui Song <i@maskray.me>2022-07-20 15:30:38 -0700
commit304027206c883b61b76465b3c2a139927ea71344 (patch)
treeb3554b04aee4c2f76a237b379414a4aa116f894d /llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
parentfe1678d1b2bf395b7b1589001f285d26d4013c37 (diff)
downloadllvm-304027206c883b61b76465b3c2a139927ea71344.zip
llvm-304027206c883b61b76465b3c2a139927ea71344.tar.gz
llvm-304027206c883b61b76465b3c2a139927ea71344.tar.bz2
[ThinLTO] Support aliased GlobalIFunc
Fixes https://github.com/llvm/llvm-project/issues/56290: when an ifunc is aliased in LTO, clang will attempt to create an alias summary; however, as ifunc is not included in the module summary, doing so will lead to crash. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D129009
Diffstat (limited to 'llvm/lib/Analysis/ModuleSummaryAnalysis.cpp')
-rw-r--r--llvm/lib/Analysis/ModuleSummaryAnalysis.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
index f364d89..c52b27a 100644
--- a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -646,15 +646,18 @@ static void computeVariableSummary(ModuleSummaryIndex &Index,
Index.addGlobalValueSummary(V, std::move(GVarSummary));
}
-static void
-computeAliasSummary(ModuleSummaryIndex &Index, const GlobalAlias &A,
- DenseSet<GlobalValue::GUID> &CantBePromoted) {
+static void computeAliasSummary(ModuleSummaryIndex &Index, const GlobalAlias &A,
+ DenseSet<GlobalValue::GUID> &CantBePromoted) {
+ // Skip summary for indirect function aliases as summary for aliasee will not
+ // be emitted.
+ const GlobalObject *Aliasee = A.getAliaseeObject();
+ if (isa<GlobalIFunc>(Aliasee))
+ return;
bool NonRenamableLocal = isNonRenamableLocal(A);
GlobalValueSummary::GVFlags Flags(
A.getLinkage(), A.getVisibility(), NonRenamableLocal,
/* Live = */ false, A.isDSOLocal(), A.canBeOmittedFromSymbolTable());
auto AS = std::make_unique<AliasSummary>(Flags);
- auto *Aliasee = A.getAliaseeObject();
auto AliaseeVI = Index.getValueInfo(Aliasee->getGUID());
assert(AliaseeVI && "Alias expects aliasee summary to be available");
assert(AliaseeVI.getSummaryList().size() == 1 &&
@@ -811,6 +814,13 @@ ModuleSummaryIndex llvm::buildModuleSummaryIndex(
for (const GlobalAlias &A : M.aliases())
computeAliasSummary(Index, A, CantBePromoted);
+ // Iterate through ifuncs, set their resolvers all alive.
+ for (const GlobalIFunc &I : M.ifuncs()) {
+ I.applyAlongResolverPath([&Index](const GlobalValue &GV) {
+ Index.getGlobalValueSummary(GV)->setLive(true);
+ });
+ }
+
for (auto *V : LocalsUsed) {
auto *Summary = Index.getGlobalValueSummary(*V);
assert(Summary && "Missing summary for global value");