Skip to content

[TOOLS][UTILS] Added const reference for params with size >= 16 bytes #125082

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

GermanAizek
Copy link

Reference: #125074

Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot
Copy link
Member

llvmbot commented Jan 30, 2025

@llvm/pr-subscribers-testing-tools
@llvm/pr-subscribers-llvm-globalisel
@llvm/pr-subscribers-llvm-binary-utilities

@llvm/pr-subscribers-tablegen

Author: Herman Semenoff (GermanAizek)

Changes

Reference: #125074


Full diff: https://github.com/llvm/llvm-project/pull/125082.diff

18 Files Affected:

  • (modified) llvm/tools/bugpoint/BugDriver.h (+1-1)
  • (modified) llvm/tools/bugpoint/ExtractFunction.cpp (+1-1)
  • (modified) llvm/tools/dsymutil/DwarfLinkerForBinary.cpp (+2-2)
  • (modified) llvm/tools/dsymutil/DwarfLinkerForBinary.h (+2-2)
  • (modified) llvm/tools/llvm-cov/CoverageExporterLcov.cpp (+2-2)
  • (modified) llvm/tools/llvm-exegesis/lib/Assembler.cpp (+1-1)
  • (modified) llvm/tools/llvm-exegesis/lib/Assembler.h (+1-1)
  • (modified) llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp (+3-3)
  • (modified) llvm/tools/llvm-exegesis/lib/BenchmarkResult.h (+5-5)
  • (modified) llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp (+1-1)
  • (modified) llvm/tools/llvm-readobj/COFFDumper.cpp (+1-1)
  • (modified) llvm/tools/llvm-readobj/ELFDumper.cpp (+1-1)
  • (modified) llvm/tools/llvm-readtapi/DiffEngine.cpp (+5-5)
  • (modified) llvm/tools/llvm-readtapi/DiffEngine.h (+1-1)
  • (modified) llvm/utils/FileCheck/FileCheck.cpp (+1-1)
  • (modified) llvm/utils/TableGen/DFAPacketizerEmitter.cpp (+2-2)
  • (modified) llvm/utils/TableGen/DXILEmitter.cpp (+1-1)
  • (modified) llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp (+5-5)
