[PATCH] D129009: [LTO] Fix LTO for aliased IFuncs
Schrodinger ZHU Yifan via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 1 17:16:13 PDT 2022
SchrodingerZhu updated this revision to Diff 441821.
SchrodingerZhu added a comment.
undo wrong patch
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D129009/new/
https://reviews.llvm.org/D129009
Files:
clang/test/Analysis/alias-indirect-function-lto.c
llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
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,19 @@
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();
+ // Skip summary for indirect function aliases as
+ // summary for aliasee will not be emitted.
+ 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 &&
Index: clang/test/Analysis/alias-indirect-function-lto.c
===================================================================
--- /dev/null
+++ clang/test/Analysis/alias-indirect-function-lto.c
@@ -0,0 +1,5 @@
+// RUN: %clang_analyze_cc1 -flto %s
+void f() __attribute__((ifunc("g")));
+static void *g() { return 0; };
+void h() __attribute__((alias("f")));
+// no crash
\ No newline at end of file
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129009.441821.patch
Type: text/x-patch
Size: 2400 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220702/1f7f3288/attachment-0001.bin>
More information about the cfe-commits
mailing list