diff --git a/llvm/tools/bugpoint/BugDriver.h b/llvm/tools/bugpoint/BugDriver.h index e3117ec0ed536..cc127bdf23d6e 100644 --- a/llvm/tools/bugpoint/BugDriver.h +++ b/llvm/tools/bugpoint/BugDriver.h @@ -183,7 +183,7 @@ class BugDriver { /// MayModifySemantics argument is true, then the cleanups is allowed to /// modify how the code behaves. /// - std::unique_ptr performFinalCleanups(std::unique_ptr M, + std::unique_ptr performFinalCleanups(const std::unique_ptr &M, bool MayModifySemantics = false); /// Given a module, extract up to one loop from it into a new function. This diff --git a/llvm/tools/bugpoint/ExtractFunction.cpp b/llvm/tools/bugpoint/ExtractFunction.cpp index dd9a82c320359..d9ec6ddd83c02 100644 --- a/llvm/tools/bugpoint/ExtractFunction.cpp +++ b/llvm/tools/bugpoint/ExtractFunction.cpp @@ -126,7 +126,7 @@ BugDriver::deleteInstructionFromProgram(const Instruction *I, } std::unique_ptr -BugDriver::performFinalCleanups(std::unique_ptr M, +BugDriver::performFinalCleanups(const std::unique_ptr &M, bool MayModifySemantics) { // Make all functions external, so GlobalDCE doesn't delete them... for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) diff --git a/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp b/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp index f6a35708dc076..9b10393c2cabe 100644 --- a/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp +++ b/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp @@ -119,7 +119,7 @@ static void dumpDIE(const DWARFDie *DIE, bool Verbose) { /// Report a warning to the user, optionally including information about a /// specific \p DIE related to the warning. -void DwarfLinkerForBinary::reportWarning(Twine Warning, Twine Context, +void DwarfLinkerForBinary::reportWarning(const Twine &Warning, const Twine &Context, const DWARFDie *DIE) const { // FIXME: implement warning logging which does not block other threads. if (ErrorHandlerMutex.try_lock()) { @@ -129,7 +129,7 @@ void DwarfLinkerForBinary::reportWarning(Twine Warning, Twine Context, } } -void DwarfLinkerForBinary::reportError(Twine Error, Twine Context, +void DwarfLinkerForBinary::reportError(const Twine &Error, const Twine &Context, const DWARFDie *DIE) const { // FIXME: implement error logging which does not block other threads. if (ErrorHandlerMutex.try_lock()) { diff --git a/llvm/tools/dsymutil/DwarfLinkerForBinary.h b/llvm/tools/dsymutil/DwarfLinkerForBinary.h index 53f9e183ebe88..6f2ea2db70742 100644 --- a/llvm/tools/dsymutil/DwarfLinkerForBinary.h +++ b/llvm/tools/dsymutil/DwarfLinkerForBinary.h @@ -80,9 +80,9 @@ class DwarfLinkerForBinary { /// Link the contents of the DebugMap. bool link(const DebugMap &); - void reportWarning(Twine Warning, Twine Context = {}, + void reportWarning(const Twine &Warning, const Twine &Context = {}, const DWARFDie *DIE = nullptr) const; - void reportError(Twine Error, Twine Context = {}, + void reportError(const Twine &Error, const Twine &Context = {}, const DWARFDie *DIE = nullptr) const; /// Returns true if input verification is enabled and verification errors were diff --git a/llvm/tools/llvm-cov/CoverageExporterLcov.cpp b/llvm/tools/llvm-cov/CoverageExporterLcov.cpp index d6b9367ae4c51..df3ff9c009b7c 100644 --- a/llvm/tools/llvm-cov/CoverageExporterLcov.cpp +++ b/llvm/tools/llvm-cov/CoverageExporterLcov.cpp @@ -105,8 +105,8 @@ collectNestedBranches(const coverage::CoverageMapping &Coverage, return Branches; } -bool sortLine(llvm::coverage::CountedRegion I, - llvm::coverage::CountedRegion J) { +bool sortLine(const llvm::coverage::CountedRegion &I, + const llvm::coverage::CountedRegion &J) { return (I.LineStart < J.LineStart) || ((I.LineStart == J.LineStart) && (I.ColumnStart < J.ColumnStart)); } diff --git a/llvm/tools/llvm-exegesis/lib/Assembler.cpp b/llvm/tools/llvm-exegesis/lib/Assembler.cpp index 1e97cd24fe099..52673926103c9 100644 --- a/llvm/tools/llvm-exegesis/lib/Assembler.cpp +++ b/llvm/tools/llvm-exegesis/lib/Assembler.cpp @@ -240,7 +240,7 @@ BitVector getFunctionReservedRegs(const TargetMachine &TM) { } Error assembleToStream(const ExegesisTarget &ET, - std::unique_ptr TM, + const std::unique_ptr &TM, ArrayRef LiveIns, const FillFunction &Fill, raw_pwrite_stream &AsmStream, const BenchmarkKey &Key, bool GenerateMemoryInstructions) { diff --git a/llvm/tools/llvm-exegesis/lib/Assembler.h b/llvm/tools/llvm-exegesis/lib/Assembler.h index 1c8854c21b9a7..186f4e5e14172 100644 --- a/llvm/tools/llvm-exegesis/lib/Assembler.h +++ b/llvm/tools/llvm-exegesis/lib/Assembler.h @@ -89,7 +89,7 @@ using FillFunction = std::function; // epilogue. Once the MachineFunction is ready, it is assembled for TM to // AsmStream, the temporary function is eventually discarded. Error assembleToStream(const ExegesisTarget &ET, - std::unique_ptr TM, + const std::unique_ptr &TM, ArrayRef LiveIns, const FillFunction &Fill, raw_pwrite_stream &AsmStreamm, const BenchmarkKey &Key, bool GenerateMemoryInstructions); diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp index 1823a534a301a..f9add64c692e3 100644 --- a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp +++ b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp @@ -346,7 +346,7 @@ template <> struct MappingTraits { namespace exegesis { Expected> -Benchmark::readTriplesAndCpusFromYamls(MemoryBufferRef Buffer) { +Benchmark::readTriplesAndCpusFromYamls(const MemoryBufferRef &Buffer) { // We're only mapping a field, drop other fields and silence the corresponding // warnings. yaml::Input Yin(Buffer, nullptr, +[](const SMDiagnostic &, void *Context) {}); @@ -365,7 +365,7 @@ Benchmark::readTriplesAndCpusFromYamls(MemoryBufferRef Buffer) { } Expected Benchmark::readYaml(const LLVMState &State, - MemoryBufferRef Buffer) { + const MemoryBufferRef &Buffer) { yaml::Input Yin(Buffer); YamlContext Context(State); Benchmark Benchmark; @@ -377,7 +377,7 @@ Expected Benchmark::readYaml(const LLVMState &State, } Expected> Benchmark::readYamls(const LLVMState &State, - MemoryBufferRef Buffer) { + const MemoryBufferRef &Buffer) { yaml::Input Yin(Buffer); YamlContext Context(State); std::vector Benchmarks; diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h index 7984c8805cadc..94c91d3aedde4 100644 --- a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h +++ b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h @@ -81,8 +81,8 @@ struct BenchmarkKey { struct BenchmarkMeasure { // A helper to create an unscaled BenchmarkMeasure. static BenchmarkMeasure - Create(std::string Key, double Value, - std::map ValCounters) { + Create(const std::string &Key, double Value, + const std::map &ValCounters) { return {Key, Value, Value, Value, ValCounters}; } std::string Key; @@ -134,10 +134,10 @@ struct Benchmark { // Read functions. static Expected readYaml(const LLVMState &State, - MemoryBufferRef Buffer); + const MemoryBufferRef &Buffer); static Expected> - readYamls(const LLVMState &State, MemoryBufferRef Buffer); + readYamls(const LLVMState &State, const MemoryBufferRef &Buffer); // Given a set of serialized instruction benchmarks, returns the set of // triples and CPUs that appear in the list of benchmarks. @@ -149,7 +149,7 @@ struct Benchmark { } }; static Expected> - readTriplesAndCpusFromYamls(MemoryBufferRef Buffer); + readTriplesAndCpusFromYamls(const MemoryBufferRef &Buffer); class Error readYamlFrom(const LLVMState &State, StringRef InputContent); diff --git a/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp b/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp index b2362ecb75703..afe01d33904dc 100644 --- a/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp +++ b/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp @@ -1201,7 +1201,7 @@ static void dumpFullTypeStream(LinePrinter &Printer, LazyRandomTypeCollection &Types, TypeReferenceTracker *RefTracker, uint32_t NumTypeRecords, uint32_t NumHashBuckets, - FixedStreamArray HashValues, + const FixedStreamArray &HashValues, TpiStream *Stream, bool Bytes, bool Extras) { Printer.formatLine("Showing {0:N} records", NumTypeRecords); diff --git a/llvm/tools/llvm-readobj/COFFDumper.cpp b/llvm/tools/llvm-readobj/COFFDumper.cpp index 1666f7692ad5f..b10c6a45e44b3 100644 --- a/llvm/tools/llvm-readobj/COFFDumper.cpp +++ b/llvm/tools/llvm-readobj/COFFDumper.cpp @@ -134,7 +134,7 @@ class COFFDumper : public ObjDumper { void printCodeViewTypeSection(StringRef SectionName, const SectionRef &Section); StringRef getFileNameForFileOffset(uint32_t FileOffset); void printFileNameForOffset(StringRef Label, uint32_t FileOffset); - void printTypeIndex(StringRef FieldName, TypeIndex TI) { + void printTypeIndex(StringRef FieldName, const TypeIndex &TI) { // Forward to CVTypeDumper for simplicity. codeview::printTypeIndex(Writer, FieldName, TI, Types); } diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp index bfca65aad52b4..f42c66d1c01c6 100644 --- a/llvm/tools/llvm-readobj/ELFDumper.cpp +++ b/llvm/tools/llvm-readobj/ELFDumper.cpp @@ -5840,7 +5840,7 @@ struct CoreNote { std::vector Mappings; }; -static Expected readCoreNote(DataExtractor Desc) { +static Expected readCoreNote(const DataExtractor &Desc) { // Expected format of the NT_FILE note description: // 1. # of file mappings (call it N) // 2. Page size diff --git a/llvm/tools/llvm-readtapi/DiffEngine.cpp b/llvm/tools/llvm-readtapi/DiffEngine.cpp index 6434c871fa64b..394cf90c679f3 100644 --- a/llvm/tools/llvm-readtapi/DiffEngine.cpp +++ b/llvm/tools/llvm-readtapi/DiffEngine.cpp @@ -98,7 +98,7 @@ std::string SymScalar::getFlagString(const MachO::Symbol *Sym) { return std::string(Flags); } -void SymScalar::print(raw_ostream &OS, std::string Indent, MachO::Target Targ) { +void SymScalar::print(raw_ostream &OS, const std::string &Indent, const MachO::Target &Targ) { if (Val->getKind() == MachO::EncodeKind::ObjectiveCClass) { if (Targ.Arch == MachO::AK_i386 && Targ.Platform == MachO::PLATFORM_MACOS) { OS << Indent << "\t\t" << ((Order == lhs) ? "< " : "> ") @@ -144,7 +144,7 @@ void addDiffForTargSlice(V Val, Target Targ, DiffOutput &Diff, } DiffOutput getSingleAttrDiff(const std::vector &IRefVec, - std::string Name, InterfaceInputOrder Order) { + const std::string &Name, InterfaceInputOrder Order) { DiffOutput Diff(Name); Diff.Kind = AD_Str_Vec; for (const auto &IRef : IRefVec) @@ -157,7 +157,7 @@ DiffOutput getSingleAttrDiff(const std::vector &IRefVec, DiffOutput getSingleAttrDiff(const std::vector> &PairVec, - std::string Name, InterfaceInputOrder Order) { + const std::string &Name, InterfaceInputOrder Order) { DiffOutput Diff(Name); Diff.Kind = AD_Str_Vec; for (const auto &Pair : PairVec) @@ -168,7 +168,7 @@ getSingleAttrDiff(const std::vector> &PairVec, } DiffOutput getSingleAttrDiff(InterfaceFile::const_symbol_range SymRange, - std::string Name, InterfaceInputOrder Order) { + const std::string &Name, InterfaceInputOrder Order) { DiffOutput Diff(Name); Diff.Kind = AD_Sym_Vec; for (const auto *Sym : SymRange) @@ -305,7 +305,7 @@ DiffOutput recordDifferences(const std::vector &LHS, DiffOutput recordDifferences(llvm::MachO::InterfaceFile::const_symbol_range LHS, llvm::MachO::InterfaceFile::const_symbol_range RHS, - std::string Attr) { + const std::string &Attr) { DiffOutput Diff(Attr); Diff.Kind = AD_Sym_Vec; findAndAddDiff(LHS, RHS, Diff, lhs); diff --git a/llvm/tools/llvm-readtapi/DiffEngine.h b/llvm/tools/llvm-readtapi/DiffEngine.h index 58b0c1b3ea9cb..fe5ae8b6bb36f 100644 --- a/llvm/tools/llvm-readtapi/DiffEngine.h +++ b/llvm/tools/llvm-readtapi/DiffEngine.h @@ -85,7 +85,7 @@ class SymScalar { std::string getFlagString(const MachO::Symbol *Sym); - void print(raw_ostream &OS, std::string Indent, MachO::Target Targ); + void print(raw_ostream &OS, const std::string &Indent, const MachO::Target &Targ); const MachO::Symbol *getVal() const { return Val; } InterfaceInputOrder getOrder() const { return Order; } diff --git a/llvm/utils/FileCheck/FileCheck.cpp b/llvm/utils/FileCheck/FileCheck.cpp index 9cf3a3164dfec..70428aa877c0d 100644 --- a/llvm/utils/FileCheck/FileCheck.cpp +++ b/llvm/utils/FileCheck/FileCheck.cpp @@ -343,7 +343,7 @@ struct InputAnnotation { }; /// Get an abbreviation for the check type. -static std::string GetCheckTypeAbbreviation(Check::FileCheckType Ty) { +static std::string GetCheckTypeAbbreviation(const Check::FileCheckType &Ty) { switch (Ty) { case Check::CheckPlain: if (Ty.getCount() > 1) diff --git a/llvm/utils/TableGen/DFAPacketizerEmitter.cpp b/llvm/utils/TableGen/DFAPacketizerEmitter.cpp index a6c0d09f69ba3..cd95face03290 100644 --- a/llvm/utils/TableGen/DFAPacketizerEmitter.cpp +++ b/llvm/utils/TableGen/DFAPacketizerEmitter.cpp @@ -85,7 +85,7 @@ class DFAPacketizerEmitter { // Emit code for a subset of itineraries. void emitForItineraries(raw_ostream &OS, std::vector &ProcItinList, - std::string DFAName); + const std::string &DFAName); void run(raw_ostream &OS); }; @@ -231,7 +231,7 @@ void DFAPacketizerEmitter::run(raw_ostream &OS) { void DFAPacketizerEmitter::emitForItineraries( raw_ostream &OS, std::vector &ProcModels, - std::string DFAName) { + const std::string &DFAName) { OS << "} // end namespace llvm\n\n"; OS << "namespace {\n"; collectAllFuncUnits(ProcModels); diff --git a/llvm/utils/TableGen/DXILEmitter.cpp b/llvm/utils/TableGen/DXILEmitter.cpp index 70f2aa6522640..34bc470b7a3d6 100644 --- a/llvm/utils/TableGen/DXILEmitter.cpp +++ b/llvm/utils/TableGen/DXILEmitter.cpp @@ -374,7 +374,7 @@ static void emitDXILAttributes(const RecordKeeper &Records, raw_ostream &OS) { // Helper function to determine if the given Attr is defined in the vector // Attrs, by comparing the names -static bool attrIsDefined(std::vector Attrs, +static bool attrIsDefined(const std::vector &Attrs, const Record *Attr) { for (auto CurAttr : Attrs) if (CurAttr->getName() == Attr->getName()) diff --git a/llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp b/llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp index 770494405810d..6ca17e9691b33 100644 --- a/llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp +++ b/llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp @@ -665,9 +665,9 @@ class CombineRuleBuilder { std::optional getLLTCodeGenOrTempType(const PatternType &PT, RuleMatcher &RM); - void PrintError(Twine Msg) const { ::PrintError(&RuleDef, Msg); } - void PrintWarning(Twine Msg) const { ::PrintWarning(RuleDef.getLoc(), Msg); } - void PrintNote(Twine Msg) const { ::PrintNote(RuleDef.getLoc(), Msg); } + void PrintError(const Twine &Msg) const { ::PrintError(&RuleDef, Msg); } + void PrintWarning(const Twine &Msg) const { ::PrintWarning(RuleDef.getLoc(), Msg); } + void PrintNote(const Twine &Msg) const { ::PrintNote(RuleDef.getLoc(), Msg); } void print(raw_ostream &OS, const PatternAlternatives &Alts) const; @@ -710,7 +710,7 @@ class CombineRuleBuilder { /// \param AdditionalComment Comment string to be added to the /// `DebugCommentAction`. RuleMatcher &addRuleMatcher(const PatternAlternatives &Alts, - Twine AdditionalComment = ""); + const Twine &AdditionalComment = ""); bool addFeaturePredicates(RuleMatcher &M); bool findRoots(); @@ -1350,7 +1350,7 @@ bool CombineRuleBuilder::checkSemantics() { } RuleMatcher &CombineRuleBuilder::addRuleMatcher(const PatternAlternatives &Alts, - Twine AdditionalComment) { + const Twine &AdditionalComment) { auto &RM = OutRMs.emplace_back(RuleDef.getLoc()); addFeaturePredicates(RM); RM.setPermanentGISelFlags(GISF_IgnoreCopies);