Skip to content

Added const reference for params wth size >= 16 bytes #125074

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 8 commits into
base: main
Choose a base branch
from

Conversation

GermanAizek
Copy link

For better optimized code generation functions calls by compiler, objects sizes equal to or greater than 16 bytes must be pass by constant reference. A constant reference is also useful as refactoring technique that indicates that param is a constant.

Reference: https://stackoverflow.com/a/3314034

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-llvm-transforms
@llvm/pr-subscribers-lto
@llvm/pr-subscribers-vectorizers
@llvm/pr-subscribers-backend-nvptx
@llvm/pr-subscribers-tools-llvm-exegesis
@llvm/pr-subscribers-testing-tools
@llvm/pr-subscribers-tablegen
@llvm/pr-subscribers-backend-directx
@llvm/pr-subscribers-backend-arm
@llvm/pr-subscribers-llvm-globalisel
@llvm/pr-subscribers-llvm-ir
@llvm/pr-subscribers-llvm-selectiondag

@llvm/pr-subscribers-backend-risc-v

Author: Herman Semenoff (GermanAizek)

Changes

For better optimized code generation functions calls by compiler, objects sizes equal to or greater than 16 bytes must be pass by constant reference. A constant reference is also useful as refactoring technique that indicates that param is a constant.

Reference: https://stackoverflow.com/a/3314034


Patch is 267.62 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/125074.diff

