Move DebugLocs around instead of copying.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228491 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Benjamin Kramer 2015-02-07 12:28:15 +00:00
parent fdac306a12
commit 74cdff870f
5 changed files with 27 additions and 30 deletions

View File

@ -110,8 +110,8 @@ private:
/// MachineInstr ctor - This constructor create a MachineInstr and add the /// MachineInstr ctor - This constructor create a MachineInstr and add the
/// implicit operands. It reserves space for number of operands specified by /// implicit operands. It reserves space for number of operands specified by
/// MCInstrDesc. An explicit DebugLoc is supplied. /// MCInstrDesc. An explicit DebugLoc is supplied.
MachineInstr(MachineFunction&, const MCInstrDesc &MCID, MachineInstr(MachineFunction &, const MCInstrDesc &MCID, DebugLoc dl,
const DebugLoc dl, bool NoImp = false); bool NoImp = false);
// MachineInstrs are pool-allocated and owned by MachineFunction. // MachineInstrs are pool-allocated and owned by MachineFunction.
friend class MachineFunction; friend class MachineFunction;
@ -242,7 +242,7 @@ public:
/// getDebugLoc - Returns the debug location id of this MachineInstr. /// getDebugLoc - Returns the debug location id of this MachineInstr.
/// ///
DebugLoc getDebugLoc() const { return debugLoc; } const DebugLoc &getDebugLoc() const { return debugLoc; }
/// \brief Return the debug variable referenced by /// \brief Return the debug variable referenced by
/// this DBG_VALUE instruction. /// this DBG_VALUE instruction.
@ -1147,8 +1147,8 @@ public:
/// setDebugLoc - Replace current source information with new such. /// setDebugLoc - Replace current source information with new such.
/// Avoid using this, the constructor argument is preferable. /// Avoid using this, the constructor argument is preferable.
/// ///
void setDebugLoc(const DebugLoc dl) { void setDebugLoc(DebugLoc dl) {
debugLoc = dl; debugLoc = std::move(dl);
assert(debugLoc.hasTrivialDestructor() && "Expected trivial destructor"); assert(debugLoc.hasTrivialDestructor() && "Expected trivial destructor");
} }

View File

