[llvm] [ThinLTO] Fix parsing null aliasee in alias summary (PR #169490)
Mingjie Xu via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 25 04:21:23 PST 2025
https://github.com/Enna1 created https://github.com/llvm/llvm-project/pull/169490
In https://github.com/llvm/llvm-project/commit/f8182f1aef5b6ec74cbe2c1618e759f0113921ba, we add support for printing "null" aliasee in AsmWriter, but missing support in LLParser.
>From fcb8d1b933ca2d2bfdd57d45bf6c1ece601d97ac Mon Sep 17 00:00:00 2001
From: "xumingjie.enna1" <xumingjie.enna1 at bytedance.com>
Date: Tue, 25 Nov 2025 20:00:34 +0800
Subject: [PATCH] [ThinLTO] Fix parsing null aliasee in alias summary
In https://github.com/llvm/llvm-project/commit/f8182f1aef5b6ec74cbe2c1618e759f0113921ba, we add support for printing "null" aliasee in AsmWriter, but missing support in LLParser.
---
llvm/lib/AsmParser/LLParser.cpp | 32 ++++++++++++++------------
llvm/test/Assembler/thinlto-summary.ll | 3 +++
2 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index 1bc2906f63b07..d28634a426c77 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -9887,25 +9887,27 @@ bool LLParser::parseAliasSummary(std::string Name, GlobalValue::GUID GUID,
ValueInfo AliaseeVI;
unsigned GVId;
- if (parseGVReference(AliaseeVI, GVId))
- return true;
-
- if (parseToken(lltok::rparen, "expected ')' here"))
- return true;
+ std::unique_ptr<AliasSummary> AS;
- auto AS = std::make_unique<AliasSummary>(GVFlags);
-
- AS->setModulePath(ModulePath);
+ if (!EatIfPresent(lltok::kw_null)) {
+ if (parseGVReference(AliaseeVI, GVId))
+ return true;
- // Record forward reference if the aliasee is not parsed yet.
- if (AliaseeVI.getRef() == FwdVIRef) {
- ForwardRefAliasees[GVId].emplace_back(AS.get(), Loc);
- } else {
- auto Summary = Index->findSummaryInModule(AliaseeVI, ModulePath);
- assert(Summary && "Aliasee must be a definition");
- AS->setAliasee(AliaseeVI, Summary);
+ AS = std::make_unique<AliasSummary>(GVFlags);
+ AS->setModulePath(ModulePath);
+ // Record forward reference if the aliasee is not parsed yet.
+ if (AliaseeVI.getRef() == FwdVIRef) {
+ ForwardRefAliasees[GVId].emplace_back(AS.get(), Loc);
+ } else {
+ auto Summary = Index->findSummaryInModule(AliaseeVI, ModulePath);
+ assert(Summary && "Aliasee must be a definition");
+ AS->setAliasee(AliaseeVI, Summary);
+ }
}
+ if (parseToken(lltok::rparen, "expected ')' here"))
+ return true;
+
return addGlobalValueToIndex(Name, GUID,
(GlobalValue::LinkageTypes)GVFlags.Linkage, ID,
std::move(AS), Loc);
diff --git a/llvm/test/Assembler/thinlto-summary.ll b/llvm/test/Assembler/thinlto-summary.ll
index e0d866da0d8a2..7af446a17da13 100644
--- a/llvm/test/Assembler/thinlto-summary.ll
+++ b/llvm/test/Assembler/thinlto-summary.ll
@@ -73,6 +73,9 @@
^31 = flags: 8
^32 = blockcount: 1888
+; Alias summary with null aliasee.
+^33 = gv: (guid: 32, summaries: (alias: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 0, dsoLocal: 1), aliasee: null)))
+
; Make sure we get back from llvm-dis essentially what we put in via llvm-as.
; CHECK: ^0 = module: (path: "thinlto-summary1.o", hash: (1369602428, 2747878711, 259090915, 2507395659, 1141468049))
; CHECK: ^1 = module: (path: "thinlto-summary2.o", hash: (2998369023, 4283347029, 1195487472, 2757298015, 1852134156))
More information about the llvm-commits
mailing list