diff --git a/llvm/tools/bugpoint/BugDriver.h b/llvm/tools/bugpoint/BugDriver.h
index e3117ec0ed5367..cc127bdf23d6e5 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<Module> performFinalCleanups(std::unique_ptr<Module> M,
+  std::unique_ptr<Module> performFinalCleanups(const std::unique_ptr<Module> &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 dd9a82c3203596..d9ec6ddd83c02b 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<Module>
-BugDriver::performFinalCleanups(std::unique_ptr<Module> M,
+BugDriver::performFinalCleanups(const std::unique_ptr<Module> &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 f6a35708dc0765..9b10393c2cabed 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 53f9e183ebe88d..6f2ea2db707429 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 d6b9367ae4c514..df3ff9c009b7c1 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 1e97cd24fe0997..52673926103c9f 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<TargetMachine> TM,
+                       const std::unique_ptr<TargetMachine> &TM,
                        ArrayRef<MCRegister> 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 1c8854c21b9a75..186f4e5e14172a 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<void(FunctionFiller &)>;
 // 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<TargetMachine> TM,
+                       const std::unique_ptr<TargetMachine> &TM,
                        ArrayRef<MCRegister> 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 1823a534a301aa..f9add64c692e3f 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
@@ -346,7 +346,7 @@ template <> struct MappingTraits<exegesis::Benchmark::TripleAndCpu> {
 namespace exegesis {
 
 Expected<std::set<Benchmark::TripleAndCpu>>
-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> 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> Benchmark::readYaml(const LLVMState &State,
 }
 
 Expected<std::vector<Benchmark>> Benchmark::readYamls(const LLVMState &State,
-                                                      MemoryBufferRef Buffer) {
+                                                      const MemoryBufferRef &Buffer) {
   yaml::Input Yin(Buffer);
   YamlContext Context(State);
   std::vector<Benchmark> Benchmarks;
diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h
index 7984c8805cadc1..94c91d3aedde46 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<ValidationEvent, int64_t> ValCounters) {
+  Create(const std::string &Key, double Value,
+         const std::map<ValidationEvent, int64_t> &ValCounters) {
     return {Key, Value, Value, Value, ValCounters};
   }
   std::string Key;
@@ -134,10 +134,10 @@ struct Benchmark {
 
   // Read functions.
   static Expected<Benchmark> readYaml(const LLVMState &State,
-                                                 MemoryBufferRef Buffer);
+                                                 const MemoryBufferRef &Buffer);
 
   static Expected<std::vector<Benchmark>>
-  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<std::set<TripleAndCpu>>
-  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 b2362ecb75703b..afe01d33904dc8 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<support::ulittle32_t> HashValues,
+                   const FixedStreamArray<support::ulittle32_t> &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 1666f7692ad5f0..b10c6a45e44b38 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 bfca65aad52b44..f42c66d1c01c66 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -5840,7 +5840,7 @@ struct CoreNote {
   std::vector<CoreFileMapping> Mappings;
 };
 
-static Expected<CoreNote> readCoreNote(DataExtractor Desc) {
+static Expected<CoreNote> 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 6434c871fa64b9..394cf90c679f38 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<InterfaceFileRef> &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<InterfaceFileRef> &IRefVec,
 
 DiffOutput
 getSingleAttrDiff(const std::vector<std::pair<Target, std::string>> &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<std::pair<Target, std::string>> &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<T> &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 58b0c1b3ea9cbf..fe5ae8b6bb36fb 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 9cf3a3164dfecc..70428aa877c0d2 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 a6c0d09f69ba34..cd95face032909 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<const CodeGenProcModel *> &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<const CodeGenProcModel *> &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 70f2aa65226401..34bc470b7a3d6e 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<const Record *> Attrs,
+static bool attrIsDefined(const std::vector<const Record *> &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 770494405810dd..6ca17e9691b336 100644
--- a/llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp
+++ b/llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp
@@ -665,9 +665,9 @@ class CombineRuleBuilder {
   std::optional<LLTCodeGenOrTempType>
   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);

@llvmbot
Copy link
Member

llvmbot commented Jan 30, 2025

@llvm/pr-subscribers-debuginfo

Author: Herman Semenoff (GermanAizek)

Changes

Reference: #125074


Full diff: https://github.com/llvm/llvm-project/pull/125082.diff

18 Files Affected:

  • (modified) llvm/tools/bugpoint/BugDriver.h (+1-1)
  • (modified) llvm/tools/bugpoint/ExtractFunction.cpp (+1-1)
  • (modified) llvm/tools/dsymutil/DwarfLinkerForBinary.cpp (+2-2)
  • (modified) llvm/tools/dsymutil/DwarfLinkerForBinary.h (+2-2)
  • (modified) llvm/tools/llvm-cov/CoverageExporterLcov.cpp (+2-2)
  • (modified) llvm/tools/llvm-exegesis/lib/Assembler.cpp (+1-1)
  • (modified) llvm/tools/llvm-exegesis/lib/Assembler.h (+1-1)
  • (modified) llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp (+3-3)
  • (modified) llvm/tools/llvm-exegesis/lib/BenchmarkResult.h (+5-5)
  • (modified) llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp (+1-1)
  • (modified) llvm/tools/llvm-readobj/COFFDumper.cpp (+1-1)
  • (modified) llvm/tools/llvm-readobj/ELFDumper.cpp (+1-1)
  • (modified) llvm/tools/llvm-readtapi/DiffEngine.cpp (+5-5)
  • (modified) llvm/tools/llvm-readtapi/DiffEngine.h (+1-1)
  • (modified) llvm/utils/FileCheck/FileCheck.cpp (+1-1)
  • (modified) llvm/utils/TableGen/DFAPacketizerEmitter.cpp (+2-2)
  • (modified) llvm/utils/TableGen/DXILEmitter.cpp (+1-1)
  • (modified) llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp (+5-5)
diff --git a/llvm/tools/bugpoint/BugDriver.h b/llvm/tools/bugpoint/BugDriver.h
index e3117ec0ed5367..cc127bdf23d6e5 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<Module> performFinalCleanups(std::unique_ptr<Module> M,
+  std::unique_ptr<Module> performFinalCleanups(const std::unique_ptr<Module> &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 dd9a82c3203596..d9ec6ddd83c02b 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<Module>
-BugDriver::performFinalCleanups(std::unique_ptr<Module> M,
+BugDriver::performFinalCleanups(const std::unique_ptr<Module> &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 f6a35708dc0765..9b10393c2cabed 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 53f9e183ebe88d..6f2ea2db707429 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 d6b9367ae4c514..df3ff9c009b7c1 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 1e97cd24fe0997..52673926103c9f 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<TargetMachine> TM,
+                       const std::unique_ptr<TargetMachine> &TM,
                        ArrayRef<MCRegister> 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 1c8854c21b9a75..186f4e5e14172a 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<void(FunctionFiller &)>;
 // 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<TargetMachine> TM,
+                       const std::unique_ptr<TargetMachine> &TM,
                        ArrayRef<MCRegister> 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 1823a534a301aa..f9add64c692e3f 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
@@ -346,7 +346,7 @@ template <> struct MappingTraits<exegesis::Benchmark::TripleAndCpu> {
 namespace exegesis {
 
 Expected<std::set<Benchmark::TripleAndCpu>>
-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> 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> Benchmark::readYaml(const LLVMState &State,
 }
 
 Expected<std::vector<Benchmark>> Benchmark::readYamls(const LLVMState &State,
-                                                      MemoryBufferRef Buffer) {
+                                                      const MemoryBufferRef &Buffer) {
   yaml::Input Yin(Buffer);
   YamlContext Context(State);
   std::vector<Benchmark> Benchmarks;
diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h
index 7984c8805cadc1..94c91d3aedde46 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<ValidationEvent, int64_t> ValCounters) {
+  Create(const std::string &Key, double Value,
+         const std::map<ValidationEvent, int64_t> &ValCounters) {
     return {Key, Value, Value, Value, ValCounters};
   }
   std::string Key;
@@ -134,10 +134,10 @@ struct Benchmark {
 
   // Read functions.
   static Expected<Benchmark> readYaml(const LLVMState &State,
-                                                 MemoryBufferRef Buffer);
+                                                 const MemoryBufferRef &Buffer);
 
   static Expected<std::vector<Benchmark>>
-  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<std::set<TripleAndCpu>>
-  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 b2362ecb75703b..afe01d33904dc8 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<support::ulittle32_t> HashValues,
+                   const FixedStreamArray<support::ulittle32_t> &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 1666f7692ad5f0..b10c6a45e44b38 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 bfca65aad52b44..f42c66d1c01c66 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -5840,7 +5840,7 @@ struct CoreNote {
   std::vector<CoreFileMapping> Mappings;
 };
 
-static Expected<CoreNote> readCoreNote(DataExtractor Desc) {
+static Expected<CoreNote> 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 6434c871fa64b9..394cf90c679f38 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<InterfaceFileRef> &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<InterfaceFileRef> &IRefVec,
 
 DiffOutput
 getSingleAttrDiff(const std::vector<std::pair<Target, std::string>> &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<std::pair<Target, std::string>> &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<T> &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 58b0c1b3ea9cbf..fe5ae8b6bb36fb 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 9cf3a3164dfecc..70428aa877c0d2 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 a6c0d09f69ba34..cd95face032909 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<const CodeGenProcModel *> &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<const CodeGenProcModel *> &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 70f2aa65226401..34bc470b7a3d6e 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<const Record *> Attrs,
+static bool attrIsDefined(const std::vector<const Record *> &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 770494405810dd..6ca17e9691b336 100644
--- a/llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp
+++ b/llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp
@@ -665,9 +665,9 @@ class CombineRuleBuilder {
   std::optional<LLTCodeGenOrTempType>
   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);

@llvmbot
Copy link
Member

llvmbot commented Jan 30, 2025

@llvm/pr-subscribers-backend-directx

Author: Herman Semenoff (GermanAizek)

Changes

Reference: #125074


Full diff: https://github.com/llvm/llvm-project/pull/125082.diff

18 Files Affected:

  • (modified) llvm/tools/bugpoint/BugDriver.h (+1-1)
  • (modified) llvm/tools/bugpoint/ExtractFunction.cpp (+1-1)
  • (modified) llvm/tools/dsymutil/DwarfLinkerForBinary.cpp (+2-2)
  • (modified) llvm/tools/dsymutil/DwarfLinkerForBinary.h (+2-2)
  • (modified) llvm/tools/llvm-cov/CoverageExporterLcov.cpp (+2-2)
  • (modified) llvm/tools/llvm-exegesis/lib/Assembler.cpp (+1-1)
  • (modified) llvm/tools/llvm-exegesis/lib/Assembler.h (+1-1)
  • (modified) llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp (+3-3)
  • (modified) llvm/tools/llvm-exegesis/lib/BenchmarkResult.h (+5-5)
  • (modified) llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp (+1-1)
  • (modified) llvm/tools/llvm-readobj/COFFDumper.cpp (+1-1)
  • (modified) llvm/tools/llvm-readobj/ELFDumper.cpp (+1-1)
  • (modified) llvm/tools/llvm-readtapi/DiffEngine.cpp (+5-5)
  • (modified) llvm/tools/llvm-readtapi/DiffEngine.h (+1-1)
  • (modified) llvm/utils/FileCheck/FileCheck.cpp (+1-1)
  • (modified) llvm/utils/TableGen/DFAPacketizerEmitter.cpp (+2-2)
  • (modified) llvm/utils/TableGen/DXILEmitter.cpp (+1-1)
  • (modified) llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp (+5-5)
diff --git a/llvm/tools/bugpoint/BugDriver.h b/llvm/tools/bugpoint/BugDriver.h
index e3117ec0ed5367..cc127bdf23d6e5 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<Module> performFinalCleanups(std::unique_ptr<Module> M,
+  std::unique_ptr<Module> performFinalCleanups(const std::unique_ptr<Module> &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 dd9a82c3203596..d9ec6ddd83c02b 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<Module>
-BugDriver::performFinalCleanups(std::unique_ptr<Module> M,
+BugDriver::performFinalCleanups(const std::unique_ptr<Module> &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 f6a35708dc0765..9b10393c2cabed 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 53f9e183ebe88d..6f2ea2db707429 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 d6b9367ae4c514..df3ff9c009b7c1 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 1e97cd24fe0997..52673926103c9f 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<TargetMachine> TM,
+                       const std::unique_ptr<TargetMachine> &TM,
                        ArrayRef<MCRegister> 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 1c8854c21b9a75..186f4e5e14172a 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<void(FunctionFiller &)>;
 // 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<TargetMachine> TM,
+                       const std::unique_ptr<TargetMachine> &TM,
                        ArrayRef<MCRegister> 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 1823a534a301aa..f9add64c692e3f 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
@@ -346,7 +346,7 @@ template <> struct MappingTraits<exegesis::Benchmark::TripleAndCpu> {
 namespace exegesis {
 
 Expected<std::set<Benchmark::TripleAndCpu>>
-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> 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> Benchmark::readYaml(const LLVMState &State,
 }
 
 Expected<std::vector<Benchmark>> Benchmark::readYamls(const LLVMState &State,
-                                                      MemoryBufferRef Buffer) {
+                                                      const MemoryBufferRef &Buffer) {
   yaml::Input Yin(Buffer);
   YamlContext Context(State);
   std::vector<Benchmark> Benchmarks;
diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h
index 7984c8805cadc1..94c91d3aedde46 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<ValidationEvent, int64_t> ValCounters) {
+  Create(const std::string &Key, double Value,
+         const std::map<ValidationEvent, int64_t> &ValCounters) {
     return {Key, Value, Value, Value, ValCounters};
   }
   std::string Key;
@@ -134,10 +134,10 @@ struct Benchmark {
 
   // Read functions.
   static Expected<Benchmark> readYaml(const LLVMState &State,
-                                                 MemoryBufferRef Buffer);
+                                                 const MemoryBufferRef &Buffer);
 
   static Expected<std::vector<Benchmark>>
-  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<std::set<TripleAndCpu>>
-  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 b2362ecb75703b..afe01d33904dc8 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<support::ulittle32_t> HashValues,
+                   const FixedStreamArray<support::ulittle32_t> &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 1666f7692ad5f0..b10c6a45e44b38 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 bfca65aad52b44..f42c66d1c01c66 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -5840,7 +5840,7 @@ struct CoreNote {
   std::vector<CoreFileMapping> Mappings;
 };
 
-static Expected<CoreNote> readCoreNote(DataExtractor Desc) {
+static Expected<CoreNote> 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 6434c871fa64b9..394cf90c679f38 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<InterfaceFileRef> &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<InterfaceFileRef> &IRefVec,
 
 DiffOutput
 getSingleAttrDiff(const std::vector<std::pair<Target, std::string>> &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<std::pair<Target, std::string>> &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<T> &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 58b0c1b3ea9cbf..fe5ae8b6bb36fb 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 9cf3a3164dfecc..70428aa877c0d2 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 a6c0d09f69ba34..cd95face032909 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<const CodeGenProcModel *> &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<const CodeGenProcModel *> &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 70f2aa65226401..34bc470b7a3d6e 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<const Record *> Attrs,
+static bool attrIsDefined(const std::vector<const Record *> &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 770494405810dd..6ca17e9691b336 100644
--- a/llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp
+++ b/llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp
@@ -665,9 +665,9 @@ class CombineRuleBuilder {
   std::optional<LLTCodeGenOrTempType>
   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);

@@ -183,7 +183,7 @@ class BugDriver {
/// MayModifySemantics argument is true, then the cleanups is allowed to
/// modify how the code behaves.
///
std::unique_ptr<Module> performFinalCleanups(std::unique_ptr<Module> M,
std::unique_ptr<Module> performFinalCleanups(const std::unique_ptr<Module> &M,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing unique_ptr by value or const reference are both suspect. I would expect this to take const Module&

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

3 participants