[llvm] [TableGen] Resolve References at top level (PR #104578)
Akshat Oke via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 18 22:48:39 PDT 2024
https://github.com/Akshat-Oke updated https://github.com/llvm/llvm-project/pull/104578
>From 0f940167103c8df98d554049224e4d856d88c714 Mon Sep 17 00:00:00 2001
From: Akshat Oke <Akshat.Oke at amd.com>
Date: Fri, 16 Aug 2024 10:11:00 +0000
Subject: [PATCH] [TableGen] Resolve References at top level
Add a dummy resolver to resolve references outside records. This invokes
Fold() with isFinal to force resolution.
Fixes #102447
---
llvm/lib/TableGen/TGParser.cpp | 9 +++++++--
llvm/test/TableGen/dump.td | 3 +++
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/TableGen/TGParser.cpp b/llvm/lib/TableGen/TGParser.cpp
index ce9da960545c23..d1d46105c814e9 100644
--- a/llvm/lib/TableGen/TGParser.cpp
+++ b/llvm/lib/TableGen/TGParser.cpp
@@ -4460,8 +4460,13 @@ bool TGParser::ParseDump(MultiClass *CurMultiClass, Record *CurRec) {
if (CurRec)
CurRec->addDump(Loc, Message);
- else
- addEntry(std::make_unique<Record::DumpInfo>(Loc, Message));
+ else {
+ HasReferenceResolver resolver{nullptr};
+ resolver.setFinal(true);
+ // force a resolution with a dummy resolver
+ Init *ResolvedMessage = Message->resolveReferences(resolver);
+ addEntry(std::make_unique<Record::DumpInfo>(Loc, ResolvedMessage));
+ }
return false;
}
diff --git a/llvm/test/TableGen/dump.td b/llvm/test/TableGen/dump.td
index 633e73802ffa3e..7f021755e2e821 100644
--- a/llvm/test/TableGen/dump.td
+++ b/llvm/test/TableGen/dump.td
@@ -101,3 +101,6 @@ def Three : BaseClassForSet;
}
// CHECK: [[FILE]]:[[@LINE+1]]:1: note: TheSet = [Subset_One, Subset_Two, Three]
dump "TheSet = " # !repr(TheSet);
+
+// CHECK: [[FILE]]:[[@LINE+1]]:1: note: 0
+dump !repr(!exists<BaseClassForSet>("non-existent-record"));
\ No newline at end of file
More information about the llvm-commits
mailing list