Skip to content

Commit

Permalink
[NFC][MachineInstr] Pass-by-value DebugLoc in CreateMachineInstr
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mtrofin committed Dec 7, 2021
1 parent 02095f2 commit 2bd7384
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion llvm/include/llvm/CodeGen/MachineFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/CodeGen/MachineFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 2bd7384

Please sign in to comment.