Index: include/llvm/TableGen/Record.h =================================================================== --- include/llvm/TableGen/Record.h +++ include/llvm/TableGen/Record.h @@ -1525,12 +1525,13 @@ }; class RecordKeeper { - using RecordMap = std::map>; + using RecordMap = StringMap>; RecordMap Classes, Defs; + std::vector ClassesV, DefsV; public: - const RecordMap &getClasses() const { return Classes; } - const RecordMap &getDefs() const { return Defs; } + const std::vector &getClasses() const { return ClassesV; } + const std::vector &getDefs() const { return DefsV; } Record *getClass(StringRef Name) const { auto I = Classes.find(Name); @@ -1543,6 +1544,7 @@ } void addClass(std::unique_ptr R) { + ClassesV.push_back(R.get()); bool Ins = Classes.insert(std::make_pair(R->getName(), std::move(R))).second; (void)Ins; @@ -1550,6 +1552,7 @@ } void addDef(std::unique_ptr R) { + DefsV.push_back(R.get()); bool Ins = Defs.insert(std::make_pair(R->getName(), std::move(R))).second; (void)Ins; Index: lib/TableGen/Record.cpp =================================================================== --- lib/TableGen/Record.cpp +++ lib/TableGen/Record.cpp @@ -1869,12 +1869,12 @@ raw_ostream &llvm::operator<<(raw_ostream &OS, const RecordKeeper &RK) { OS << "------------- Classes -----------------\n"; - for (const auto &C : RK.getClasses()) - OS << "class " << *C.second; + for (Record *R : RK.getClasses()) + OS << "class " << *R; OS << "------------- Defs -----------------\n"; - for (const auto &D : RK.getDefs()) - OS << "def " << *D.second; + for (Record *R : RK.getClasses()) + OS << "def " << *R; return OS; } @@ -1884,10 +1884,10 @@ if (!Class) PrintFatalError("ERROR: Couldn't find the `" + ClassName + "' class!\n"); - std::vector Defs; - for (const auto &D : getDefs()) - if (D.second->isSubClassOf(Class)) - Defs.push_back(D.second.get()); + std::vector Defs; + for (Record *R : getDefs()) + if (R->isSubClassOf(Class)) + Defs.push_back(R); return Defs; } Index: utils/TableGen/CTagsEmitter.cpp =================================================================== --- utils/TableGen/CTagsEmitter.cpp +++ utils/TableGen/CTagsEmitter.cpp @@ -69,9 +69,9 @@ // Collect tags. Tags.reserve(Classes.size() + Defs.size()); for (const auto &C : Classes) - Tags.push_back(Tag(C.first, locate(C.second.get()))); + Tags.push_back(Tag(C->getName(), locate(C))); for (const auto &D : Defs) - Tags.push_back(Tag(D.first, locate(D.second.get()))); + Tags.push_back(Tag(D->getName(), locate(D))); // Emit tags. std::sort(Tags.begin(), Tags.end()); OS << "!_TAG_FILE_FORMAT\t1\t/original ctags format/\n"; Index: utils/TableGen/PseudoLoweringEmitter.cpp =================================================================== --- utils/TableGen/PseudoLoweringEmitter.cpp +++ utils/TableGen/PseudoLoweringEmitter.cpp @@ -276,12 +276,10 @@ assert(ExpansionClass && "PseudoInstExpansion class definition missing!"); assert(InstructionClass && "Instruction class definition missing!"); - std::vector Insts; - for (const auto &D : Records.getDefs()) { - if (D.second->isSubClassOf(ExpansionClass) && - D.second->isSubClassOf(InstructionClass)) - Insts.push_back(D.second.get()); - } + std::vector Insts; + for (Record *R : Records.getDefs()) + if (R->isSubClassOf(ExpansionClass) && R->isSubClassOf(InstructionClass)) + Insts.push_back(R); // Process the pseudo expansion definitions, validating them as we do so. for (unsigned i = 0, e = Insts.size(); i != e; ++i) Index: utils/TableGen/SearchableTableEmitter.cpp =================================================================== --- utils/TableGen/SearchableTableEmitter.cpp +++ utils/TableGen/SearchableTableEmitter.cpp @@ -302,8 +302,7 @@ void SearchableTableEmitter::run(raw_ostream &OS) { // Tables are defined to be the direct descendents of "SearchableEntry". Record *SearchableTable = Records.getClass("SearchableTable"); - for (auto &NameRec : Records.getClasses()) { - Record *Class = NameRec.second.get(); + for (Record *Class : Records.getClasses()) { if (Class->getSuperClasses().size() != 1 || !Class->isSubClassOf(SearchableTable)) continue;