mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 11:42:57 +01:00
- Move TargetLowering::EmitTargetCodeForFrameDebugValue to TargetInstrInfo and rename it to emitFrameIndexDebugValue.
- Teach spiller to modify DBG_VALUE instructions to reference spill slots. llvm-svn: 102323
This commit is contained in:
parent
d27eedab6d
commit
dc0ce1eae8
@ -23,6 +23,7 @@ class CalleeSavedInfo;
|
|||||||
class LiveVariables;
|
class LiveVariables;
|
||||||
class MCAsmInfo;
|
class MCAsmInfo;
|
||||||
class MachineMemOperand;
|
class MachineMemOperand;
|
||||||
|
class MDNode;
|
||||||
class SDNode;
|
class SDNode;
|
||||||
class SelectionDAG;
|
class SelectionDAG;
|
||||||
class TargetRegisterClass;
|
class TargetRegisterClass;
|
||||||
@ -361,6 +362,19 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// emitFrameIndexDebugValue - Emit a target-dependent form of
|
||||||
|
/// DBG_VALUE encoding the address of a frame index. Addresses would
|
||||||
|
/// normally be lowered the same way as other addresses on the target,
|
||||||
|
/// e.g. in load instructions. For targets that do not support this
|
||||||
|
/// the debug info is simply lost.
|
||||||
|
virtual MachineInstr *emitFrameIndexDebugValue(MachineFunction &MF,
|
||||||
|
unsigned FrameIx,
|
||||||
|
uint64_t Offset,
|
||||||
|
const MDNode *MDPtr,
|
||||||
|
DebugLoc dl) const {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/// foldMemoryOperand - Attempt to fold a load or store of the specified stack
|
/// foldMemoryOperand - Attempt to fold a load or store of the specified stack
|
||||||
/// slot into the specified machine instruction for the specified operand(s).
|
/// slot into the specified machine instruction for the specified operand(s).
|
||||||
/// If this is possible, a new instruction is returned with the specified
|
/// If this is possible, a new instruction is returned with the specified
|
||||||
|
@ -1255,16 +1255,6 @@ public:
|
|||||||
return SDValue();
|
return SDValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// EmitTargetCodeForFrameDebugValue - Emit a target-dependent form of
|
|
||||||
/// DBG_VALUE encoding the address of a frame index. Addresses would
|
|
||||||
/// normally be lowered the same way as other addresses on the target,
|
|
||||||
/// e.g. in load instructions. For targets that do not support this
|
|
||||||
/// the debug info is simply lost.
|
|
||||||
virtual void
|
|
||||||
EmitTargetCodeForFrameDebugValue(MachineBasicBlock* BB, unsigned FrameIx,
|
|
||||||
uint64_t Offset, MDNode *MDPtr,
|
|
||||||
DebugLoc dl) const {}
|
|
||||||
|
|
||||||
/// LowerOperationWrapper - This callback is invoked by the type legalizer
|
/// LowerOperationWrapper - This callback is invoked by the type legalizer
|
||||||
/// to legalize nodes with an illegal operand type but legal result types.
|
/// to legalize nodes with an illegal operand type but legal result types.
|
||||||
/// It replaces the LowerOperation callback in the type Legalizer.
|
/// It replaces the LowerOperation callback in the type Legalizer.
|
||||||
|
@ -1296,9 +1296,23 @@ rewriteInstructionsForSpills(const LiveInterval &li, bool TrySplit,
|
|||||||
MachineOperand &O = ri.getOperand();
|
MachineOperand &O = ri.getOperand();
|
||||||
++ri;
|
++ri;
|
||||||
if (MI->isDebugValue()) {
|
if (MI->isDebugValue()) {
|
||||||
// Remove debug info for now.
|
// Modify DBG_VALUE now that the value is in a spill slot.
|
||||||
O.setReg(0U);
|
uint64_t Offset = MI->getOperand(1).getImm();
|
||||||
DEBUG(dbgs() << "Removing debug info due to spill:" << "\t" << *MI);
|
const MDNode *MDPtr = MI->getOperand(2).getMetadata();
|
||||||
|
DebugLoc DL = MI->getDebugLoc();
|
||||||
|
MachineInstr *NewDV = tii_->emitFrameIndexDebugValue(*mf_, Slot, Offset,
|
||||||
|
MDPtr, DL);
|
||||||
|
if (NewDV) {
|
||||||
|
DEBUG(dbgs() << "Modifying debug info due to spill:" << "\t" << *MI);
|
||||||
|
ReplaceMachineInstrInMaps(MI, NewDV);
|
||||||
|
MachineBasicBlock *MBB = MI->getParent();
|
||||||
|
MBB->insert(MBB->erase(MI), NewDV);
|
||||||
|
} else {
|
||||||
|
DEBUG(dbgs() << "Removing debug info due to spill:" << "\t" << *MI);
|
||||||
|
RemoveMachineInstrFromMaps(MI);
|
||||||
|
vrm.RemoveMachineInstrFromMaps(MI);
|
||||||
|
MI->eraseFromParent();
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
assert(!O.isImplicit() && "Spilling register that's used as implicit use?");
|
assert(!O.isImplicit() && "Spilling register that's used as implicit use?");
|
||||||
|
@ -507,7 +507,6 @@ InstrEmitter::EmitCopyToRegClassNode(SDNode *Node,
|
|||||||
/// EmitDbgValue - Generate machine instruction for a dbg_value node.
|
/// EmitDbgValue - Generate machine instruction for a dbg_value node.
|
||||||
///
|
///
|
||||||
MachineInstr *InstrEmitter::EmitDbgValue(SDDbgValue *SD,
|
MachineInstr *InstrEmitter::EmitDbgValue(SDDbgValue *SD,
|
||||||
MachineBasicBlock *InsertBB,
|
|
||||||
DenseMap<SDValue, unsigned> &VRBaseMap,
|
DenseMap<SDValue, unsigned> &VRBaseMap,
|
||||||
DenseMap<MachineBasicBlock*, MachineBasicBlock*> *EM) {
|
DenseMap<MachineBasicBlock*, MachineBasicBlock*> *EM) {
|
||||||
uint64_t Offset = SD->getOffset();
|
uint64_t Offset = SD->getOffset();
|
||||||
@ -518,8 +517,7 @@ MachineInstr *InstrEmitter::EmitDbgValue(SDDbgValue *SD,
|
|||||||
// Stack address; this needs to be lowered in target-dependent fashion.
|
// Stack address; this needs to be lowered in target-dependent fashion.
|
||||||
// EmitTargetCodeForFrameDebugValue is responsible for allocation.
|
// EmitTargetCodeForFrameDebugValue is responsible for allocation.
|
||||||
unsigned FrameIx = SD->getFrameIx();
|
unsigned FrameIx = SD->getFrameIx();
|
||||||
TLI->EmitTargetCodeForFrameDebugValue(InsertBB, FrameIx, Offset, MDPtr, DL);
|
return TII->emitFrameIndexDebugValue(*MF, FrameIx, Offset, MDPtr, DL);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
// Otherwise, we're going to create an instruction here.
|
// Otherwise, we're going to create an instruction here.
|
||||||
const TargetInstrDesc &II = TII->get(TargetOpcode::DBG_VALUE);
|
const TargetInstrDesc &II = TII->get(TargetOpcode::DBG_VALUE);
|
||||||
|
@ -103,7 +103,6 @@ public:
|
|||||||
/// EmitDbgValue - Generate machine instruction for a dbg_value node.
|
/// EmitDbgValue - Generate machine instruction for a dbg_value node.
|
||||||
///
|
///
|
||||||
MachineInstr *EmitDbgValue(SDDbgValue *SD,
|
MachineInstr *EmitDbgValue(SDDbgValue *SD,
|
||||||
MachineBasicBlock *InsertBB,
|
|
||||||
DenseMap<SDValue, unsigned> &VRBaseMap,
|
DenseMap<SDValue, unsigned> &VRBaseMap,
|
||||||
DenseMap<MachineBasicBlock*, MachineBasicBlock*> *EM);
|
DenseMap<MachineBasicBlock*, MachineBasicBlock*> *EM);
|
||||||
|
|
||||||
|
@ -449,9 +449,11 @@ static void ProcessSourceNode(SDNode *N, SelectionDAG *DAG,
|
|||||||
continue;
|
continue;
|
||||||
unsigned DVOrder = DVs[i]->getOrder();
|
unsigned DVOrder = DVs[i]->getOrder();
|
||||||
if (DVOrder == ++Order) {
|
if (DVOrder == ++Order) {
|
||||||
MachineInstr *DbgMI = Emitter.EmitDbgValue(DVs[i], BB, VRBaseMap, EM);
|
MachineInstr *DbgMI = Emitter.EmitDbgValue(DVs[i], VRBaseMap, EM);
|
||||||
Orders.push_back(std::make_pair(DVOrder, DbgMI));
|
if (DbgMI) {
|
||||||
BB->insert(InsertPos, DbgMI);
|
Orders.push_back(std::make_pair(DVOrder, DbgMI));
|
||||||
|
BB->insert(InsertPos, DbgMI);
|
||||||
|
}
|
||||||
DVs[i]->setIsInvalidated();
|
DVs[i]->setIsInvalidated();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -540,13 +542,15 @@ EmitSchedule(DenseMap<MachineBasicBlock*, MachineBasicBlock*> *EM) {
|
|||||||
#endif
|
#endif
|
||||||
if ((*DI)->isInvalidated())
|
if ((*DI)->isInvalidated())
|
||||||
continue;
|
continue;
|
||||||
MachineInstr *DbgMI = Emitter.EmitDbgValue(*DI, MIBB, VRBaseMap, EM);
|
MachineInstr *DbgMI = Emitter.EmitDbgValue(*DI, VRBaseMap, EM);
|
||||||
if (!LastOrder)
|
if (DbgMI) {
|
||||||
// Insert to start of the BB (after PHIs).
|
if (!LastOrder)
|
||||||
BB->insert(BBBegin, DbgMI);
|
// Insert to start of the BB (after PHIs).
|
||||||
else {
|
BB->insert(BBBegin, DbgMI);
|
||||||
MachineBasicBlock::iterator Pos = MI;
|
else {
|
||||||
MIBB->insert(llvm::next(Pos), DbgMI);
|
MachineBasicBlock::iterator Pos = MI;
|
||||||
|
MIBB->insert(llvm::next(Pos), DbgMI);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LastOrder = Order;
|
LastOrder = Order;
|
||||||
@ -558,8 +562,9 @@ EmitSchedule(DenseMap<MachineBasicBlock*, MachineBasicBlock*> *EM) {
|
|||||||
MachineBasicBlock *InsertBB = Emitter.getBlock();
|
MachineBasicBlock *InsertBB = Emitter.getBlock();
|
||||||
MachineBasicBlock::iterator Pos= Emitter.getBlock()->getFirstTerminator();
|
MachineBasicBlock::iterator Pos= Emitter.getBlock()->getFirstTerminator();
|
||||||
if (!(*DI)->isInvalidated()) {
|
if (!(*DI)->isInvalidated()) {
|
||||||
MachineInstr *DbgMI= Emitter.EmitDbgValue(*DI, InsertBB, VRBaseMap, EM);
|
MachineInstr *DbgMI= Emitter.EmitDbgValue(*DI, VRBaseMap, EM);
|
||||||
InsertBB->insert(Pos, DbgMI);
|
if (DbgMI)
|
||||||
|
InsertBB->insert(Pos, DbgMI);
|
||||||
}
|
}
|
||||||
++DI;
|
++DI;
|
||||||
}
|
}
|
||||||
|
@ -8622,19 +8622,6 @@ X86TargetLowering::EmitLoweredMingwAlloca(MachineInstr *MI,
|
|||||||
return BB;
|
return BB;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
X86TargetLowering::EmitTargetCodeForFrameDebugValue(MachineBasicBlock* BB,
|
|
||||||
unsigned FrameIx, uint64_t Offset,
|
|
||||||
MDNode *MDPtr, DebugLoc DL) const {
|
|
||||||
// Target dependent DBG_VALUE. Only the frame index case is done here.
|
|
||||||
const TargetInstrInfo *TII = getTargetMachine().getInstrInfo();
|
|
||||||
X86AddressMode AM;
|
|
||||||
AM.BaseType = X86AddressMode::FrameIndexBase;
|
|
||||||
AM.Base.FrameIndex = FrameIx;
|
|
||||||
addFullAddress(BuildMI(BB, DL, TII->get(X86::DBG_VALUE)), AM).
|
|
||||||
addImm(Offset).addMetadata(MDPtr);
|
|
||||||
}
|
|
||||||
|
|
||||||
MachineBasicBlock *
|
MachineBasicBlock *
|
||||||
X86TargetLowering::EmitInstrWithCustomInserter(MachineInstr *MI,
|
X86TargetLowering::EmitInstrWithCustomInserter(MachineInstr *MI,
|
||||||
MachineBasicBlock *BB,
|
MachineBasicBlock *BB,
|
||||||
|
@ -453,11 +453,6 @@ namespace llvm {
|
|||||||
/// and some i16 instructions are slow.
|
/// and some i16 instructions are slow.
|
||||||
virtual bool IsDesirableToPromoteOp(SDValue Op, EVT &PVT) const;
|
virtual bool IsDesirableToPromoteOp(SDValue Op, EVT &PVT) const;
|
||||||
|
|
||||||
virtual void
|
|
||||||
EmitTargetCodeForFrameDebugValue(MachineBasicBlock* BB,
|
|
||||||
unsigned FrameIx, uint64_t Offset,
|
|
||||||
MDNode *MDPtr, DebugLoc DL) const;
|
|
||||||
|
|
||||||
virtual MachineBasicBlock *EmitInstrWithCustomInserter(MachineInstr *MI,
|
virtual MachineBasicBlock *EmitInstrWithCustomInserter(MachineInstr *MI,
|
||||||
MachineBasicBlock *MBB,
|
MachineBasicBlock *MBB,
|
||||||
DenseMap<MachineBasicBlock*, MachineBasicBlock*> *EM) const;
|
DenseMap<MachineBasicBlock*, MachineBasicBlock*> *EM) const;
|
||||||
|
@ -2319,6 +2319,20 @@ bool X86InstrInfo::restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MachineInstr*
|
||||||
|
X86InstrInfo::emitFrameIndexDebugValue(MachineFunction &MF,
|
||||||
|
unsigned FrameIx, uint64_t Offset,
|
||||||
|
const MDNode *MDPtr,
|
||||||
|
DebugLoc DL) const {
|
||||||
|
// Target dependent DBG_VALUE. Only the frame index case is done here.
|
||||||
|
X86AddressMode AM;
|
||||||
|
AM.BaseType = X86AddressMode::FrameIndexBase;
|
||||||
|
AM.Base.FrameIndex = FrameIx;
|
||||||
|
MachineInstrBuilder MIB = BuildMI(MF, DL, get(X86::DBG_VALUE));
|
||||||
|
addFullAddress(MIB, AM).addImm(Offset).addMetadata(MDPtr);
|
||||||
|
return &*MIB;
|
||||||
|
}
|
||||||
|
|
||||||
static MachineInstr *FuseTwoAddrInst(MachineFunction &MF, unsigned Opcode,
|
static MachineInstr *FuseTwoAddrInst(MachineFunction &MF, unsigned Opcode,
|
||||||
const SmallVectorImpl<MachineOperand> &MOs,
|
const SmallVectorImpl<MachineOperand> &MOs,
|
||||||
MachineInstr *MI,
|
MachineInstr *MI,
|
||||||
|
@ -623,6 +623,12 @@ public:
|
|||||||
MachineBasicBlock::iterator MI,
|
MachineBasicBlock::iterator MI,
|
||||||
const std::vector<CalleeSavedInfo> &CSI) const;
|
const std::vector<CalleeSavedInfo> &CSI) const;
|
||||||
|
|
||||||
|
virtual
|
||||||
|
MachineInstr *emitFrameIndexDebugValue(MachineFunction &MF,
|
||||||
|
unsigned FrameIx, uint64_t Offset,
|
||||||
|
const MDNode *MDPtr,
|
||||||
|
DebugLoc DL) const;
|
||||||
|
|
||||||
/// foldMemoryOperand - If this target supports it, fold a load or store of
|
/// foldMemoryOperand - If this target supports it, fold a load or store of
|
||||||
/// the specified stack slot into the specified machine instruction for the
|
/// the specified stack slot into the specified machine instruction for the
|
||||||
/// specified operand(s). If this is possible, the target should perform the
|
/// specified operand(s). If this is possible, the target should perform the
|
||||||
|
Loading…
Reference in New Issue
Block a user