diff options
author | Jay Foad <jay.foad@amd.com> | 2025-04-24 18:57:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-24 18:57:51 +0100 |
commit | 2bc6f9d4b6ff1d838f1c2d50cacbab6ba2f20bc9 (patch) | |
tree | 7c67c461289e0bffdcbdde83cb8f773f50e90f13 /llvm/lib/TableGen/TGParser.cpp | |
parent | 6e3b16bec3a3384d8d2deb23d770d1d6a7357c50 (diff) | |
download | llvm-2bc6f9d4b6ff1d838f1c2d50cacbab6ba2f20bc9.zip llvm-2bc6f9d4b6ff1d838f1c2d50cacbab6ba2f20bc9.tar.gz llvm-2bc6f9d4b6ff1d838f1c2d50cacbab6ba2f20bc9.tar.bz2 |
[TableGen] Only store direct superclasses in Record (#123072)
In Record only store the direct superclasses instead of all
superclasses. getSuperClasses recurses to find all superclasses when
necessary.
This gives a small reduction in memory usage. On lib/Target/X86/X86.td I
measured about 2.0% reduction in total bytes allocated (measured by
valgrind) and 1.3% reduction in peak memory usage (measured by
/usr/bin/time -v).
---------
Co-authored-by: Min-Yih Hsu <min@myhsu.dev>
Diffstat (limited to 'llvm/lib/TableGen/TGParser.cpp')
-rw-r--r-- | llvm/lib/TableGen/TGParser.cpp | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/llvm/lib/TableGen/TGParser.cpp b/llvm/lib/TableGen/TGParser.cpp index 3d914b9..423daf6 100644 --- a/llvm/lib/TableGen/TGParser.cpp +++ b/llvm/lib/TableGen/TGParser.cpp @@ -332,17 +332,10 @@ bool TGParser::AddSubClass(Record *CurRec, SubClassReference &SubClass) { // Since everything went well, we can now set the "superclass" list for the // current record. - for (const auto &[SC, Loc] : SC->getSuperClasses()) { - if (CurRec->isSubClassOf(SC)) - return Error(SubClass.RefRange.Start, - "Already subclass of '" + SC->getName() + "'!\n"); - CurRec->addSuperClass(SC, Loc); - } - if (CurRec->isSubClassOf(SC)) return Error(SubClass.RefRange.Start, "Already subclass of '" + SC->getName() + "'!\n"); - CurRec->addSuperClass(SC, SubClass.RefRange); + CurRec->addDirectSuperClass(SC, SubClass.RefRange); return false; } @@ -4056,7 +4049,7 @@ bool TGParser::ParseClass() { if (CurRec) { // If the body was previously defined, this is an error. if (!CurRec->getValues().empty() || - !CurRec->getSuperClasses().empty() || + !CurRec->getDirectSuperClasses().empty() || !CurRec->getTemplateArgs().empty()) return TokError("Class '" + CurRec->getNameInitAsString() + "' already defined"); |