|
@@ -34,14 +34,13 @@
|
|
#include "llvm/CodeGen/MachineMemOperand.h"
|
|
#include "llvm/CodeGen/MachineMemOperand.h"
|
|
#include "llvm/CodeGen/MachineOperand.h"
|
|
#include "llvm/CodeGen/MachineOperand.h"
|
|
#include "llvm/CodeGen/PseudoSourceValue.h"
|
|
#include "llvm/CodeGen/PseudoSourceValue.h"
|
|
-#include "llvm/CodeGen/RegisterScavenging.h"
|
|
|
|
#include "llvm/CodeGen/TargetFrameLowering.h"
|
|
#include "llvm/CodeGen/TargetFrameLowering.h"
|
|
#include "llvm/CodeGen/TargetInstrInfo.h"
|
|
#include "llvm/CodeGen/TargetInstrInfo.h"
|
|
#include "llvm/CodeGen/TargetLowering.h"
|
|
#include "llvm/CodeGen/TargetLowering.h"
|
|
#include "llvm/CodeGen/TargetRegisterInfo.h"
|
|
#include "llvm/CodeGen/TargetRegisterInfo.h"
|
|
#include "llvm/CodeGen/TargetSubtargetInfo.h"
|
|
#include "llvm/CodeGen/TargetSubtargetInfo.h"
|
|
|
|
+#include "llvm/CodeGen/RegisterScavenging.h"
|
|
#include "llvm/Config/llvm-config.h"
|
|
#include "llvm/Config/llvm-config.h"
|
|
-#include "llvm/IR/DIBuilder.h"
|
|
|
|
#include "llvm/IR/DebugInfoMetadata.h"
|
|
#include "llvm/IR/DebugInfoMetadata.h"
|
|
#include "llvm/IR/DebugLoc.h"
|
|
#include "llvm/IR/DebugLoc.h"
|
|
#include "llvm/IR/Function.h"
|
|
#include "llvm/IR/Function.h"
|
|
@@ -86,8 +85,6 @@ private:
|
|
BitVector CalleeSavedRegs;
|
|
BitVector CalleeSavedRegs;
|
|
LexicalScopes LS;
|
|
LexicalScopes LS;
|
|
|
|
|
|
- enum struct TransferKind { TransferCopy, TransferSpill, TransferRestore };
|
|
|
|
-
|
|
|
|
/// Keeps track of lexical scopes associated with a user value's source
|
|
/// Keeps track of lexical scopes associated with a user value's source
|
|
/// location.
|
|
/// location.
|
|
class UserValueScopes {
|
|
class UserValueScopes {
|
|
@@ -127,30 +124,15 @@ private:
|
|
|
|
|
|
/// A pair of debug variable and value location.
|
|
/// A pair of debug variable and value location.
|
|
struct VarLoc {
|
|
struct VarLoc {
|
|
- // The location at which a spilled variable resides. It consists of a
|
|
|
|
- // register and an offset.
|
|
|
|
- struct SpillLoc {
|
|
|
|
- unsigned SpillBase;
|
|
|
|
- int SpillOffset;
|
|
|
|
- bool operator==(const SpillLoc &Other) const {
|
|
|
|
- return SpillBase == Other.SpillBase && SpillOffset == Other.SpillOffset;
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
const DebugVariable Var;
|
|
const DebugVariable Var;
|
|
const MachineInstr &MI; ///< Only used for cloning a new DBG_VALUE.
|
|
const MachineInstr &MI; ///< Only used for cloning a new DBG_VALUE.
|
|
mutable UserValueScopes UVS;
|
|
mutable UserValueScopes UVS;
|
|
- enum VarLocKind {
|
|
|
|
- InvalidKind = 0,
|
|
|
|
- RegisterKind,
|
|
|
|
- SpillLocKind
|
|
|
|
- } Kind = InvalidKind;
|
|
|
|
|
|
+ enum { InvalidKind = 0, RegisterKind } Kind = InvalidKind;
|
|
|
|
|
|
/// The value location. Stored separately to avoid repeatedly
|
|
/// The value location. Stored separately to avoid repeatedly
|
|
/// extracting it from MI.
|
|
/// extracting it from MI.
|
|
union {
|
|
union {
|
|
uint64_t RegNo;
|
|
uint64_t RegNo;
|
|
- SpillLoc SpillLocation;
|
|
|
|
uint64_t Hash;
|
|
uint64_t Hash;
|
|
} Loc;
|
|
} Loc;
|
|
|
|
|
|
@@ -167,17 +149,6 @@ private:
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- /// The constructor for spill locations.
|
|
|
|
- VarLoc(const MachineInstr &MI, unsigned SpillBase, int SpillOffset,
|
|
|
|
- LexicalScopes &LS)
|
|
|
|
- : Var(MI.getDebugVariable(), MI.getDebugLoc()->getInlinedAt()), MI(MI),
|
|
|
|
- UVS(MI.getDebugLoc(), LS) {
|
|
|
|
- assert(MI.isDebugValue() && "not a DBG_VALUE");
|
|
|
|
- assert(MI.getNumOperands() == 4 && "malformed DBG_VALUE");
|
|
|
|
- Kind = SpillLocKind;
|
|
|
|
- Loc.SpillLocation = {SpillBase, SpillOffset};
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/// If this variable is described by a register, return it,
|
|
/// If this variable is described by a register, return it,
|
|
/// otherwise return 0.
|
|
/// otherwise return 0.
|
|
unsigned isDescribedByReg() const {
|
|
unsigned isDescribedByReg() const {
|
|
@@ -265,23 +236,15 @@ private:
|
|
|
|
|
|
bool isSpillInstruction(const MachineInstr &MI, MachineFunction *MF,
|
|
bool isSpillInstruction(const MachineInstr &MI, MachineFunction *MF,
|
|
unsigned &Reg);
|
|
unsigned &Reg);
|
|
- /// If a given instruction is identified as a spill, return the spill location
|
|
|
|
- /// and set \p Reg to the spilled register.
|
|
|
|
- Optional<VarLoc::SpillLoc> isRestoreInstruction(const MachineInstr &MI,
|
|
|
|
- MachineFunction *MF,
|
|
|
|
- unsigned &Reg);
|
|
|
|
- /// Given a spill instruction, extract the register and offset used to
|
|
|
|
- /// address the spill location in a target independent way.
|
|
|
|
- VarLoc::SpillLoc extractSpillBaseRegAndOffset(const MachineInstr &MI);
|
|
|
|
|
|
+ int extractSpillBaseRegAndOffset(const MachineInstr &MI, unsigned &Reg);
|
|
void insertTransferDebugPair(MachineInstr &MI, OpenRangesSet &OpenRanges,
|
|
void insertTransferDebugPair(MachineInstr &MI, OpenRangesSet &OpenRanges,
|
|
TransferMap &Transfers, VarLocMap &VarLocIDs,
|
|
TransferMap &Transfers, VarLocMap &VarLocIDs,
|
|
- unsigned OldVarID, TransferKind Kind,
|
|
|
|
- unsigned NewReg = 0);
|
|
|
|
|
|
+ unsigned OldVarID, unsigned NewReg = 0);
|
|
|
|
|
|
void transferDebugValue(const MachineInstr &MI, OpenRangesSet &OpenRanges,
|
|
void transferDebugValue(const MachineInstr &MI, OpenRangesSet &OpenRanges,
|
|
VarLocMap &VarLocIDs);
|
|
VarLocMap &VarLocIDs);
|
|
- void transferSpillOrRestoreInst(MachineInstr &MI, OpenRangesSet &OpenRanges,
|
|
|
|
- VarLocMap &VarLocIDs, TransferMap &Transfers);
|
|
|
|
|
|
+ void transferSpillInst(MachineInstr &MI, OpenRangesSet &OpenRanges,
|
|
|
|
+ VarLocMap &VarLocIDs, TransferMap &Transfers);
|
|
void transferRegisterCopy(MachineInstr &MI, OpenRangesSet &OpenRanges,
|
|
void transferRegisterCopy(MachineInstr &MI, OpenRangesSet &OpenRanges,
|
|
VarLocMap &VarLocIDs, TransferMap &Transfers);
|
|
VarLocMap &VarLocIDs, TransferMap &Transfers);
|
|
void transferRegisterDef(MachineInstr &MI, OpenRangesSet &OpenRanges,
|
|
void transferRegisterDef(MachineInstr &MI, OpenRangesSet &OpenRanges,
|
|
@@ -375,8 +338,10 @@ void LiveDebugValues::printVarLocInMBB(const MachineFunction &MF,
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
|
|
-LiveDebugValues::VarLoc::SpillLoc
|
|
|
|
-LiveDebugValues::extractSpillBaseRegAndOffset(const MachineInstr &MI) {
|
|
|
|
|
|
+/// Given a spill instruction, extract the register and offset used to
|
|
|
|
+/// address the spill location in a target independent way.
|
|
|
|
+int LiveDebugValues::extractSpillBaseRegAndOffset(const MachineInstr &MI,
|
|
|
|
+ unsigned &Reg) {
|
|
assert(MI.hasOneMemOperand() &&
|
|
assert(MI.hasOneMemOperand() &&
|
|
"Spill instruction does not have exactly one memory operand?");
|
|
"Spill instruction does not have exactly one memory operand?");
|
|
auto MMOI = MI.memoperands_begin();
|
|
auto MMOI = MI.memoperands_begin();
|
|
@@ -385,9 +350,7 @@ LiveDebugValues::extractSpillBaseRegAndOffset(const MachineInstr &MI) {
|
|
"Inconsistent memory operand in spill instruction");
|
|
"Inconsistent memory operand in spill instruction");
|
|
int FI = cast<FixedStackPseudoSourceValue>(PVal)->getFrameIndex();
|
|
int FI = cast<FixedStackPseudoSourceValue>(PVal)->getFrameIndex();
|
|
const MachineBasicBlock *MBB = MI.getParent();
|
|
const MachineBasicBlock *MBB = MI.getParent();
|
|
- unsigned Reg;
|
|
|
|
- int Offset = TFI->getFrameIndexReference(*MBB->getParent(), FI, Reg);
|
|
|
|
- return {Reg, Offset};
|
|
|
|
|
|
+ return TFI->getFrameIndexReference(*MBB->getParent(), FI, Reg);
|
|
}
|
|
}
|
|
|
|
|
|
/// End all previous ranges related to @MI and start a new range from @MI
|
|
/// End all previous ranges related to @MI and start a new range from @MI
|
|
@@ -423,28 +386,11 @@ void LiveDebugValues::transferDebugValue(const MachineInstr &MI,
|
|
/// otherwise it is variable's location on the stack.
|
|
/// otherwise it is variable's location on the stack.
|
|
void LiveDebugValues::insertTransferDebugPair(
|
|
void LiveDebugValues::insertTransferDebugPair(
|
|
MachineInstr &MI, OpenRangesSet &OpenRanges, TransferMap &Transfers,
|
|
MachineInstr &MI, OpenRangesSet &OpenRanges, TransferMap &Transfers,
|
|
- VarLocMap &VarLocIDs, unsigned OldVarID, TransferKind Kind,
|
|
|
|
- unsigned NewReg) {
|
|
|
|
|
|
+ VarLocMap &VarLocIDs, unsigned OldVarID, unsigned NewReg) {
|
|
const MachineInstr *DMI = &VarLocIDs[OldVarID].MI;
|
|
const MachineInstr *DMI = &VarLocIDs[OldVarID].MI;
|
|
MachineFunction *MF = MI.getParent()->getParent();
|
|
MachineFunction *MF = MI.getParent()->getParent();
|
|
MachineInstr *NewDMI;
|
|
MachineInstr *NewDMI;
|
|
-
|
|
|
|
- auto ProcessVarLoc = [&MI, &OpenRanges, &Transfers,
|
|
|
|
- &VarLocIDs](VarLoc &VL, MachineInstr *NewDMI) {
|
|
|
|
- unsigned LocId = VarLocIDs.insert(VL);
|
|
|
|
- OpenRanges.insert(LocId, VL.Var);
|
|
|
|
- // The newly created DBG_VALUE instruction NewDMI must be inserted after
|
|
|
|
- // MI. Keep track of the pairing.
|
|
|
|
- TransferDebugPair MIP = {&MI, NewDMI};
|
|
|
|
- Transfers.push_back(MIP);
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- // End all previous ranges of Var.
|
|
|
|
- OpenRanges.erase(VarLocIDs[OldVarID].Var);
|
|
|
|
- switch (Kind) {
|
|
|
|
- case TransferKind::TransferCopy: {
|
|
|
|
- assert(NewReg &&
|
|
|
|
- "No register supplied when handling a copy of a debug value");
|
|
|
|
|
|
+ if (NewReg) {
|
|
// Create a DBG_VALUE instruction to describe the Var in its new
|
|
// Create a DBG_VALUE instruction to describe the Var in its new
|
|
// register location.
|
|
// register location.
|
|
NewDMI = BuildMI(*MF, DMI->getDebugLoc(), DMI->getDesc(),
|
|
NewDMI = BuildMI(*MF, DMI->getDebugLoc(), DMI->getDesc(),
|
|
@@ -452,43 +398,33 @@ void LiveDebugValues::insertTransferDebugPair(
|
|
DMI->getDebugVariable(), DMI->getDebugExpression());
|
|
DMI->getDebugVariable(), DMI->getDebugExpression());
|
|
if (DMI->isIndirectDebugValue())
|
|
if (DMI->isIndirectDebugValue())
|
|
NewDMI->getOperand(1).setImm(DMI->getOperand(1).getImm());
|
|
NewDMI->getOperand(1).setImm(DMI->getOperand(1).getImm());
|
|
- VarLoc VL(*NewDMI, LS);
|
|
|
|
- ProcessVarLoc(VL, NewDMI);
|
|
|
|
LLVM_DEBUG(dbgs() << "Creating DBG_VALUE inst for register copy: ";
|
|
LLVM_DEBUG(dbgs() << "Creating DBG_VALUE inst for register copy: ";
|
|
NewDMI->print(dbgs(), false, false, false, TII));
|
|
NewDMI->print(dbgs(), false, false, false, TII));
|
|
- return;
|
|
|
|
- }
|
|
|
|
- case TransferKind::TransferSpill: {
|
|
|
|
|
|
+ } else {
|
|
// Create a DBG_VALUE instruction to describe the Var in its spilled
|
|
// Create a DBG_VALUE instruction to describe the Var in its spilled
|
|
// location.
|
|
// location.
|
|
- VarLoc::SpillLoc SpillLocation = extractSpillBaseRegAndOffset(MI);
|
|
|
|
- auto *SpillExpr =
|
|
|
|
- DIExpression::prepend(DMI->getDebugExpression(), DIExpression::NoDeref,
|
|
|
|
- SpillLocation.SpillOffset);
|
|
|
|
- NewDMI =
|
|
|
|
- BuildMI(*MF, DMI->getDebugLoc(), DMI->getDesc(), true,
|
|
|
|
- SpillLocation.SpillBase, DMI->getDebugVariable(), SpillExpr);
|
|
|
|
- VarLoc VL(*NewDMI, SpillLocation.SpillBase, SpillLocation.SpillOffset, LS);
|
|
|
|
- ProcessVarLoc(VL, NewDMI);
|
|
|
|
|
|
+ unsigned SpillBase;
|
|
|
|
+ int SpillOffset = extractSpillBaseRegAndOffset(MI, SpillBase);
|
|
|
|
+ auto *SpillExpr = DIExpression::prepend(DMI->getDebugExpression(),
|
|
|
|
+ DIExpression::NoDeref, SpillOffset);
|
|
|
|
+ NewDMI = BuildMI(*MF, DMI->getDebugLoc(), DMI->getDesc(), true, SpillBase,
|
|
|
|
+ DMI->getDebugVariable(), SpillExpr);
|
|
LLVM_DEBUG(dbgs() << "Creating DBG_VALUE inst for spill: ";
|
|
LLVM_DEBUG(dbgs() << "Creating DBG_VALUE inst for spill: ";
|
|
NewDMI->print(dbgs(), false, false, false, TII));
|
|
NewDMI->print(dbgs(), false, false, false, TII));
|
|
- return;
|
|
|
|
- }
|
|
|
|
- case TransferKind::TransferRestore: {
|
|
|
|
- assert(NewReg &&
|
|
|
|
- "No register supplied when handling a restore of a debug value");
|
|
|
|
- MachineFunction *MF = MI.getMF();
|
|
|
|
- DIBuilder DIB(*const_cast<Function &>(MF->getFunction()).getParent());
|
|
|
|
- NewDMI = BuildMI(*MF, DMI->getDebugLoc(), DMI->getDesc(), false, NewReg,
|
|
|
|
- DMI->getDebugVariable(), DIB.createExpression());
|
|
|
|
- VarLoc VL(*NewDMI, LS);
|
|
|
|
- ProcessVarLoc(VL, NewDMI);
|
|
|
|
- LLVM_DEBUG(dbgs() << "Creating DBG_VALUE inst for register restore: ";
|
|
|
|
- NewDMI->print(dbgs(), false, false, false, TII));
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
- llvm_unreachable("Invalid transfer kind");
|
|
|
|
|
|
+
|
|
|
|
+ // The newly created DBG_VALUE instruction NewDMI must be inserted after
|
|
|
|
+ // MI. Keep track of the pairing.
|
|
|
|
+ TransferDebugPair MIP = {&MI, NewDMI};
|
|
|
|
+ Transfers.push_back(MIP);
|
|
|
|
+
|
|
|
|
+ // End all previous ranges of Var.
|
|
|
|
+ OpenRanges.erase(VarLocIDs[OldVarID].Var);
|
|
|
|
+
|
|
|
|
+ // Add the VarLoc to OpenRanges.
|
|
|
|
+ VarLoc VL(*NewDMI, LS);
|
|
|
|
+ unsigned LocID = VarLocIDs.insert(VL);
|
|
|
|
+ OpenRanges.insert(LocID, VL.Var);
|
|
}
|
|
}
|
|
|
|
|
|
/// A definition of a register may mark the end of a range.
|
|
/// A definition of a register may mark the end of a range.
|
|
@@ -534,15 +470,24 @@ void LiveDebugValues::transferRegisterDef(MachineInstr &MI,
|
|
/// other spills). We do not handle this yet (more than one memory operand).
|
|
/// other spills). We do not handle this yet (more than one memory operand).
|
|
bool LiveDebugValues::isSpillInstruction(const MachineInstr &MI,
|
|
bool LiveDebugValues::isSpillInstruction(const MachineInstr &MI,
|
|
MachineFunction *MF, unsigned &Reg) {
|
|
MachineFunction *MF, unsigned &Reg) {
|
|
|
|
+ const MachineFrameInfo &FrameInfo = MF->getFrameInfo();
|
|
|
|
+ int FI;
|
|
SmallVector<const MachineMemOperand*, 1> Accesses;
|
|
SmallVector<const MachineMemOperand*, 1> Accesses;
|
|
|
|
|
|
// TODO: Handle multiple stores folded into one.
|
|
// TODO: Handle multiple stores folded into one.
|
|
if (!MI.hasOneMemOperand())
|
|
if (!MI.hasOneMemOperand())
|
|
return false;
|
|
return false;
|
|
|
|
|
|
- if (!MI.getSpillSize(TII) && !MI.getFoldedSpillSize(TII))
|
|
|
|
- return false; // This is not a spill instruction, since no valid size was
|
|
|
|
- // returned from either function.
|
|
|
|
|
|
+ // To identify a spill instruction, use the same criteria as in AsmPrinter.
|
|
|
|
+ if (!((TII->isStoreToStackSlotPostFE(MI, FI) &&
|
|
|
|
+ FrameInfo.isSpillSlotObjectIndex(FI)) ||
|
|
|
|
+ (TII->hasStoreToStackSlot(MI, Accesses) &&
|
|
|
|
+ llvm::any_of(Accesses, [&FrameInfo](const MachineMemOperand *MMO) {
|
|
|
|
+ return FrameInfo.isSpillSlotObjectIndex(
|
|
|
|
+ cast<FixedStackPseudoSourceValue>(MMO->getPseudoValue())
|
|
|
|
+ ->getFrameIndex());
|
|
|
|
+ }))))
|
|
|
|
+ return false;
|
|
|
|
|
|
auto isKilledReg = [&](const MachineOperand MO, unsigned &Reg) {
|
|
auto isKilledReg = [&](const MachineOperand MO, unsigned &Reg) {
|
|
if (!MO.isReg() || !MO.isUse()) {
|
|
if (!MO.isReg() || !MO.isUse()) {
|
|
@@ -579,64 +524,29 @@ bool LiveDebugValues::isSpillInstruction(const MachineInstr &MI,
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
-Optional<LiveDebugValues::VarLoc::SpillLoc>
|
|
|
|
-LiveDebugValues::isRestoreInstruction(const MachineInstr &MI,
|
|
|
|
- MachineFunction *MF, unsigned &Reg) {
|
|
|
|
- if (!MI.hasOneMemOperand())
|
|
|
|
- return None;
|
|
|
|
-
|
|
|
|
- // FIXME: Handle folded restore instructions with more than one memory
|
|
|
|
- // operand.
|
|
|
|
- if (MI.getRestoreSize(TII)) {
|
|
|
|
- Reg = MI.getOperand(0).getReg();
|
|
|
|
- return extractSpillBaseRegAndOffset(MI);
|
|
|
|
- }
|
|
|
|
- return None;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
/// A spilled register may indicate that we have to end the current range of
|
|
/// A spilled register may indicate that we have to end the current range of
|
|
/// a variable and create a new one for the spill location.
|
|
/// a variable and create a new one for the spill location.
|
|
-/// A restored register may indicate the reverse situation.
|
|
|
|
/// We don't want to insert any instructions in process(), so we just create
|
|
/// We don't want to insert any instructions in process(), so we just create
|
|
/// the DBG_VALUE without inserting it and keep track of it in \p Transfers.
|
|
/// the DBG_VALUE without inserting it and keep track of it in \p Transfers.
|
|
/// It will be inserted into the BB when we're done iterating over the
|
|
/// It will be inserted into the BB when we're done iterating over the
|
|
/// instructions.
|
|
/// instructions.
|
|
-void LiveDebugValues::transferSpillOrRestoreInst(MachineInstr &MI,
|
|
|
|
- OpenRangesSet &OpenRanges,
|
|
|
|
- VarLocMap &VarLocIDs,
|
|
|
|
- TransferMap &Transfers) {
|
|
|
|
- MachineFunction *MF = MI.getMF();
|
|
|
|
- TransferKind TKind;
|
|
|
|
|
|
+void LiveDebugValues::transferSpillInst(MachineInstr &MI,
|
|
|
|
+ OpenRangesSet &OpenRanges,
|
|
|
|
+ VarLocMap &VarLocIDs,
|
|
|
|
+ TransferMap &Transfers) {
|
|
unsigned Reg;
|
|
unsigned Reg;
|
|
- Optional<VarLoc::SpillLoc> Loc;
|
|
|
|
|
|
+ MachineFunction *MF = MI.getMF();
|
|
|
|
+ if (!isSpillInstruction(MI, MF, Reg))
|
|
|
|
+ return;
|
|
|
|
|
|
- if (isSpillInstruction(MI, MF, Reg)) {
|
|
|
|
- TKind = TransferKind::TransferSpill;
|
|
|
|
- LLVM_DEBUG(dbgs() << "Recognized as spill: "; MI.dump(););
|
|
|
|
- LLVM_DEBUG(dbgs() << "Register: " << Reg << " " << printReg(Reg, TRI)
|
|
|
|
- << "\n");
|
|
|
|
- } else {
|
|
|
|
- if (!(Loc = isRestoreInstruction(MI, MF, Reg)))
|
|
|
|
- return;
|
|
|
|
- TKind = TransferKind::TransferRestore;
|
|
|
|
- LLVM_DEBUG(dbgs() << "Recognized as restore: "; MI.dump(););
|
|
|
|
- LLVM_DEBUG(dbgs() << "Register: " << Reg << " " << printReg(Reg, TRI)
|
|
|
|
- << "\n");
|
|
|
|
- }
|
|
|
|
- // Check if the register or spill location is the location of a debug value.
|
|
|
|
|
|
+ // Check if the register is the location of a debug value.
|
|
for (unsigned ID : OpenRanges.getVarLocs()) {
|
|
for (unsigned ID : OpenRanges.getVarLocs()) {
|
|
- if (TKind == TransferKind::TransferSpill &&
|
|
|
|
- VarLocIDs[ID].isDescribedByReg() == Reg) {
|
|
|
|
|
|
+ if (VarLocIDs[ID].isDescribedByReg() == Reg) {
|
|
LLVM_DEBUG(dbgs() << "Spilling Register " << printReg(Reg, TRI) << '('
|
|
LLVM_DEBUG(dbgs() << "Spilling Register " << printReg(Reg, TRI) << '('
|
|
<< VarLocIDs[ID].Var.getVar()->getName() << ")\n");
|
|
<< VarLocIDs[ID].Var.getVar()->getName() << ")\n");
|
|
- } else if (TKind == TransferKind::TransferRestore &&
|
|
|
|
- VarLocIDs[ID].Loc.SpillLocation == *Loc) {
|
|
|
|
- LLVM_DEBUG(dbgs() << "Restoring Register " << printReg(Reg, TRI) << '('
|
|
|
|
- << VarLocIDs[ID].Var.getVar()->getName() << ")\n");
|
|
|
|
- } else
|
|
|
|
- continue;
|
|
|
|
- insertTransferDebugPair(MI, OpenRanges, Transfers, VarLocIDs, ID, TKind,
|
|
|
|
- Reg);
|
|
|
|
|
|
+ insertTransferDebugPair(MI, OpenRanges, Transfers, VarLocIDs, ID);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -674,7 +584,7 @@ void LiveDebugValues::transferRegisterCopy(MachineInstr &MI,
|
|
for (unsigned ID : OpenRanges.getVarLocs()) {
|
|
for (unsigned ID : OpenRanges.getVarLocs()) {
|
|
if (VarLocIDs[ID].isDescribedByReg() == SrcReg) {
|
|
if (VarLocIDs[ID].isDescribedByReg() == SrcReg) {
|
|
insertTransferDebugPair(MI, OpenRanges, Transfers, VarLocIDs, ID,
|
|
insertTransferDebugPair(MI, OpenRanges, Transfers, VarLocIDs, ID,
|
|
- TransferKind::TransferCopy, DestReg);
|
|
|
|
|
|
+ DestReg);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -714,7 +624,7 @@ bool LiveDebugValues::process(MachineInstr &MI, OpenRangesSet &OpenRanges,
|
|
transferRegisterDef(MI, OpenRanges, VarLocIDs);
|
|
transferRegisterDef(MI, OpenRanges, VarLocIDs);
|
|
if (transferChanges) {
|
|
if (transferChanges) {
|
|
transferRegisterCopy(MI, OpenRanges, VarLocIDs, Transfers);
|
|
transferRegisterCopy(MI, OpenRanges, VarLocIDs, Transfers);
|
|
- transferSpillOrRestoreInst(MI, OpenRanges, VarLocIDs, Transfers);
|
|
|
|
|
|
+ transferSpillInst(MI, OpenRanges, VarLocIDs, Transfers);
|
|
}
|
|
}
|
|
Changed = transferTerminatorInst(MI, OpenRanges, OutLocs, VarLocIDs);
|
|
Changed = transferTerminatorInst(MI, OpenRanges, OutLocs, VarLocIDs);
|
|
return Changed;
|
|
return Changed;
|