SchrodingerZhu updated this revision to Diff 441848. SchrodingerZhu added a comment.
- address cr: use IR instead Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D129009/new/ https://reviews.llvm.org/D129009 Files: llvm/lib/Analysis/ModuleSummaryAnalysis.cpp llvm/lib/Bitcode/Writer/BitcodeWriter.cpp llvm/test/LTO/alias-indirect-function-lto.ll Index: llvm/test/LTO/alias-indirect-function-lto.ll =================================================================== --- /dev/null +++ llvm/test/LTO/alias-indirect-function-lto.ll @@ -0,0 +1,16 @@ +; RUN: opt -module-summary -o %t.bc %s + +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +@foo = ifunc i32 (i32), i32 (i32)* ()* @foo_resolver + +define internal i32 (i32)* @foo_resolver() { +entry: + ret i32 (i32)* null +} + +@bar = alias i32 (i32), i32 (i32)* @foo + +@baz = weak alias i32 (i32), i32 (i32)* @foo +; no crash Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp =================================================================== --- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -4103,8 +4103,9 @@ for (const GlobalAlias &A : M.aliases()) { auto *Aliasee = A.getAliaseeObject(); - if (!Aliasee->hasName()) - // Nameless function don't have an entry in the summary, skip it. + if (!Aliasee->hasName() || isa<GlobalIFunc>(Aliasee)) + // IFunc function and Nameless function don't have an entry in the + // summary, skip it. continue; auto AliasId = VE.getValueID(&A); auto AliaseeId = VE.getValueID(Aliasee); Index: llvm/lib/Analysis/ModuleSummaryAnalysis.cpp =================================================================== --- llvm/lib/Analysis/ModuleSummaryAnalysis.cpp +++ llvm/lib/Analysis/ModuleSummaryAnalysis.cpp @@ -646,15 +646,20 @@ 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) { + auto *Aliasee = A.getAliaseeObject(); + + if (isa<GlobalIFunc>(Aliasee)) + // Skip summary for indirect function aliases as + // summary for aliasee will not be emitted. + 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 &&
Index: llvm/test/LTO/alias-indirect-function-lto.ll =================================================================== --- /dev/null +++ llvm/test/LTO/alias-indirect-function-lto.ll @@ -0,0 +1,16 @@ +; RUN: opt -module-summary -o %t.bc %s + +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +@foo = ifunc i32 (i32), i32 (i32)* ()* @foo_resolver + +define internal i32 (i32)* @foo_resolver() { +entry: + ret i32 (i32)* null +} + +@bar = alias i32 (i32), i32 (i32)* @foo + +@baz = weak alias i32 (i32), i32 (i32)* @foo +; no crash Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp =================================================================== --- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -4103,8 +4103,9 @@ for (const GlobalAlias &A : M.aliases()) { auto *Aliasee = A.getAliaseeObject(); - if (!Aliasee->hasName()) - // Nameless function don't have an entry in the summary, skip it. + if (!Aliasee->hasName() || isa<GlobalIFunc>(Aliasee)) + // IFunc function and Nameless function don't have an entry in the + // summary, skip it. continue; auto AliasId = VE.getValueID(&A); auto AliaseeId = VE.getValueID(Aliasee); Index: llvm/lib/Analysis/ModuleSummaryAnalysis.cpp =================================================================== --- llvm/lib/Analysis/ModuleSummaryAnalysis.cpp +++ llvm/lib/Analysis/ModuleSummaryAnalysis.cpp @@ -646,15 +646,20 @@ 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) { + auto *Aliasee = A.getAliaseeObject(); + + if (isa<GlobalIFunc>(Aliasee)) + // Skip summary for indirect function aliases as + // summary for aliasee will not be emitted. + 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 &&
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits