[PATCH] D81911: [ThinLTO] Work around getBaseObject returning null for alias-to-ifunc
Itay Bookstein via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 7 09:38:17 PDT 2020
nextsilicon-itay-bookstein updated this revision to Diff 290307.
nextsilicon-itay-bookstein added a comment.
I have updated the diff to include the changes you suggested. However, as you said, for the test to have a chance of passing, https://reviews.llvm.org/D82745 is required. I will send out a mail to discuss the design issue on llvm-dev soon.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D81911/new/
https://reviews.llvm.org/D81911
Files:
llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
llvm/test/Bitcode/thinlto-summary-alias-ifunc.ll
Index: llvm/test/Bitcode/thinlto-summary-alias-ifunc.ll
===================================================================
--- /dev/null
+++ llvm/test/Bitcode/thinlto-summary-alias-ifunc.ll
@@ -0,0 +1,19 @@
+; RUN: opt -module-summary %s -o - | llvm-bcanalyzer -dump | FileCheck %s
+
+; PR46340
+; Check that alias-to-ifunc is properly generated in the module summary.
+
+; CHECK: <GLOBALVAL_SUMMARY_BLOCK
+; CHECK: <ALIAS
+; CHECK: </GLOBALVAL_SUMMARY_BLOCK>
+
+ at bar = dso_local alias void (), void ()* @foo
+ at foo = dso_local ifunc void (), bitcast (i8* ()* @foo_ifunc to void ()*)
+
+define internal i8* @foo_ifunc() {
+ ret i8* bitcast (void ()* @foo_impl to i8*)
+}
+
+define internal void @foo_impl() {
+ ret void
+}
Index: llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
===================================================================
--- llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -618,6 +618,16 @@
Index.addGlobalValueSummary(V, std::move(GVarSummary));
}
+static const GlobalValue *getAliasee(const GlobalAlias &A)
+{
+ const GlobalValue *Aliasee = A.getBaseObject();
+ if (Aliasee)
+ return Aliasee;
+
+ // Workaround for PR46340
+ return dyn_cast<GlobalIFunc>(A.getAliasee());
+}
+
static void
computeAliasSummary(ModuleSummaryIndex &Index, const GlobalAlias &A,
DenseSet<GlobalValue::GUID> &CantBePromoted) {
@@ -626,7 +636,8 @@
/* Live = */ false, A.isDSOLocal(),
A.hasLinkOnceODRLinkage() && A.hasGlobalUnnamedAddr());
auto AS = std::make_unique<AliasSummary>(Flags);
- auto *Aliasee = A.getBaseObject();
+ auto *Aliasee = getAliasee(A);
+ assert(Aliasee && "Aliasee is null");
auto AliaseeVI = Index.getValueInfo(Aliasee->getGUID());
assert(AliaseeVI && "Alias expects aliasee summary to be available");
assert(AliaseeVI.getSummaryList().size() == 1 &&
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81911.290307.patch
Type: text/x-patch
Size: 1948 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200907/3be07434/attachment.bin>
More information about the llvm-commits
mailing list