Index: llvm/include/llvm/TableGen/Record.h =================================================================== --- llvm/include/llvm/TableGen/Record.h +++ llvm/include/llvm/TableGen/Record.h @@ -1804,7 +1804,7 @@ /// Get all the concrete records that inherit from the one specified /// class. The class must be defined. - std::vector getAllDerivedDefinitions(StringRef ClassName) const; + const std::vector &getAllDerivedDefinitions(StringRef ClassName) const; /// Get all the concrete records that inherit from all the specified /// classes. The classes must be defined. Index: llvm/lib/TableGen/Record.cpp =================================================================== --- llvm/lib/TableGen/Record.cpp +++ llvm/lib/TableGen/Record.cpp @@ -2598,7 +2598,7 @@ // We cache the record vectors for single classes. Many backends request // the same vectors multiple times. -std::vector RecordKeeper::getAllDerivedDefinitions( +const std::vector &RecordKeeper::getAllDerivedDefinitions( StringRef ClassName) const { auto Pair = ClassRecordsMap.try_emplace(ClassName); Index: llvm/utils/TableGen/AsmMatcherEmitter.cpp =================================================================== --- llvm/utils/TableGen/AsmMatcherEmitter.cpp +++ llvm/utils/TableGen/AsmMatcherEmitter.cpp @@ -1344,7 +1344,7 @@ } void AsmMatcherInfo::buildOperandClasses() { - std::vector AsmOperands = + const std::vector &AsmOperands = Records.getAllDerivedDefinitions("AsmOperandClass"); // Pre-populate AsmOperandClasses map. @@ -1530,7 +1530,7 @@ // Parse all of the InstAlias definitions and stick them in the list of // matchables. - std::vector AllInstAliases = + const std::vector &AllInstAliases = Records.getAllDerivedDefinitions("InstAlias"); for (unsigned i = 0, e = AllInstAliases.size(); i != e; ++i) { auto Alias = std::make_unique(AllInstAliases[i], @@ -1639,7 +1639,7 @@ // Process token alias definitions and set up the associated superclass // information. - std::vector AllTokenAliases = + const std::vector &AllTokenAliases = Records.getAllDerivedDefinitions("TokenAlias"); for (Record *Rec : AllTokenAliases) { ClassInfo *FromClass = getTokenClass(Rec->getValueAsString("FromToken")); @@ -2717,7 +2717,7 @@ } static void emitMnemonicAliasVariant(raw_ostream &OS,const AsmMatcherInfo &Info, - std::vector &Aliases, + const std::vector &Aliases, unsigned Indent = 0, StringRef AsmParserVariantName = StringRef()){ // Keep track of all the aliases from a mnemonic. Use an std::map so that the @@ -2799,7 +2799,7 @@ if (!MatchPrefix.empty()) return false; - std::vector Aliases = + const std::vector &Aliases = Info.getRecords().getAllDerivedDefinitions("MnemonicAlias"); if (Aliases.empty()) return false; Index: llvm/utils/TableGen/Attributes.cpp =================================================================== --- llvm/utils/TableGen/Attributes.cpp +++ llvm/utils/TableGen/Attributes.cpp @@ -69,7 +69,7 @@ << " const Function &Callee) {\n"; OS << " bool Ret = true;\n\n"; - std::vector CompatRules = + const std::vector &CompatRules = Records.getAllDerivedDefinitions("CompatRule"); for (auto *Rule : CompatRules) { @@ -81,7 +81,7 @@ OS << " return Ret;\n"; OS << "}\n\n"; - std::vector MergeRules = + const std::vector &MergeRules = Records.getAllDerivedDefinitions("MergeRule"); OS << "static inline void mergeFnAttrs(Function &Caller,\n" << " const Function &Callee) {\n"; Index: llvm/utils/TableGen/CallingConvEmitter.cpp =================================================================== --- llvm/utils/TableGen/CallingConvEmitter.cpp +++ llvm/utils/TableGen/CallingConvEmitter.cpp @@ -34,7 +34,8 @@ } // End anonymous namespace void CallingConvEmitter::run(raw_ostream &O) { - std::vector CCs = Records.getAllDerivedDefinitions("CallingConv"); + const std::vector &CCs = + Records.getAllDerivedDefinitions("CallingConv"); // Emit prototypes for all of the non-custom CC's so that they can forward ref // each other. Index: llvm/utils/TableGen/CodeEmitterGen.cpp =================================================================== --- llvm/utils/TableGen/CodeEmitterGen.cpp +++ llvm/utils/TableGen/CodeEmitterGen.cpp @@ -388,7 +388,8 @@ void CodeEmitterGen::run(raw_ostream &o) { CodeGenTarget Target(Records); - std::vector Insts = Records.getAllDerivedDefinitions("Instruction"); + const std::vector &Insts = + Records.getAllDerivedDefinitions("Instruction"); // For little-endian instruction bit encodings, reverse the bit order Target.reverseBitsForLittleEndianEncoding(); @@ -461,7 +462,7 @@ std::map> CaseMap; // Construct all cases statement for each opcode - for (std::vector::iterator IC = Insts.begin(), EC = Insts.end(); + for (std::vector::const_iterator IC = Insts.begin(), EC = Insts.end(); IC != EC; ++IC) { Record *R = *IC; if (R->getValueAsString("Namespace") == "TargetOpcode" || Index: mlir/tools/mlir-tblgen/OpInterfacesGen.cpp =================================================================== --- mlir/tools/mlir-tblgen/OpInterfacesGen.cpp +++ mlir/tools/mlir-tblgen/OpInterfacesGen.cpp @@ -77,8 +77,10 @@ bool emitInterfaceDocs(); protected: - InterfaceGenerator(std::vector &&defs, raw_ostream &os) - : defs(std::move(defs)), os(os) {} + InterfaceGenerator(const std::vector &defs, raw_ostream &os) + : defs(defs), os(os) {} +//// InterfaceGenerator(std::vector &&defs, raw_ostream &os) +//// : defs(std::move(defs)), os(os) {} void emitConceptDecl(Interface &interface); void emitModelDecl(Interface &interface);