@ -184,7 +184,7 @@ public:
inline bool isTargetOpcode() const; inline bool isTargetOpcode() const;
inline bool isMachineOpcode() const; inline bool isMachineOpcode() const;
inline unsigned getMachineOpcode() const; inline unsigned getMachineOpcode() const;
inline const DebugLoc getDebugLoc() const; inline const DebugLoc &getDebugLoc() const;
inline void dump() const; inline void dump() const;
inline void dumpr() const; inline void dumpr() const;
@ -476,11 +476,11 @@ public:
void setIROrder(unsigned Order) { IROrder = Order; } void setIROrder(unsigned Order) { IROrder = Order; }
/// getDebugLoc - Return the source location info. /// getDebugLoc - Return the source location info.
const DebugLoc getDebugLoc() const { return debugLoc; } const DebugLoc &getDebugLoc() const { return debugLoc; }
/// setDebugLoc - Set source location info. Try to avoid this, putting /// setDebugLoc - Set source location info. Try to avoid this, putting
/// it in the constructor is preferable. /// it in the constructor is preferable.
void setDebugLoc(const DebugLoc dl) { debugLoc = dl; } void setDebugLoc(DebugLoc dl) { debugLoc = std::move(dl); }
/// use_iterator - This class provides iterator support for SDUse /// use_iterator - This class provides iterator support for SDUse
/// operands that use a specific SDNode. /// operands that use a specific SDNode.
@ -754,14 +754,13 @@ protected:
return Ret; return Ret;
} }
SDNode(unsigned Opc, unsigned Order, const DebugLoc dl, SDVTList VTs, SDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs,
ArrayRef<SDValue> Ops) ArrayRef<SDValue> Ops)
: NodeType(Opc), OperandsNeedDelete(true), HasDebugValue(false), : NodeType(Opc), OperandsNeedDelete(true), HasDebugValue(false),
SubclassData(0), NodeId(-1), SubclassData(0), NodeId(-1),
OperandList(Ops.size() ? new SDUse[Ops.size()] : nullptr), OperandList(Ops.size() ? new SDUse[Ops.size()] : nullptr),
ValueList(VTs.VTs), UseList(nullptr), ValueList(VTs.VTs), UseList(nullptr), NumOperands(Ops.size()),
NumOperands(Ops.size()), NumValues(VTs.NumVTs), NumValues(VTs.NumVTs), debugLoc(std::move(dl)), IROrder(Order) {
debugLoc(dl), IROrder(Order) {
assert(debugLoc.hasTrivialDestructor() && "Expected trivial destructor"); assert(debugLoc.hasTrivialDestructor() && "Expected trivial destructor");
assert(NumOperands == Ops.size() && assert(NumOperands == Ops.size() &&
"NumOperands wasn't wide enough for its operands!"); "NumOperands wasn't wide enough for its operands!");
@ -777,11 +776,11 @@ protected:
/// This constructor adds no operands itself; operands can be /// This constructor adds no operands itself; operands can be
/// set later with InitOperands. /// set later with InitOperands.
SDNode(unsigned Opc, unsigned Order, const DebugLoc dl, SDVTList VTs) SDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs)
: NodeType(Opc), OperandsNeedDelete(false), HasDebugValue(false), : NodeType(Opc), OperandsNeedDelete(false), HasDebugValue(false),
SubclassData(0), NodeId(-1), OperandList(nullptr), ValueList(VTs.VTs), SubclassData(0), NodeId(-1), OperandList(nullptr), ValueList(VTs.VTs),
UseList(nullptr), NumOperands(0), NumValues(VTs.NumVTs), debugLoc(dl), UseList(nullptr), NumOperands(0), NumValues(VTs.NumVTs),
IROrder(Order) { debugLoc(std::move(dl)), IROrder(Order) {
assert(debugLoc.hasTrivialDestructor() && "Expected trivial destructor"); assert(debugLoc.hasTrivialDestructor() && "Expected trivial destructor");
assert(NumValues == VTs.NumVTs && assert(NumValues == VTs.NumVTs &&
"NumValues wasn't wide enough for its operands!"); "NumValues wasn't wide enough for its operands!");
@ -945,7 +944,7 @@ inline bool SDValue::use_empty() const {
inline bool SDValue::hasOneUse() const { inline bool SDValue::hasOneUse() const {
return Node->hasNUsesOfValue(1, ResNo); return Node->hasNUsesOfValue(1, ResNo);
} }
inline const DebugLoc SDValue::getDebugLoc() const { inline const DebugLoc &SDValue::getDebugLoc() const {
return Node->getDebugLoc(); return Node->getDebugLoc();
} }
inline void SDValue::dump() const { inline void SDValue::dump() const {

View File

@ -115,12 +115,10 @@ public:
} }
/// \brief Set location information used by debugging information. /// \brief Set location information used by debugging information.
void SetCurrentDebugLocation(const DebugLoc &L) { void SetCurrentDebugLocation(DebugLoc L) { CurDbgLocation = std::move(L); }
CurDbgLocation = L;
}
/// \brief Get location information used by debugging information. /// \brief Get location information used by debugging information.
DebugLoc getCurrentDebugLocation() const { return CurDbgLocation; } const DebugLoc &getCurrentDebugLocation() const { return CurDbgLocation; }
/// \brief If this builder has a current debug location, set it on the /// \brief If this builder has a current debug location, set it on the
/// specified instruction. /// specified instruction.

View File

@ -201,7 +201,7 @@ public:
void setAAMetadata(const AAMDNodes &N); void setAAMetadata(const AAMDNodes &N);
/// setDebugLoc - Set the debug location information for this instruction. /// setDebugLoc - Set the debug location information for this instruction.
void setDebugLoc(const DebugLoc &Loc) { DbgLoc = Loc; } void setDebugLoc(DebugLoc Loc) { DbgLoc = std::move(Loc); }
/// getDebugLoc - Return the debug location for this node as a DebugLoc. /// getDebugLoc - Return the debug location for this node as a DebugLoc.
const DebugLoc &getDebugLoc() const { return DbgLoc; } const DebugLoc &getDebugLoc() const { return DbgLoc; }

View File

@ -595,10 +595,10 @@ void MachineInstr::addImplicitDefUseOperands(MachineFunction &MF) {
/// implicit operands. It reserves space for the number of operands specified by /// implicit operands. It reserves space for the number of operands specified by
/// the MCInstrDesc. /// the MCInstrDesc.
MachineInstr::MachineInstr(MachineFunction &MF, const MCInstrDesc &tid, MachineInstr::MachineInstr(MachineFunction &MF, const MCInstrDesc &tid,
const DebugLoc dl, bool NoImp) DebugLoc dl, bool NoImp)
: MCID(&tid), Parent(nullptr), Operands(nullptr), NumOperands(0), : MCID(&tid), Parent(nullptr), Operands(nullptr), NumOperands(0), Flags(0),
Flags(0), AsmPrinterFlags(0), AsmPrinterFlags(0), NumMemRefs(0), MemRefs(nullptr),
NumMemRefs(0), MemRefs(nullptr), debugLoc(dl) { debugLoc(std::move(dl)) {
assert(debugLoc.hasTrivialDestructor() && "Expected trivial destructor"); assert(debugLoc.hasTrivialDestructor() && "Expected trivial destructor");
// Reserve space for the expected number of operands. // Reserve space for the expected number of operands.