127 Files Affected:

  • (modified) llvm/include/llvm/Analysis/AliasSetTracker.h (+1-1)
  • (modified) llvm/include/llvm/Analysis/AssumeBundleQueries.h (+3-3)
  • (modified) llvm/include/llvm/Bitcode/BitcodeReader.h (+17-17)
  • (modified) llvm/include/llvm/Bitcode/BitcodeWriter.h (+1-1)
  • (modified) llvm/include/llvm/CGData/CodeGenData.h (+1-1)
  • (modified) llvm/include/llvm/CodeGen/AsmPrinter.h (+3-3)
  • (modified) llvm/include/llvm/CodeGen/BasicBlockSectionsProfileReader.h (+1-1)
  • (modified) llvm/include/llvm/CodeGen/MachineFunction.h (+1-1)
  • (modified) llvm/include/llvm/CodeGen/SelectionDAG.h (+1-1)
  • (modified) llvm/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h (+2-2)
  • (modified) llvm/include/llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h (+2-2)
  • (modified) llvm/include/llvm/DebugInfo/CodeView/DebugStringTableSubsection.h (+1-1)
  • (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h (+1-1)
  • (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFAddressRange.h (+1-1)
  • (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h (+1-1)
  • (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAddr.h (+1-1)
  • (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h (+1-1)
  • (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h (+1-1)
  • (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h (+7-7)
  • (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h (+2-2)
  • (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h (+2-2)
  • (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFDebugMacro.h (+5-5)
  • (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFDebugPubTable.h (+1-1)
  • (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h (+1-1)
  • (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFExpression.h (+2-2)
  • (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h (+5-5)
  • (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFGdbIndex.h (+2-2)
  • (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFListTable.h (+4-4)
  • (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h (+3-3)
  • (modified) llvm/include/llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h (+1-1)
  • (modified) llvm/include/llvm/DebugInfo/PDB/Native/DbiModuleList.h (+1-1)
  • (modified) llvm/include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h (+1-1)
  • (modified) llvm/include/llvm/Debuginfod/Debuginfod.h (+1-1)
  • (modified) llvm/include/llvm/ExecutionEngine/JITLink/COFF.h (+1-1)
  • (modified) llvm/include/llvm/ExecutionEngine/JITLink/COFF_x86_64.h (+1-1)
  • (modified) llvm/include/llvm/ExecutionEngine/JITLink/ELF.h (+1-1)
  • (modified) llvm/include/llvm/ExecutionEngine/JITLink/ELF_aarch32.h (+1-1)
  • (modified) llvm/include/llvm/ExecutionEngine/JITLink/ELF_aarch64.h (+1-1)
  • (modified) llvm/include/llvm/ExecutionEngine/JITLink/ELF_i386.h (+1-1)
  • (modified) llvm/include/llvm/ExecutionEngine/JITLink/ELF_loongarch.h (+1-1)
  • (modified) llvm/include/llvm/ExecutionEngine/JITLink/ELF_riscv.h (+1-1)
  • (modified) llvm/include/llvm/ExecutionEngine/JITLink/ELF_x86_64.h (+1-1)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/Core.h (+1-1)
  • (modified) llvm/include/llvm/IR/InstrTypes.h (+39-39)
  • (modified) llvm/include/llvm/IR/Instructions.h (+105-105)
  • (modified) llvm/include/llvm/Object/Binary.h (+1-1)
  • (modified) llvm/include/llvm/Object/COFFModuleDefinition.h (+1-1)
  • (modified) llvm/include/llvm/Object/DXContainer.h (+1-1)
  • (modified) llvm/include/llvm/Object/ObjectFile.h (+2-2)
  • (modified) llvm/include/llvm/SandboxIR/Instruction.h (+41-41)
  • (modified) llvm/include/llvm/Support/BinaryStreamWriter.h (+2-2)
  • (modified) llvm/lib/Bitcode/Reader/BitcodeReader.cpp (+20-20)
  • (modified) llvm/lib/Bitcode/Writer/BitcodeWriter.cpp (+2-2)
  • (modified) llvm/lib/CGData/CodeGenData.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (+4-4)
  • (modified) llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp (+2-2)
  • (modified) llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h (+2-2)
  • (modified) llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp (+3-3)
  • (modified) llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/MachineFunction.cpp (+1-1)
  • (modified) llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp (+4-4)
  • (modified) llvm/lib/DebugInfo/CodeView/DebugInlineeLinesSubsection.cpp (+1-1)
  • (modified) llvm/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp (+1-1)
  • (modified) llvm/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp (+1-1)
  • (modified) llvm/lib/DebugInfo/DWARF/DWARFAddressRange.cpp (+1-1)
  • (modified) llvm/lib/DebugInfo/DWARF/DWARFContext.cpp (+1-1)
  • (modified) llvm/lib/DebugInfo/DWARF/DWARFDebugAbbrev.cpp (+1-1)
  • (modified) llvm/lib/DebugInfo/DWARF/DWARFDebugAddr.cpp (+1-1)
  • (modified) llvm/lib/DebugInfo/DWARF/DWARFDebugArangeSet.cpp (+1-1)
  • (modified) llvm/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp (+1-1)
  • (modified) llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp (+8-8)
  • (modified) llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp (+2-2)
  • (modified) llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp (+3-3)
  • (modified) llvm/lib/DebugInfo/DWARF/DWARFDebugMacro.cpp (+2-2)
  • (modified) llvm/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp (+1-1)
  • (modified) llvm/lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp (+1-1)
  • (modified) llvm/lib/DebugInfo/DWARF/DWARFDie.cpp (+4-4)
  • (modified) llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp (+3-3)
  • (modified) llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp (+4-4)
  • (modified) llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp (+2-2)
  • (modified) llvm/lib/DebugInfo/DWARF/DWARFListTable.cpp (+2-2)
  • (modified) llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp (+3-3)
  • (modified) llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp (+1-1)
  • (modified) llvm/lib/DebugInfo/PDB/Native/DbiModuleList.cpp (+2-2)
  • (modified) llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp (+1-1)
  • (modified) llvm/lib/Debuginfod/Debuginfod.cpp (+1-1)
  • (modified) llvm/lib/ExecutionEngine/Interpreter/Execution.cpp (+31-31)
  • (modified) llvm/lib/ExecutionEngine/Interpreter/Interpreter.h (+2-2)
  • (modified) llvm/lib/ExecutionEngine/JITLink/COFF.cpp (+1-1)
  • (modified) llvm/lib/ExecutionEngine/JITLink/COFF_x86_64.cpp (+1-1)
  • (modified) llvm/lib/ExecutionEngine/JITLink/ELF.cpp (+1-1)
  • (modified) llvm/lib/ExecutionEngine/JITLink/ELF_aarch32.cpp (+1-1)
  • (modified) llvm/lib/ExecutionEngine/JITLink/ELF_aarch64.cpp (+1-1)
  • (modified) llvm/lib/ExecutionEngine/JITLink/ELF_i386.cpp (+1-1)
  • (modified) llvm/lib/ExecutionEngine/JITLink/ELF_loongarch.cpp (+1-1)
  • (modified) llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp (+1-1)
  • (modified) llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp (+1-1)
  • (modified) llvm/lib/ExecutionEngine/Orc/Core.cpp (+1-1)
  • (modified) llvm/lib/ExecutionEngine/Orc/DebugObjectManagerPlugin.cpp (+5-5)
  • (modified) llvm/lib/IR/AsmWriter.cpp (+1-1)
  • (modified) llvm/lib/IR/Instructions.cpp (+90-90)
  • (modified) llvm/lib/ObjCopy/ELF/ELFObject.cpp (+2-2)
  • (modified) llvm/lib/ObjCopy/ELF/ELFObject.h (+2-2)
  • (modified) llvm/lib/Object/Archive.cpp (+3-3)
  • (modified) llvm/lib/Object/ArchiveWriter.cpp (+1-1)
  • (modified) llvm/lib/Object/Binary.cpp (+1-1)
  • (modified) llvm/lib/Object/COFFModuleDefinition.cpp (+1-1)
  • (modified) llvm/lib/Object/COFFObjectFile.cpp (+4-4)
  • (modified) llvm/lib/Object/DXContainer.cpp (+1-1)
  • (modified) llvm/lib/Object/GOFFObjectFile.cpp (+1-1)
  • (modified) llvm/lib/SandboxIR/Instruction.cpp (+39-39)
  • (modified) llvm/lib/Support/AMDGPUMetadata.cpp (+1-1)
  • (modified) llvm/lib/Support/BinaryStreamWriter.cpp (+2-2)
  • (modified) llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp (+4-3)
  • (modified) llvm/lib/Target/AArch64/AArch64FrameLowering.cpp (+1-1)
  • (modified) llvm/lib/Target/AArch64/AArch64SelectionDAGInfo.cpp (+2-2)
  • (modified) llvm/lib/Target/AArch64/AArch64SelectionDAGInfo.h (+2-2)
  • (modified) llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp (+1-1)
  • (modified) llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp (+2-2)
  • (modified) llvm/lib/Target/AArch64/Utils/AArch64BaseInfo.h (+3-3)
  • (modified) llvm/lib/Target/AMDGPU/Utils/AMDGPUDelayedMCExpr.cpp (+2-2)
  • (modified) llvm/lib/Target/ARM/ARMInstructionSelector.cpp (+4-4)
  • (modified) llvm/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp (+6-4)
  • (modified) llvm/lib/Target/ARM/Utils/ARMBaseInfo.h (+2-2)
  • (modified) llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp (+1-1)
  • (modified) llvm/lib/TargetParser/ARMTargetParser.cpp (+1-1)
diff --git a/llvm/include/llvm/Analysis/AliasSetTracker.h b/llvm/include/llvm/Analysis/AliasSetTracker.h
index e5817d2409bc651..917df86d8d01de1 100644
--- a/llvm/include/llvm/Analysis/AliasSetTracker.h
+++ b/llvm/include/llvm/Analysis/AliasSetTracker.h
@@ -249,7 +249,7 @@ class AliasSetTracker {
     }
   }
 
-  AliasSet &addMemoryLocation(MemoryLocation Loc, AliasSet::AccessLattice E);
+  AliasSet &addMemoryLocation(const MemoryLocation &Loc, AliasSet::AccessLattice E);
   AliasSet *mergeAliasSetsForMemoryLocation(const MemoryLocation &MemLoc,
                                             AliasSet *PtrAS,
                                             bool &MustAliasAll);
diff --git a/llvm/include/llvm/Analysis/AssumeBundleQueries.h b/llvm/include/llvm/Analysis/AssumeBundleQueries.h
index f7a893708758c5a..3acdd46e86a6e13 100644
--- a/llvm/include/llvm/Analysis/AssumeBundleQueries.h
+++ b/llvm/include/llvm/Analysis/AssumeBundleQueries.h
@@ -100,14 +100,14 @@ struct RetainedKnowledge {
   Attribute::AttrKind AttrKind = Attribute::None;
   uint64_t ArgValue = 0;
   Value *WasOn = nullptr;
-  bool operator==(RetainedKnowledge Other) const {
+  bool operator==(const RetainedKnowledge &Other) const {
     return AttrKind == Other.AttrKind && WasOn == Other.WasOn &&
            ArgValue == Other.ArgValue;
   }
-  bool operator!=(RetainedKnowledge Other) const { return !(*this == Other); }
+  bool operator!=(const RetainedKnowledge &Other) const { return !(*this == Other); }
   /// This is only intended for use in std::min/std::max between attribute that
   /// only differ in ArgValue.
-  bool operator<(RetainedKnowledge Other) const {
+  bool operator<(const RetainedKnowledge &Other) const {
     assert(((AttrKind == Other.AttrKind && WasOn == Other.WasOn) ||
             AttrKind == Attribute::None || Other.AttrKind == Attribute::None) &&
            "This is only intend for use in min/max to select the best for "
diff --git a/llvm/include/llvm/Bitcode/BitcodeReader.h b/llvm/include/llvm/Bitcode/BitcodeReader.h
index f204060a3a97871..09ece3eae8c4b51 100644
--- a/llvm/include/llvm/Bitcode/BitcodeReader.h
+++ b/llvm/include/llvm/Bitcode/BitcodeReader.h
@@ -119,12 +119,12 @@ struct ParserCallbacks {
 
     // Calls the ctor.
     friend Expected<BitcodeFileContents>
-    getBitcodeFileContents(MemoryBufferRef Buffer);
+    getBitcodeFileContents(const MemoryBufferRef &Buffer);
 
     Expected<std::unique_ptr<Module>>
     getModuleImpl(LLVMContext &Context, bool MaterializeAll,
                   bool ShouldLazyLoadMetadata, bool IsImporting,
-                  ParserCallbacks Callbacks = {});
+                  const ParserCallbacks &Callbacks = {});
 
   public:
     StringRef getBuffer() const {
@@ -141,11 +141,11 @@ struct ParserCallbacks {
     /// importing into another module.
     Expected<std::unique_ptr<Module>>
     getLazyModule(LLVMContext &Context, bool ShouldLazyLoadMetadata,
-                  bool IsImporting, ParserCallbacks Callbacks = {});
+                  bool IsImporting, const ParserCallbacks &Callbacks = {});
 
     /// Read the entire bitcode module and return it.
     Expected<std::unique_ptr<Module>>
-    parseModule(LLVMContext &Context, ParserCallbacks Callbacks = {});
+    parseModule(LLVMContext &Context, const ParserCallbacks &Callbacks = {});
 
     /// Returns information about the module to be used for LTO: whether to
     /// compile with ThinLTO, and whether it has a summary.
@@ -171,21 +171,21 @@ struct ParserCallbacks {
   /// symbol table should prefer to use irsymtab::read instead of this function
   /// because it creates a reader for the irsymtab and handles upgrading bitcode
   /// files without a symbol table or with an old symbol table.
-  Expected<BitcodeFileContents> getBitcodeFileContents(MemoryBufferRef Buffer);
+  Expected<BitcodeFileContents> getBitcodeFileContents(const MemoryBufferRef &Buffer);
 
   /// Returns a list of modules in the specified bitcode buffer.
   Expected<std::vector<BitcodeModule>>
-  getBitcodeModuleList(MemoryBufferRef Buffer);
+  getBitcodeModuleList(const MemoryBufferRef &Buffer);
 
   /// Read the header of the specified bitcode buffer and prepare for lazy
   /// deserialization of function bodies. If ShouldLazyLoadMetadata is true,
   /// lazily load metadata as well. If IsImporting is true, this module is
   /// being parsed for ThinLTO importing into another module.
   Expected<std::unique_ptr<Module>>
-  getLazyBitcodeModule(MemoryBufferRef Buffer, LLVMContext &Context,
+  getLazyBitcodeModule(const MemoryBufferRef &Buffer, LLVMContext &Context,
                        bool ShouldLazyLoadMetadata = false,
                        bool IsImporting = false,
-                       ParserCallbacks Callbacks = {});
+                       const ParserCallbacks &Callbacks = {});
 
   /// Like getLazyBitcodeModule, except that the module takes ownership of
   /// the memory buffer if successful. If successful, this moves Buffer. On
@@ -194,36 +194,36 @@ struct ParserCallbacks {
   Expected<std::unique_ptr<Module>> getOwningLazyBitcodeModule(
       std::unique_ptr<MemoryBuffer> &&Buffer, LLVMContext &Context,
       bool ShouldLazyLoadMetadata = false, bool IsImporting = false,
-      ParserCallbacks Callbacks = {});
+      const ParserCallbacks &Callbacks = {});
 
   /// Read the header of the specified bitcode buffer and extract just the
   /// triple information. If successful, this returns a string. On error, this
   /// returns "".
-  Expected<std::string> getBitcodeTargetTriple(MemoryBufferRef Buffer);
+  Expected<std::string> getBitcodeTargetTriple(const MemoryBufferRef &Buffer);
 
   /// Return true if \p Buffer contains a bitcode file with ObjC code (category
   /// or class) in it.
-  Expected<bool> isBitcodeContainingObjCCategory(MemoryBufferRef Buffer);
+  Expected<bool> isBitcodeContainingObjCCategory(const MemoryBufferRef &Buffer);
 
   /// Read the header of the specified bitcode buffer and extract just the
   /// producer string information. If successful, this returns a string. On
   /// error, this returns "".
-  Expected<std::string> getBitcodeProducerString(MemoryBufferRef Buffer);
+  Expected<std::string> getBitcodeProducerString(const MemoryBufferRef &Buffer);
 
   /// Read the specified bitcode file, returning the module.
   Expected<std::unique_ptr<Module>>
-  parseBitcodeFile(MemoryBufferRef Buffer, LLVMContext &Context,
-                   ParserCallbacks Callbacks = {});
+  parseBitcodeFile(const MemoryBufferRef &Buffer, LLVMContext &Context,
+                   const ParserCallbacks &Callbacks = {});
 
   /// Returns LTO information for the specified bitcode file.
-  Expected<BitcodeLTOInfo> getBitcodeLTOInfo(MemoryBufferRef Buffer);
+  Expected<BitcodeLTOInfo> getBitcodeLTOInfo(const MemoryBufferRef &Buffer);
 
   /// Parse the specified bitcode buffer, returning the module summary index.
   Expected<std::unique_ptr<ModuleSummaryIndex>>
-  getModuleSummaryIndex(MemoryBufferRef Buffer);
+  getModuleSummaryIndex(const MemoryBufferRef &Buffer);
 
   /// Parse the specified bitcode buffer and merge the index into CombinedIndex.
-  Error readModuleSummaryIndex(MemoryBufferRef Buffer,
+  Error readModuleSummaryIndex(const MemoryBufferRef &Buffer,
                                ModuleSummaryIndex &CombinedIndex);
 
   /// Parse the module summary index out of an IR file and return the module
diff --git a/llvm/include/llvm/Bitcode/BitcodeWriter.h b/llvm/include/llvm/Bitcode/BitcodeWriter.h
index 2823b438f80bf40..db4c752abc5ed78 100644
--- a/llvm/include/llvm/Bitcode/BitcodeWriter.h
+++ b/llvm/include/llvm/Bitcode/BitcodeWriter.h
@@ -163,7 +163,7 @@ void writeIndexToFile(
 /// If EmbedCmdline is set, the command line is also exported in
 /// the corresponding section (__LLVM,_cmdline / .llvmcmd) - even if CmdArgs
 /// were empty.
-void embedBitcodeInModule(Module &M, MemoryBufferRef Buf, bool EmbedBitcode,
+void embedBitcodeInModule(Module &M, const MemoryBufferRef &Buf, bool EmbedBitcode,
                           bool EmbedCmdline,
                           const std::vector<uint8_t> &CmdArgs);
 
diff --git a/llvm/include/llvm/CGData/CodeGenData.h b/llvm/include/llvm/CGData/CodeGenData.h
index da0e412f2a0e036..ba62f7332818ff6 100644
--- a/llvm/include/llvm/CGData/CodeGenData.h
+++ b/llvm/include/llvm/CGData/CodeGenData.h
@@ -265,7 +265,7 @@ std::unique_ptr<Module> loadModuleForTwoRounds(BitcodeModule &OrigModule,
 Expected<stable_hash> mergeCodeGenData(ArrayRef<StringRef> ObjectFiles);
 
 void warn(Error E, StringRef Whence = "");
-void warn(Twine Message, std::string Whence = "", std::string Hint = "");
+void warn(const Twine &Message, const std::string &Whence = "", const std::string &Hint = "");
 
 } // end namespace cgdata
 
diff --git a/llvm/include/llvm/CodeGen/AsmPrinter.h b/llvm/include/llvm/CodeGen/AsmPrinter.h
index 5291369b3b9f1d8..18a99186bafe871 100644
--- a/llvm/include/llvm/CodeGen/AsmPrinter.h
+++ b/llvm/include/llvm/CodeGen/AsmPrinter.h
@@ -632,7 +632,7 @@ class AsmPrinter : public MachineFunctionPass {
                                          StringRef Suffix) const;
 
   /// Return the MCSymbol for the specified ExternalSymbol.
-  MCSymbol *GetExternalSymbolSymbol(Twine Sym) const;
+  MCSymbol *GetExternalSymbolSymbol(const Twine &Sym) const;
 
   /// Return the symbol for the specified jump table entry.
   MCSymbol *GetJTISymbol(unsigned JTID, bool isLinkerPrivate = false) const;
@@ -723,10 +723,10 @@ class AsmPrinter : public MachineFunctionPass {
   /// emitDwarfSymbolReference().
   ///
   /// The length of the emitted value depends on the DWARF format.
-  void emitDwarfStringOffset(DwarfStringPoolEntry S) const;
+  void emitDwarfStringOffset(const DwarfStringPoolEntry &S) const;
 
   /// Emit the 4-or 8-byte offset of a string from the start of its section.
-  void emitDwarfStringOffset(DwarfStringPoolEntryRef S) const {
+  void emitDwarfStringOffset(const DwarfStringPoolEntryRef &S) const {
     emitDwarfStringOffset(S.getEntry());
   }
 
diff --git a/llvm/include/llvm/CodeGen/BasicBlockSectionsProfileReader.h b/llvm/include/llvm/CodeGen/BasicBlockSectionsProfileReader.h
index 08e6a0e3ef6295c..814879860b1b212 100644
--- a/llvm/include/llvm/CodeGen/BasicBlockSectionsProfileReader.h
+++ b/llvm/include/llvm/CodeGen/BasicBlockSectionsProfileReader.h
@@ -105,7 +105,7 @@ class BasicBlockSectionsProfileReader {
   }
 
   // Returns a profile parsing error for the current line.
-  Error createProfileParseError(Twine Message) const {
+  Error createProfileParseError(const Twine &Message) const {
     return make_error<StringError>(
         Twine("invalid profile " + MBuf->getBufferIdentifier() + " at line " +
               Twine(LineIt.line_number()) + ": " + Message),
diff --git a/llvm/include/llvm/CodeGen/MachineFunction.h b/llvm/include/llvm/CodeGen/MachineFunction.h
index c3eb27b9462879d..861db8147438f73 100644
--- a/llvm/include/llvm/CodeGen/MachineFunction.h
+++ b/llvm/include/llvm/CodeGen/MachineFunction.h
@@ -1059,7 +1059,7 @@ class LLVM_ABI MachineFunction {
       AtomicOrdering Ordering = AtomicOrdering::NotAtomic,
       AtomicOrdering FailureOrdering = AtomicOrdering::NotAtomic);
   MachineMemOperand *getMachineMemOperand(
-      MachinePointerInfo PtrInfo, MachineMemOperand::Flags F, LocationSize Size,
+      const MachinePointerInfo &PtrInfo, MachineMemOperand::Flags F, LocationSize Size,
       Align BaseAlignment, const AAMDNodes &AAInfo = AAMDNodes(),
       const MDNode *Ranges = nullptr, SyncScope::ID SSID = SyncScope::System,
       AtomicOrdering Ordering = AtomicOrdering::NotAtomic,
diff --git a/llvm/include/llvm/CodeGen/SelectionDAG.h b/llvm/include/llvm/CodeGen/SelectionDAG.h
index 461c0c1ead16d2c..2f0472661bf26cf 100644
--- a/llvm/include/llvm/CodeGen/SelectionDAG.h
+++ b/llvm/include/llvm/CodeGen/SelectionDAG.h
@@ -1408,7 +1408,7 @@ class SelectionDAG {
                   const MDNode *Ranges = nullptr);
   inline SDValue getLoad(
       ISD::MemIndexedMode AM, ISD::LoadExtType ExtType, EVT VT, const SDLoc &dl,
-      SDValue Chain, SDValue Ptr, SDValue Offset, MachinePointerInfo PtrInfo,
+      SDValue Chain, SDValue Ptr, SDValue Offset, const MachinePointerInfo &PtrInfo,
       EVT MemVT, MaybeAlign Alignment = MaybeAlign(),
       MachineMemOperand::Flags MMOFlags = MachineMemOperand::MONone,
       const AAMDNodes &AAInfo = AAMDNodes(), const MDNode *Ranges = nullptr) {
diff --git a/llvm/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h b/llvm/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h
index 7780e233cab3b0b..7864649c9366088 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h
@@ -30,13 +30,13 @@ enum VisitorDataSource {
                     // supply the bytes.
 };
 
-Error visitTypeRecord(CVType &Record, TypeIndex Index,
+Error visitTypeRecord(CVType &Record, const TypeIndex &Index,
                       TypeVisitorCallbacks &Callbacks,
                       VisitorDataSource Source = VDS_BytesPresent);
 Error visitTypeRecord(CVType &Record, TypeVisitorCallbacks &Callbacks,
                       VisitorDataSource Source = VDS_BytesPresent);
 
-Error visitMemberRecord(CVMemberRecord Record, TypeVisitorCallbacks &Callbacks,
+Error visitMemberRecord(const CVMemberRecord &Record, TypeVisitorCallbacks &Callbacks,
                         VisitorDataSource Source = VDS_BytesPresent);
 Error visitMemberRecord(TypeLeafKind Kind, ArrayRef<uint8_t> Record,
                         TypeVisitorCallbacks &Callbacks);
diff --git a/llvm/include/llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h b/llvm/include/llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h
index f9d1507af5f3cd6..abf3e63ca06ea9b 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h
@@ -69,7 +69,7 @@ class DebugInlineeLinesSubsectionRef final : public DebugSubsectionRef {
   }
 
   Error initialize(BinaryStreamReader Reader);
-  Error initialize(BinaryStreamRef Section) {
+  Error initialize(const BinaryStreamRef &Section) {
     return initialize(BinaryStreamReader(Section));
   }
 
@@ -101,7 +101,7 @@ class DebugInlineeLinesSubsection final : public DebugSubsection {
   Error commit(BinaryStreamWriter &Writer) const override;
   uint32_t calculateSerializedSize() const override;
 
-  void addInlineSite(TypeIndex FuncId, StringRef FileName, uint32_t SourceLine);
+  void addInlineSite(const TypeIndex &FuncId, StringRef FileName, uint32_t SourceLine);
   void addExtraFile(StringRef FileName);
 
   bool hasExtraFiles() const { return HasExtraFiles; }
diff --git a/llvm/include/llvm/DebugInfo/CodeView/DebugStringTableSubsection.h b/llvm/include/llvm/DebugInfo/CodeView/DebugStringTableSubsection.h
index 6e5b8adddd4aef4..7b3f0a78af3b6a4 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/DebugStringTableSubsection.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/DebugStringTableSubsection.h
@@ -36,7 +36,7 @@ class DebugStringTableSubsectionRef : public DebugSubsectionRef {
     return S->kind() == DebugSubsectionKind::StringTable;
   }
 
-  Error initialize(BinaryStreamRef Contents);
+  Error initialize(const BinaryStreamRef &Contents);
   Error initialize(BinaryStreamReader &Reader);
 
   Expected<StringRef> getString(uint32_t Offset) const;
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h
index 02b402e86d23399..c5bdf5a5b652298 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h
@@ -173,7 +173,7 @@ class DWARFAbbreviationDeclaration {
   getAttributeValueFromOffset(uint32_t AttrIndex, uint64_t Offset,
                               const DWARFUnit &U) const;
 
-  llvm::Expected<ExtractState> extract(DataExtractor Data, uint64_t *OffsetPtr);
+  llvm::Expected<ExtractState> extract(const DataExtractor &Data, uint64_t *OffsetPtr);
   void dump(raw_ostream &OS) const;
 
   // Return an optional byte size of all attribute data in this abbreviation
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFAddressRange.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFAddressRange.h
index f4d6c451cbe1d65..55a8d89294bba02 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFAddressRange.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFAddressRange.h
@@ -68,7 +68,7 @@ struct DWARFAddressRange {
     return true;
   }
 
-  void dump(raw_ostream &OS, uint32_t AddressSize, DIDumpOptions DumpOpts = {},
+  void dump(raw_ostream &OS, uint32_t AddressSize, const DIDumpOptions &DumpOpts = {},
             const DWARFObject *Obj = nullptr) const;
 };
 
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h
index 6439827ef70f0f0..138fbef4e79d832 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h
@@ -34,7 +34,7 @@ class DWARFAbbreviationDeclarationSet {
 
   uint64_t getOffset() const { return Offset; }
   void dump(raw_ostream &OS) const;
-  Error extract(DataExtractor Data, uint64_t *OffsetPtr);
+  Error extract(const DataExtractor &Data, uint64_t *OffsetPtr);
 
   const DWARFAbbreviationDeclaration *
   getAbbreviationDeclaration(uint32_t AbbrCode) const;
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAddr.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAddr.h
index ae2a4e2276da0fe..1e7931277ec9d27 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAddr.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAddr.h
@@ -63,7 +63,7 @@ class DWARFDebugAddrTable {
   Error extractPreStandard(const DWARFDataExtractor &Data, uint64_t *OffsetPtr,
                            uint16_t CUVersion, uint8_t CUAddrSize);
 
-  void dump(raw_ostream &OS, DIDumpOptions DumpOpts = {}) const;
+  void dump(raw_ostream &OS, const DIDumpOptions &DumpOpts = {}) const;
 
   /// Return the address based on a given index.
   Expected<uint64_t> getAddrEntry(uint32_t Index) const;
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h
index 942de05f6bd84be..928d7889cbf2349 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h
@@ -61,7 +61,7 @@ class DWARFDebugArangeSet {
   DWARFDebugArangeSet() { clear(); }
 
   void clear();
-  Error extract(DWARFDataExtractor data, uint64_t *offset_ptr,
+  Error extract(const DWARFDataExtractor &data, uint64_t *offset_ptr,
                 function_ref<void(Error)> WarningHandler = nullptr);
   void dump(raw_ostream &OS) const;
 
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h
index 068674cfae5c56b..8661b2247b9d12b 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h
@@ -27,7 +27,7 @@ class DWARFDebugAranges {
 
 private:
   void clear();
-  void extract(DWARFDataExtractor DebugArangesData,
+  void extract(const DWARFDataExtractor &DebugArangesData,
                function_ref<void(Error)> RecoverableErrorHandler,
                function_ref<void(Error)> WarningHandler);
 
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h
index a9a3c7edde691e5..624116ab34672c0 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h
@@ -124,8 +124,8 @@ class UnwindLocation {
   /// Create a location whose value is the result of evaluating a DWARF
   /// expression. This allows complex expressions to be evaluated in order to
   /// unwind a register or CFA value.
-  static UnwindLocation createIsDWARFExpression(DWARFExpression Expr);
-  static UnwindLocation createAtDWARFExpression(DWARFExpression Expr);
+  static UnwindLocation createIsDWARFExpression(const DWARFExpression &Expr);
+  static UnwindLocation createAtDWARFExpression(const DWARFExpression &Expr);
   static UnwindLocation createIsConstant(int32_t Value);
 
   Location getLocation() const { return Kind; }
@@ -164,7 +164,7 @@ class UnwindLocation {
   /// instead of from .debug_frame. This is needed for register number
   /// conversion be...
[truncated]

@llvmbot
Copy link
Member

llvmbot commented Jan 30, 2025

@llvm/pr-subscribers-llvm-analysis

Author: Herman Semenoff (GermanAizek)

Changes

For better optimized code generation functions calls by compiler, objects sizes equal to or greater than 16 bytes must be pass by constant reference. A constant reference is also useful as refactoring technique that indicates that param is a constant.

Reference: https://stackoverflow.com/a/3314034


Patch is 267.37 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/125074.diff

127 Files Affected:

  • (modified) llvm/include/llvm/Analysis/AliasSetTracker.h (+1-1)
  • (modified) llvm/include/llvm/Analysis/AssumeBundleQueries.h (+3-3)
  • (modified) llvm/include/llvm/Bitcode/BitcodeReader.h (+17-17)
  • (modified) llvm/include/llvm/Bitcode/BitcodeWriter.h (+1-1)
  • (modified) llvm/include/llvm/CGData/CodeGenData.h (+1-1)
  • (modified) llvm/include/llvm/CodeGen/AsmPrinter.h (+3-3)
  • (modified) llvm/include/llvm/CodeGen/BasicBlockSectionsProfileReader.h (+1-1)
  • (modified) llvm/include/llvm/CodeGen/MachineFunction.h (+1-1)
  • (modified) llvm/include/llvm/CodeGen/SelectionDAG.h (+1-1)
  • (modified) llvm/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h (+2-2)
  • (modified) llvm/include/llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h (+2-2)
  • (modified) llvm/include/llvm/DebugInfo/CodeView/DebugStringTableSubsection.h (+1-1)
  • (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h (+1-1)
  • (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFAddressRange.h (+1-1)
  • (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h (+1-1)
  • (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAddr.h (+1-1)
  • (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h (+1-1)
  • (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h (+1-1)
  • (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h (+7-7)
  • (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h (+2-2)
  • (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h (+2-2)
  • (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFDebugMacro.h (+5-5)
  • (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFDebugPubTable.h (+1-1)
  • (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h (+1-1)
  • (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFExpression.h (+2-2)
  • (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h (+5-5)
  • (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFGdbIndex.h (+2-2)
  • (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFListTable.h (+4-4)
  • (modified) llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h (+3-3)
  • (modified) llvm/include/llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h (+1-1)
  • (modified) llvm/include/llvm/DebugInfo/PDB/Native/DbiModuleList.h (+1-1)
  • (modified) llvm/include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h (+1-1)
  • (modified) llvm/include/llvm/Debuginfod/Debuginfod.h (+1-1)
  • (modified) llvm/include/llvm/ExecutionEngine/JITLink/COFF.h (+1-1)
  • (modified) llvm/include/llvm/ExecutionEngine/JITLink/COFF_x86_64.h (+1-1)
  • (modified) llvm/include/llvm/ExecutionEngine/JITLink/ELF.h (+1-1)
  • (modified) llvm/include/llvm/ExecutionEngine/JITLink/ELF_aarch32.h (+1-1)
  • (modified) llvm/include/llvm/ExecutionEngine/JITLink/ELF_aarch64.h (+1-1)
  • (modified) llvm/include/llvm/ExecutionEngine/JITLink/ELF_i386.h (+1-1)
  • (modified) llvm/include/llvm/ExecutionEngine/JITLink/ELF_loongarch.h (+1-1)
  • (modified) llvm/include/llvm/ExecutionEngine/JITLink/ELF_riscv.h (+1-1)
  • (modified) llvm/include/llvm/ExecutionEngine/JITLink/ELF_x86_64.h (+1-1)
  • (modified) llvm/include/llvm/ExecutionEngine/Orc/Core.h (+1-1)
  • (modified) llvm/include/llvm/IR/InstrTypes.h (+39-39)
  • (modified) llvm/include/llvm/IR/Instructions.h (+105-105)
  • (modified) llvm/include/llvm/Object/Binary.h (+1-1)
  • (modified) llvm/include/llvm/Object/COFFModuleDefinition.h (+1-1)
  • (modified) llvm/include/llvm/Object/DXContainer.h (+1-1)
  • (modified) llvm/include/llvm/Object/ObjectFile.h (+2-2)
  • (modified) llvm/include/llvm/SandboxIR/Instruction.h (+41-41)
  • (modified) llvm/include/llvm/Support/BinaryStreamWriter.h (+2-2)
  • (modified) llvm/lib/Bitcode/Reader/BitcodeReader.cpp (+20-20)
  • (modified) llvm/lib/Bitcode/Writer/BitcodeWriter.cpp (+2-2)
  • (modified) llvm/lib/CGData/CodeGenData.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (+4-4)
  • (modified) llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp (+2-2)
  • (modified) llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h (+2-2)
  • (modified) llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp (+3-3)
  • (modified) llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/MachineFunction.cpp (+1-1)
  • (modified) llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp (+4-4)
  • (modified) llvm/lib/DebugInfo/CodeView/DebugInlineeLinesSubsection.cpp (+1-1)
  • (modified) llvm/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp (+1-1)
  • (modified) llvm/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp (+1-1)
  • (modified) llvm/lib/DebugInfo/DWARF/DWARFAddressRange.cpp (+1-1)
  • (modified) llvm/lib/DebugInfo/DWARF/DWARFContext.cpp (+1-1)
  • (modified) llvm/lib/DebugInfo/DWARF/DWARFDebugAbbrev.cpp (+1-1)
  • (modified) llvm/lib/DebugInfo/DWARF/DWARFDebugAddr.cpp (+1-1)
  • (modified) llvm/lib/DebugInfo/DWARF/DWARFDebugArangeSet.cpp (+1-1)
  • (modified) llvm/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp (+1-1)
  • (modified) llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp (+8-8)
  • (modified) llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp (+2-2)
  • (modified) llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp (+3-3)
  • (modified) llvm/lib/DebugInfo/DWARF/DWARFDebugMacro.cpp (+2-2)
  • (modified) llvm/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp (+1-1)
  • (modified) llvm/lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp (+1-1)
  • (modified) llvm/lib/DebugInfo/DWARF/DWARFDie.cpp (+4-4)
  • (modified) llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp (+3-3)
  • (modified) llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp (+4-4)
  • (modified) llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp (+2-2)
  • (modified) llvm/lib/DebugInfo/DWARF/DWARFListTable.cpp (+2-2)
  • (modified) llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp (+3-3)
  • (modified) llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp (+1-1)
  • (modified) llvm/lib/DebugInfo/PDB/Native/DbiModuleList.cpp (+2-2)
  • (modified) llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp (+1-1)
  • (modified) llvm/lib/Debuginfod/Debuginfod.cpp (+1-1)
  • (modified) llvm/lib/ExecutionEngine/Interpreter/Execution.cpp (+31-31)
  • (modified) llvm/lib/ExecutionEngine/Interpreter/Interpreter.h (+2-2)
  • (modified) llvm/lib/ExecutionEngine/JITLink/COFF.cpp (+1-1)
  • (modified) llvm/lib/ExecutionEngine/JITLink/COFF_x86_64.cpp (+1-1)
  • (modified) llvm/lib/ExecutionEngine/JITLink/ELF.cpp (+1-1)
  • (modified) llvm/lib/ExecutionEngine/JITLink/ELF_aarch32.cpp (+1-1)
  • (modified) llvm/lib/ExecutionEngine/JITLink/ELF_aarch64.cpp (+1-1)
  • (modified) llvm/lib/ExecutionEngine/JITLink/ELF_i386.cpp (+1-1)
  • (modified) llvm/lib/ExecutionEngine/JITLink/ELF_loongarch.cpp (+1-1)
  • (modified) llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp (+1-1)
  • (modified) llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp (+1-1)
  • (modified) llvm/lib/ExecutionEngine/Orc/Core.cpp (+1-1)
  • (modified) llvm/lib/ExecutionEngine/Orc/DebugObjectManagerPlugin.cpp (+5-5)
  • (modified) llvm/lib/IR/AsmWriter.cpp (+1-1)
  • (modified) llvm/lib/IR/Instructions.cpp (+90-90)
  • (modified) llvm/lib/ObjCopy/ELF/ELFObject.cpp (+2-2)
  • (modified) llvm/lib/ObjCopy/ELF/ELFObject.h (+2-2)
  • (modified) llvm/lib/Object/Archive.cpp (+3-3)
  • (modified) llvm/lib/Object/ArchiveWriter.cpp (+1-1)
  • (modified) llvm/lib/Object/Binary.cpp (+1-1)
  • (modified) llvm/lib/Object/COFFModuleDefinition.cpp (+1-1)
  • (modified) llvm/lib/Object/COFFObjectFile.cpp (+4-4)
  • (modified) llvm/lib/Object/DXContainer.cpp (+1-1)
  • (modified) llvm/lib/Object/GOFFObjectFile.cpp (+1-1)
  • (modified) llvm/lib/SandboxIR/Instruction.cpp (+39-39)
  • (modified) llvm/lib/Support/AMDGPUMetadata.cpp (+1-1)
  • (modified) llvm/lib/Support/BinaryStreamWriter.cpp (+2-2)
  • (modified) llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp (+4-3)
  • (modified) llvm/lib/Target/AArch64/AArch64FrameLowering.cpp (+1-1)
  • (modified) llvm/lib/Target/AArch64/AArch64SelectionDAGInfo.cpp (+2-2)
  • (modified) llvm/lib/Target/AArch64/AArch64SelectionDAGInfo.h (+2-2)
  • (modified) llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp (+1-1)
  • (modified) llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp (+2-2)
  • (modified) llvm/lib/Target/AArch64/Utils/AArch64BaseInfo.h (+3-3)
  • (modified) llvm/lib/Target/AMDGPU/Utils/AMDGPUDelayedMCExpr.cpp (+2-2)
  • (modified) llvm/lib/Target/ARM/ARMInstructionSelector.cpp (+4-4)
  • (modified) llvm/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp (+6-4)
  • (modified) llvm/lib/Target/ARM/Utils/ARMBaseInfo.h (+2-2)
  • (modified) llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp (+1-1)
  • (modified) llvm/lib/TargetParser/ARMTargetParser.cpp (+1-1)
diff --git a/llvm/include/llvm/Analysis/AliasSetTracker.h b/llvm/include/llvm/Analysis/AliasSetTracker.h
index e5817d2409bc65..917df86d8d01de 100644
--- a/llvm/include/llvm/Analysis/AliasSetTracker.h
+++ b/llvm/include/llvm/Analysis/AliasSetTracker.h
@@ -249,7 +249,7 @@ class AliasSetTracker {
     }
   }
 
-  AliasSet &addMemoryLocation(MemoryLocation Loc, AliasSet::AccessLattice E);
+  AliasSet &addMemoryLocation(const MemoryLocation &Loc, AliasSet::AccessLattice E);
   AliasSet *mergeAliasSetsForMemoryLocation(const MemoryLocation &MemLoc,
                                             AliasSet *PtrAS,
                                             bool &MustAliasAll);
diff --git a/llvm/include/llvm/Analysis/AssumeBundleQueries.h b/llvm/include/llvm/Analysis/AssumeBundleQueries.h
index f7a893708758c5..3acdd46e86a6e1 100644
--- a/llvm/include/llvm/Analysis/AssumeBundleQueries.h
+++ b/llvm/include/llvm/Analysis/AssumeBundleQueries.h
@@ -100,14 +100,14 @@ struct RetainedKnowledge {
   Attribute::AttrKind AttrKind = Attribute::None;
   uint64_t ArgValue = 0;
   Value *WasOn = nullptr;
-  bool operator==(RetainedKnowledge Other) const {
+  bool operator==(const RetainedKnowledge &Other) const {
     return AttrKind == Other.AttrKind && WasOn == Other.WasOn &&
            ArgValue == Other.ArgValue;
   }
-  bool operator!=(RetainedKnowledge Other) const { return !(*this == Other); }
+  bool operator!=(const RetainedKnowledge &Other) const { return !(*this == Other); }
   /// This is only intended for use in std::min/std::max between attribute that
   /// only differ in ArgValue.
-  bool operator<(RetainedKnowledge Other) const {
+  bool operator<(const RetainedKnowledge &Other) const {
     assert(((AttrKind == Other.AttrKind && WasOn == Other.WasOn) ||
             AttrKind == Attribute::None || Other.AttrKind == Attribute::None) &&
            "This is only intend for use in min/max to select the best for "
diff --git a/llvm/include/llvm/Bitcode/BitcodeReader.h b/llvm/include/llvm/Bitcode/BitcodeReader.h
index f204060a3a9787..09ece3eae8c4b5 100644
--- a/llvm/include/llvm/Bitcode/BitcodeReader.h
+++ b/llvm/include/llvm/Bitcode/BitcodeReader.h
@@ -119,12 +119,12 @@ struct ParserCallbacks {
 
     // Calls the ctor.
     friend Expected<BitcodeFileContents>
-    getBitcodeFileContents(MemoryBufferRef Buffer);
+    getBitcodeFileContents(const MemoryBufferRef &Buffer);
 
     Expected<std::unique_ptr<Module>>
     getModuleImpl(LLVMContext &Context, bool MaterializeAll,
                   bool ShouldLazyLoadMetadata, bool IsImporting,
-                  ParserCallbacks Callbacks = {});
+                  const ParserCallbacks &Callbacks = {});
 
   public:
     StringRef getBuffer() const {
@@ -141,11 +141,11 @@ struct ParserCallbacks {
     /// importing into another module.
     Expected<std::unique_ptr<Module>>
     getLazyModule(LLVMContext &Context, bool ShouldLazyLoadMetadata,
-                  bool IsImporting, ParserCallbacks Callbacks = {});
+                  bool IsImporting, const ParserCallbacks &Callbacks = {});
 
     /// Read the entire bitcode module and return it.
     Expected<std::unique_ptr<Module>>
-    parseModule(LLVMContext &Context, ParserCallbacks Callbacks = {});
+    parseModule(LLVMContext &Context, const ParserCallbacks &Callbacks = {});
 
     /// Returns information about the module to be used for LTO: whether to
     /// compile with ThinLTO, and whether it has a summary.
@@ -171,21 +171,21 @@ struct ParserCallbacks {
   /// symbol table should prefer to use irsymtab::read instead of this function
   /// because it creates a reader for the irsymtab and handles upgrading bitcode
   /// files without a symbol table or with an old symbol table.
-  Expected<BitcodeFileContents> getBitcodeFileContents(MemoryBufferRef Buffer);
+  Expected<BitcodeFileContents> getBitcodeFileContents(const MemoryBufferRef &Buffer);
 
   /// Returns a list of modules in the specified bitcode buffer.
   Expected<std::vector<BitcodeModule>>
-  getBitcodeModuleList(MemoryBufferRef Buffer);
+  getBitcodeModuleList(const MemoryBufferRef &Buffer);
 
   /// Read the header of the specified bitcode buffer and prepare for lazy
   /// deserialization of function bodies. If ShouldLazyLoadMetadata is true,
   /// lazily load metadata as well. If IsImporting is true, this module is
   /// being parsed for ThinLTO importing into another module.
   Expected<std::unique_ptr<Module>>
-  getLazyBitcodeModule(MemoryBufferRef Buffer, LLVMContext &Context,
+  getLazyBitcodeModule(const MemoryBufferRef &Buffer, LLVMContext &Context,
                        bool ShouldLazyLoadMetadata = false,
                        bool IsImporting = false,
-                       ParserCallbacks Callbacks = {});
+                       const ParserCallbacks &Callbacks = {});
 
   /// Like getLazyBitcodeModule, except that the module takes ownership of
   /// the memory buffer if successful. If successful, this moves Buffer. On
@@ -194,36 +194,36 @@ struct ParserCallbacks {
   Expected<std::unique_ptr<Module>> getOwningLazyBitcodeModule(
       std::unique_ptr<MemoryBuffer> &&Buffer, LLVMContext &Context,
       bool ShouldLazyLoadMetadata = false, bool IsImporting = false,
-      ParserCallbacks Callbacks = {});
+      const ParserCallbacks &Callbacks = {});
 
   /// Read the header of the specified bitcode buffer and extract just the
   /// triple information. If successful, this returns a string. On error, this
   /// returns "".
-  Expected<std::string> getBitcodeTargetTriple(MemoryBufferRef Buffer);
+  Expected<std::string> getBitcodeTargetTriple(const MemoryBufferRef &Buffer);
 
   /// Return true if \p Buffer contains a bitcode file with ObjC code (category
   /// or class) in it.
-  Expected<bool> isBitcodeContainingObjCCategory(MemoryBufferRef Buffer);
+  Expected<bool> isBitcodeContainingObjCCategory(const MemoryBufferRef &Buffer);
 
   /// Read the header of the specified bitcode buffer and extract just the
   /// producer string information. If successful, this returns a string. On
   /// error, this returns "".
-  Expected<std::string> getBitcodeProducerString(MemoryBufferRef Buffer);
+  Expected<std::string> getBitcodeProducerString(const MemoryBufferRef &Buffer);
 
   /// Read the specified bitcode file, returning the module.
   Expected<std::unique_ptr<Module>>
-  parseBitcodeFile(MemoryBufferRef Buffer, LLVMContext &Context,
-                   ParserCallbacks Callbacks = {});
+  parseBitcodeFile(const MemoryBufferRef &Buffer, LLVMContext &Context,
+                   const ParserCallbacks &Callbacks = {});
 
   /// Returns LTO information for the specified bitcode file.
-  Expected<BitcodeLTOInfo> getBitcodeLTOInfo(MemoryBufferRef Buffer);
+  Expected<BitcodeLTOInfo> getBitcodeLTOInfo(const MemoryBufferRef &Buffer);
 
   /// Parse the specified bitcode buffer, returning the module summary index.
   Expected<std::unique_ptr<ModuleSummaryIndex>>
-  getModuleSummaryIndex(MemoryBufferRef Buffer);
+  getModuleSummaryIndex(const MemoryBufferRef &Buffer);
 
   /// Parse the specified bitcode buffer and merge the index into CombinedIndex.
-  Error readModuleSummaryIndex(MemoryBufferRef Buffer,
+  Error readModuleSummaryIndex(const MemoryBufferRef &Buffer,
                                ModuleSummaryIndex &CombinedIndex);
 
   /// Parse the module summary index out of an IR file and return the module
diff --git a/llvm/include/llvm/Bitcode/BitcodeWriter.h b/llvm/include/llvm/Bitcode/BitcodeWriter.h
index 2823b438f80bf4..db4c752abc5ed7 100644
--- a/llvm/include/llvm/Bitcode/BitcodeWriter.h
+++ b/llvm/include/llvm/Bitcode/BitcodeWriter.h
@@ -163,7 +163,7 @@ void writeIndexToFile(
 /// If EmbedCmdline is set, the command line is also exported in
 /// the corresponding section (__LLVM,_cmdline / .llvmcmd) - even if CmdArgs
 /// were empty.
-void embedBitcodeInModule(Module &M, MemoryBufferRef Buf, bool EmbedBitcode,
+void embedBitcodeInModule(Module &M, const MemoryBufferRef &Buf, bool EmbedBitcode,
                           bool EmbedCmdline,
                           const std::vector<uint8_t> &CmdArgs);
 
diff --git a/llvm/include/llvm/CGData/CodeGenData.h b/llvm/include/llvm/CGData/CodeGenData.h
index da0e412f2a0e03..ba62f7332818ff 100644
--- a/llvm/include/llvm/CGData/CodeGenData.h
+++ b/llvm/include/llvm/CGData/CodeGenData.h
@@ -265,7 +265,7 @@ std::unique_ptr<Module> loadModuleForTwoRounds(BitcodeModule &OrigModule,
 Expected<stable_hash> mergeCodeGenData(ArrayRef<StringRef> ObjectFiles);
 
 void warn(Error E, StringRef Whence = "");
-void warn(Twine Message, std::string Whence = "", std::string Hint = "");
+void warn(const Twine &Message, const std::string &Whence = "", const std::string &Hint = "");
 
 } // end namespace cgdata
 
diff --git a/llvm/include/llvm/CodeGen/AsmPrinter.h b/llvm/include/llvm/CodeGen/AsmPrinter.h
index 5291369b3b9f1d..18a99186bafe87 100644
--- a/llvm/include/llvm/CodeGen/AsmPrinter.h
+++ b/llvm/include/llvm/CodeGen/AsmPrinter.h
@@ -632,7 +632,7 @@ class AsmPrinter : public MachineFunctionPass {
                                          StringRef Suffix) const;
 
   /// Return the MCSymbol for the specified ExternalSymbol.
-  MCSymbol *GetExternalSymbolSymbol(Twine Sym) const;
+  MCSymbol *GetExternalSymbolSymbol(const Twine &Sym) const;
 
   /// Return the symbol for the specified jump table entry.
   MCSymbol *GetJTISymbol(unsigned JTID, bool isLinkerPrivate = false) const;
@@ -723,10 +723,10 @@ class AsmPrinter : public MachineFunctionPass {
   /// emitDwarfSymbolReference().
   ///
   /// The length of the emitted value depends on the DWARF format.
-  void emitDwarfStringOffset(DwarfStringPoolEntry S) const;
+  void emitDwarfStringOffset(const DwarfStringPoolEntry &S) const;
 
   /// Emit the 4-or 8-byte offset of a string from the start of its section.
-  void emitDwarfStringOffset(DwarfStringPoolEntryRef S) const {
+  void emitDwarfStringOffset(const DwarfStringPoolEntryRef &S) const {
     emitDwarfStringOffset(S.getEntry());
   }
 
diff --git a/llvm/include/llvm/CodeGen/BasicBlockSectionsProfileReader.h b/llvm/include/llvm/CodeGen/BasicBlockSectionsProfileReader.h
index 08e6a0e3ef6295..814879860b1b21 100644
--- a/llvm/include/llvm/CodeGen/BasicBlockSectionsProfileReader.h
+++ b/llvm/include/llvm/CodeGen/BasicBlockSectionsProfileReader.h
@@ -105,7 +105,7 @@ class BasicBlockSectionsProfileReader {
   }
 
   // Returns a profile parsing error for the current line.
-  Error createProfileParseError(Twine Message) const {
+  Error createProfileParseError(const Twine &Message) const {
     return make_error<StringError>(
         Twine("invalid profile " + MBuf->getBufferIdentifier() + " at line " +
               Twine(LineIt.line_number()) + ": " + Message),
diff --git a/llvm/include/llvm/CodeGen/MachineFunction.h b/llvm/include/llvm/CodeGen/MachineFunction.h
index c3eb27b9462879..861db8147438f7 100644
--- a/llvm/include/llvm/CodeGen/MachineFunction.h
+++ b/llvm/include/llvm/CodeGen/MachineFunction.h
@@ -1059,7 +1059,7 @@ class LLVM_ABI MachineFunction {
       AtomicOrdering Ordering = AtomicOrdering::NotAtomic,
       AtomicOrdering FailureOrdering = AtomicOrdering::NotAtomic);
   MachineMemOperand *getMachineMemOperand(
-      MachinePointerInfo PtrInfo, MachineMemOperand::Flags F, LocationSize Size,
+      const MachinePointerInfo &PtrInfo, MachineMemOperand::Flags F, LocationSize Size,
       Align BaseAlignment, const AAMDNodes &AAInfo = AAMDNodes(),
       const MDNode *Ranges = nullptr, SyncScope::ID SSID = SyncScope::System,
       AtomicOrdering Ordering = AtomicOrdering::NotAtomic,
diff --git a/llvm/include/llvm/CodeGen/SelectionDAG.h b/llvm/include/llvm/CodeGen/SelectionDAG.h
index 461c0c1ead16d2..2f0472661bf26c 100644
--- a/llvm/include/llvm/CodeGen/SelectionDAG.h
+++ b/llvm/include/llvm/CodeGen/SelectionDAG.h
@@ -1408,7 +1408,7 @@ class SelectionDAG {
                   const MDNode *Ranges = nullptr);
   inline SDValue getLoad(
       ISD::MemIndexedMode AM, ISD::LoadExtType ExtType, EVT VT, const SDLoc &dl,
-      SDValue Chain, SDValue Ptr, SDValue Offset, MachinePointerInfo PtrInfo,
+      SDValue Chain, SDValue Ptr, SDValue Offset, const MachinePointerInfo &PtrInfo,
       EVT MemVT, MaybeAlign Alignment = MaybeAlign(),
       MachineMemOperand::Flags MMOFlags = MachineMemOperand::MONone,
       const AAMDNodes &AAInfo = AAMDNodes(), const MDNode *Ranges = nullptr) {
diff --git a/llvm/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h b/llvm/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h
index 7780e233cab3b0..7864649c936608 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h
@@ -30,13 +30,13 @@ enum VisitorDataSource {
                     // supply the bytes.
 };
 
-Error visitTypeRecord(CVType &Record, TypeIndex Index,
+Error visitTypeRecord(CVType &Record, const TypeIndex &Index,
                       TypeVisitorCallbacks &Callbacks,
                       VisitorDataSource Source = VDS_BytesPresent);
 Error visitTypeRecord(CVType &Record, TypeVisitorCallbacks &Callbacks,
                       VisitorDataSource Source = VDS_BytesPresent);
 
-Error visitMemberRecord(CVMemberRecord Record, TypeVisitorCallbacks &Callbacks,
+Error visitMemberRecord(const CVMemberRecord &Record, TypeVisitorCallbacks &Callbacks,
                         VisitorDataSource Source = VDS_BytesPresent);
 Error visitMemberRecord(TypeLeafKind Kind, ArrayRef<uint8_t> Record,
                         TypeVisitorCallbacks &Callbacks);
diff --git a/llvm/include/llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h b/llvm/include/llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h
index f9d1507af5f3cd..abf3e63ca06ea9 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h
@@ -69,7 +69,7 @@ class DebugInlineeLinesSubsectionRef final : public DebugSubsectionRef {
   }
 
   Error initialize(BinaryStreamReader Reader);
-  Error initialize(BinaryStreamRef Section) {
+  Error initialize(const BinaryStreamRef &Section) {
     return initialize(BinaryStreamReader(Section));
   }
 
@@ -101,7 +101,7 @@ class DebugInlineeLinesSubsection final : public DebugSubsection {
   Error commit(BinaryStreamWriter &Writer) const override;
   uint32_t calculateSerializedSize() const override;
 
-  void addInlineSite(TypeIndex FuncId, StringRef FileName, uint32_t SourceLine);
+  void addInlineSite(const TypeIndex &FuncId, StringRef FileName, uint32_t SourceLine);
   void addExtraFile(StringRef FileName);
 
   bool hasExtraFiles() const { return HasExtraFiles; }
diff --git a/llvm/include/llvm/DebugInfo/CodeView/DebugStringTableSubsection.h b/llvm/include/llvm/DebugInfo/CodeView/DebugStringTableSubsection.h
index 6e5b8adddd4aef..7b3f0a78af3b6a 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/DebugStringTableSubsection.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/DebugStringTableSubsection.h
@@ -36,7 +36,7 @@ class DebugStringTableSubsectionRef : public DebugSubsectionRef {
     return S->kind() == DebugSubsectionKind::StringTable;
   }
 
-  Error initialize(BinaryStreamRef Contents);
+  Error initialize(const BinaryStreamRef &Contents);
   Error initialize(BinaryStreamReader &Reader);
 
   Expected<StringRef> getString(uint32_t Offset) const;
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h
index 02b402e86d2339..c5bdf5a5b65229 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h
@@ -173,7 +173,7 @@ class DWARFAbbreviationDeclaration {
   getAttributeValueFromOffset(uint32_t AttrIndex, uint64_t Offset,
                               const DWARFUnit &U) const;
 
-  llvm::Expected<ExtractState> extract(DataExtractor Data, uint64_t *OffsetPtr);
+  llvm::Expected<ExtractState> extract(const DataExtractor &Data, uint64_t *OffsetPtr);
   void dump(raw_ostream &OS) const;
 
   // Return an optional byte size of all attribute data in this abbreviation
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFAddressRange.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFAddressRange.h
index f4d6c451cbe1d6..55a8d89294bba0 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFAddressRange.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFAddressRange.h
@@ -68,7 +68,7 @@ struct DWARFAddressRange {
     return true;
   }
 
-  void dump(raw_ostream &OS, uint32_t AddressSize, DIDumpOptions DumpOpts = {},
+  void dump(raw_ostream &OS, uint32_t AddressSize, const DIDumpOptions &DumpOpts = {},
             const DWARFObject *Obj = nullptr) const;
 };
 
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h
index 6439827ef70f0f..138fbef4e79d83 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h
@@ -34,7 +34,7 @@ class DWARFAbbreviationDeclarationSet {
 
   uint64_t getOffset() const { return Offset; }
   void dump(raw_ostream &OS) const;
-  Error extract(DataExtractor Data, uint64_t *OffsetPtr);
+  Error extract(const DataExtractor &Data, uint64_t *OffsetPtr);
 
   const DWARFAbbreviationDeclaration *
   getAbbreviationDeclaration(uint32_t AbbrCode) const;
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAddr.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAddr.h
index ae2a4e2276da0f..1e7931277ec9d2 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAddr.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAddr.h
@@ -63,7 +63,7 @@ class DWARFDebugAddrTable {
   Error extractPreStandard(const DWARFDataExtractor &Data, uint64_t *OffsetPtr,
                            uint16_t CUVersion, uint8_t CUAddrSize);
 
-  void dump(raw_ostream &OS, DIDumpOptions DumpOpts = {}) const;
+  void dump(raw_ostream &OS, const DIDumpOptions &DumpOpts = {}) const;
 
   /// Return the address based on a given index.
   Expected<uint64_t> getAddrEntry(uint32_t Index) const;
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h
index 942de05f6bd84b..928d7889cbf234 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h
@@ -61,7 +61,7 @@ class DWARFDebugArangeSet {
   DWARFDebugArangeSet() { clear(); }
 
   void clear();
-  Error extract(DWARFDataExtractor data, uint64_t *offset_ptr,
+  Error extract(const DWARFDataExtractor &data, uint64_t *offset_ptr,
                 function_ref<void(Error)> WarningHandler = nullptr);
   void dump(raw_ostream &OS) const;
 
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h
index 068674cfae5c56..8661b2247b9d12 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h
@@ -27,7 +27,7 @@ class DWARFDebugAranges {
 
 private:
   void clear();
-  void extract(DWARFDataExtractor DebugArangesData,
+  void extract(const DWARFDataExtractor &DebugArangesData,
                function_ref<void(Error)> RecoverableErrorHandler,
                function_ref<void(Error)> WarningHandler);
 
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h
index a9a3c7edde691e..624116ab34672c 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h
@@ -124,8 +124,8 @@ class UnwindLocation {
   /// Create a location whose value is the result of evaluating a DWARF
   /// expression. This allows complex expressions to be evaluated in order to
   /// unwind a register or CFA value.
-  static UnwindLocation createIsDWARFExpression(DWARFExpression Expr);
-  static UnwindLocation createAtDWARFExpression(DWARFExpression Expr);
+  static UnwindLocation createIsDWARFExpression(const DWARFExpression &Expr);
+  static UnwindLocation createAtDWARFExpression(const DWARFExpression &Expr);
   static UnwindLocation createIsConstant(int32_t Value);
 
   Location getLocation() const { return Kind; }
@@ -164,7 +164,7 @@ class UnwindLocation {
   /// instead of from .debug_frame. This is needed for register number
   /// conversion because some register numbers differ bet...
[truncated]

@llvmbot llvmbot added backend:Hexagon vectorizers PGO Profile Guided Optimizations LTO Link time optimization (regular/full LTO or ThinLTO) backend:NVPTX llvm:transforms labels Jan 30, 2025
@jh7370
Copy link
Collaborator

jh7370 commented Jan 30, 2025

This PR needs breaking up into independent ones for easier review.

Also, I'm pretty sure MemoryBufferRef is intended for passing by value (note the Ref part of the name). It's just a pair of pointers... 16 bytes is too small. By that logic, std::string_view should be passed by const &, at least on Windows, but presumably for others too.

@GermanAizek
Copy link
Author

This PR needs breaking up into independent ones for easier review.

Also, I'm pretty sure MemoryBufferRef is intended for passing by value (note the Ref part of the name). It's just a pair of pointers... 16 bytes is too small. By that logic, std::string_view should be passed by const &, at least on Windows, but presumably for others too.

I can split this PR into different branches with others PR, and I also analyzed all structures and classes as parameters under Linux, if there is changing size from OS, more code reviewers (Windows, MacOS, BSD) are needed.

@jh7370
Copy link
Collaborator

jh7370 commented Jan 30, 2025

I can split this PR into different branches with others PR, and I also analyzed all structures and classes as parameters under Linux, if there is changing size from OS, more code reviewers (Windows, MacOS, BSD) are needed.

I think you need consensus on the idea that 16 bytes is a reasonably boundary. I'm not convinced it is. Certainly, I don't think a 16-byte struct should be passed by const & unconditionally. As this is a wide-impacting change, that will likely need a coding standards update, I suggest you raise this on LLVM's Discourse before proceeding further. See https://discourse.llvm.org/.

@GermanAizek
Copy link
Author

GermanAizek commented Jan 30, 2025

I think you need consensus on idea that 16 bytes is a reasonably boundary. I'm not convinced it is. Certainly, I don't think a 16-byte struct should be passed by const & unconditionally.

This has already been discussed in context C language and simple structures, but in the case C++, everything is different.
https://www.reddit.com/r/C_Programming/comments/14ki3vl/returning_a_16_byte_struct_vs_passing_a_pointer/

I'll create topic on forum, let's see how most people respond.

@jrtc27
Copy link
Collaborator

jrtc27 commented Jan 30, 2025

Sizes of structures changes between platforms. We have one where pointers are 16 bytes, yet this would mandate all pointers are passed by const reference, which is itself 16 bytes, clearly wrong.

@jrtc27
Copy link
Collaborator

jrtc27 commented Jan 30, 2025

Also, for types that come from other libraries (libc, STL, or other third-party ones), their sizes may vary. For example, FreeBSD's pthread_mutex_t is a pointer to the real data, whilst GNU/Linux's is the struct itself. How are we deciding which to use? Do we go with the biggest or the smallest?

@hiraditya
Copy link
Collaborator

Agreed with @jrtc27, better to create an RFC on discourse and get feedback before putting this patch for review.

@JDevlieghere
Copy link
Member

This PR also passes Twine by value while it really should be passed by const ref as it's not meant to be stored.

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.

6 participants