[llvm] [MIR] Round-trip all machine metadata nodes (PR #219612)
Yaxun Liu via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 29 13:23:48 PDT 2026
================
@@ -1226,26 +1223,39 @@ bool MIRParserImpl::parseMBBReference(PerFunctionMIParsingState &PFS,
return false;
}
-bool MIRParserImpl::parseMachineMetadata(PerFunctionMIParsingState &PFS,
- const yaml::StringValue &Source) {
- SMDiagnostic Error;
- if (llvm::parseMachineMetadata(PFS, Source.Value, Source.SourceRange, Error))
- return error(Error, Source.SourceRange);
- return false;
-}
-
bool MIRParserImpl::parseMachineMetadataNodes(
PerFunctionMIParsingState &PFS, MachineFunction &MF,
const yaml::MachineFunction &YMF) {
+ // Parse the definitions as one LLVM metadata block so specialized nodes and
+ // forward references use the same rules as metadata in the IR module.
+ std::string Definitions;
for (const auto &MDS : YMF.MachineMetadataNodes) {
- if (parseMachineMetadata(PFS, MDS))
- return true;
+ Definitions.append(MDS.Value);
+ Definitions.push_back('\n');
----------------
yxsamliu wrote:
Thanks. I now preserve the YAML list-item boundaries. The parser reports an error if a definition crosses an item boundary or if one item contains more than one definition. I also added tests for these cases.
https://github.com/llvm/llvm-project/pull/219612
More information about the llvm-commits
mailing list