[llvm] 2bd7384 - [NFC][MachineInstr] Pass-by-value DebugLoc in CreateMachineInstr

Mircea Trofin via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 6 19:45:20 PST 2021


Author: Mircea Trofin
Date: 2021-12-06T19:42:19-08:00
New Revision: 2bd7384d3a99edd345fcc5e8ee8d550bd65dddb2

URL: https://github.com/llvm/llvm-project/commit/2bd7384d3a99edd345fcc5e8ee8d550bd65dddb2
DIFF: https://github.com/llvm/llvm-project/commit/2bd7384d3a99edd345fcc5e8ee8d550bd65dddb2.diff

LOG: [NFC][MachineInstr] Pass-by-value DebugLoc in CreateMachineInstr

DebugLoc is cheap to move, passing it by-val rather than const ref to
take advantage of the fact that it is consumed that way by the
MachineInstr ctor, which creates some optimization oportunities.

Differential Revision: https://reviews.llvm.org/D115208

Added: 
    

Modified: 
    llvm/include/llvm/CodeGen/MachineFunction.h
    llvm/lib/CodeGen/MachineFunction.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/CodeGen/MachineFunction.h b/llvm/include/llvm/CodeGen/MachineFunction.h
index d661711251d90..8767f91b36319 100644
--- a/llvm/include/llvm/CodeGen/MachineFunction.h
+++ b/llvm/include/llvm/CodeGen/MachineFunction.h
@@ -890,7 +890,7 @@ class LLVM_EXTERNAL_VISIBILITY MachineFunction {
 
   /// CreateMachineInstr - Allocate a new MachineInstr. Use this instead
   /// of `new MachineInstr'.
-  MachineInstr *CreateMachineInstr(const MCInstrDesc &MCID, const DebugLoc &DL,
+  MachineInstr *CreateMachineInstr(const MCInstrDesc &MCID, DebugLoc DL,
                                    bool NoImplicit = false);
 
   /// Create a new MachineInstr which is a copy of \p Orig, identical in all

diff  --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp
index b6f1a6e64e758..c249dd8e58f33 100644
--- a/llvm/lib/CodeGen/MachineFunction.cpp
+++ b/llvm/lib/CodeGen/MachineFunction.cpp
@@ -350,10 +350,10 @@ void MachineFunction::assignBeginEndSections() {
 
 /// Allocate a new MachineInstr. Use this instead of `new MachineInstr'.
 MachineInstr *MachineFunction::CreateMachineInstr(const MCInstrDesc &MCID,
-                                                  const DebugLoc &DL,
+                                                  DebugLoc DL,
                                                   bool NoImplicit) {
   return new (InstructionRecycler.Allocate<MachineInstr>(Allocator))
-      MachineInstr(*this, MCID, DL, NoImplicit);
+      MachineInstr(*this, MCID, std::move(DL), NoImplicit);
 }
 
 /// Create a new MachineInstr which is a copy of the 'Orig' instruction,


        


More information about the llvm-commits mailing list