mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-08 21:32:39 +00:00
Propagate debug loc info through prologue/epilogue.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65298 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
4214a5531c
commit
ef4cfc749a
@ -1222,7 +1222,8 @@ void ARMRegisterInfo::emitPrologue(MachineFunction &MF) const {
|
|||||||
unsigned VARegSaveSize = AFI->getVarArgsRegSaveSize();
|
unsigned VARegSaveSize = AFI->getVarArgsRegSaveSize();
|
||||||
unsigned NumBytes = MFI->getStackSize();
|
unsigned NumBytes = MFI->getStackSize();
|
||||||
const std::vector<CalleeSavedInfo> &CSI = MFI->getCalleeSavedInfo();
|
const std::vector<CalleeSavedInfo> &CSI = MFI->getCalleeSavedInfo();
|
||||||
DebugLoc dl = DebugLoc::getUnknownLoc();
|
DebugLoc dl = (MBBI != MBB.end() ?
|
||||||
|
MBBI->getDebugLoc() : DebugLoc::getUnknownLoc());
|
||||||
|
|
||||||
if (isThumb) {
|
if (isThumb) {
|
||||||
// Check if R3 is live in. It might have to be used as a scratch register.
|
// Check if R3 is live in. It might have to be used as a scratch register.
|
||||||
@ -1292,8 +1293,11 @@ void ARMRegisterInfo::emitPrologue(MachineFunction &MF) const {
|
|||||||
// Build the new SUBri to adjust SP for integer callee-save spill area 1.
|
// Build the new SUBri to adjust SP for integer callee-save spill area 1.
|
||||||
emitSPUpdate(MBB, MBBI, -GPRCS1Size, ARMCC::AL, 0, isThumb, TII, *this, dl);
|
emitSPUpdate(MBB, MBBI, -GPRCS1Size, ARMCC::AL, 0, isThumb, TII, *this, dl);
|
||||||
movePastCSLoadStoreOps(MBB, MBBI, ARM::STR, 1, STI);
|
movePastCSLoadStoreOps(MBB, MBBI, ARM::STR, 1, STI);
|
||||||
} else if (MBBI != MBB.end() && MBBI->getOpcode() == ARM::tPUSH)
|
} else if (MBBI != MBB.end() && MBBI->getOpcode() == ARM::tPUSH) {
|
||||||
++MBBI;
|
++MBBI;
|
||||||
|
if (MBBI != MBB.end())
|
||||||
|
dl = MBBI->getDebugLoc();
|
||||||
|
}
|
||||||
|
|
||||||
// Darwin ABI requires FP to point to the stack slot that contains the
|
// Darwin ABI requires FP to point to the stack slot that contains the
|
||||||
// previous FP.
|
// previous FP.
|
||||||
@ -1358,18 +1362,18 @@ static bool isCSRestore(MachineInstr *MI, const unsigned *CSRegs) {
|
|||||||
|
|
||||||
void ARMRegisterInfo::emitEpilogue(MachineFunction &MF,
|
void ARMRegisterInfo::emitEpilogue(MachineFunction &MF,
|
||||||
MachineBasicBlock &MBB) const {
|
MachineBasicBlock &MBB) const {
|
||||||
DebugLoc dl = DebugLoc::getUnknownLoc();
|
|
||||||
MachineBasicBlock::iterator MBBI = prior(MBB.end());
|
MachineBasicBlock::iterator MBBI = prior(MBB.end());
|
||||||
assert((MBBI->getOpcode() == ARM::BX_RET ||
|
assert((MBBI->getOpcode() == ARM::BX_RET ||
|
||||||
MBBI->getOpcode() == ARM::tBX_RET ||
|
MBBI->getOpcode() == ARM::tBX_RET ||
|
||||||
MBBI->getOpcode() == ARM::tPOP_RET) &&
|
MBBI->getOpcode() == ARM::tPOP_RET) &&
|
||||||
"Can only insert epilog into returning blocks");
|
"Can only insert epilog into returning blocks");
|
||||||
|
DebugLoc dl = MBBI->getDebugLoc();
|
||||||
MachineFrameInfo *MFI = MF.getFrameInfo();
|
MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||||
ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>();
|
ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>();
|
||||||
bool isThumb = AFI->isThumbFunction();
|
bool isThumb = AFI->isThumbFunction();
|
||||||
unsigned VARegSaveSize = AFI->getVarArgsRegSaveSize();
|
unsigned VARegSaveSize = AFI->getVarArgsRegSaveSize();
|
||||||
int NumBytes = (int)MFI->getStackSize();
|
int NumBytes = (int)MFI->getStackSize();
|
||||||
|
|
||||||
if (!AFI->hasStackFrame()) {
|
if (!AFI->hasStackFrame()) {
|
||||||
if (NumBytes != 0)
|
if (NumBytes != 0)
|
||||||
emitSPUpdate(MBB, MBBI, NumBytes, ARMCC::AL, 0, isThumb, TII, *this, dl);
|
emitSPUpdate(MBB, MBBI, NumBytes, ARMCC::AL, 0, isThumb, TII, *this, dl);
|
||||||
|
@ -202,7 +202,8 @@ void AlphaRegisterInfo::emitPrologue(MachineFunction &MF) const {
|
|||||||
MachineBasicBlock &MBB = MF.front(); // Prolog goes in entry BB
|
MachineBasicBlock &MBB = MF.front(); // Prolog goes in entry BB
|
||||||
MachineBasicBlock::iterator MBBI = MBB.begin();
|
MachineBasicBlock::iterator MBBI = MBB.begin();
|
||||||
MachineFrameInfo *MFI = MF.getFrameInfo();
|
MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||||
DebugLoc dl = DebugLoc::getUnknownLoc();
|
DebugLoc dl = (MBBI != MBB.end() ?
|
||||||
|
MBBI->getDebugLoc() : DebugLoc::getUnknownLoc());
|
||||||
bool FP = hasFP(MF);
|
bool FP = hasFP(MF);
|
||||||
|
|
||||||
static int curgpdist = 0;
|
static int curgpdist = 0;
|
||||||
@ -268,7 +269,7 @@ void AlphaRegisterInfo::emitEpilogue(MachineFunction &MF,
|
|||||||
assert((MBBI->getOpcode() == Alpha::RETDAG ||
|
assert((MBBI->getOpcode() == Alpha::RETDAG ||
|
||||||
MBBI->getOpcode() == Alpha::RETDAGp)
|
MBBI->getOpcode() == Alpha::RETDAGp)
|
||||||
&& "Can only insert epilog into returning blocks");
|
&& "Can only insert epilog into returning blocks");
|
||||||
DebugLoc dl = DebugLoc::getUnknownLoc();
|
DebugLoc dl = MBBI->getDebugLoc();
|
||||||
|
|
||||||
bool FP = hasFP(MF);
|
bool FP = hasFP(MF);
|
||||||
|
|
||||||
|
@ -428,7 +428,8 @@ void SPURegisterInfo::emitPrologue(MachineFunction &MF) const
|
|||||||
MachineBasicBlock::iterator MBBI = MBB.begin();
|
MachineBasicBlock::iterator MBBI = MBB.begin();
|
||||||
MachineFrameInfo *MFI = MF.getFrameInfo();
|
MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||||
MachineModuleInfo *MMI = MFI->getMachineModuleInfo();
|
MachineModuleInfo *MMI = MFI->getMachineModuleInfo();
|
||||||
DebugLoc dl = DebugLoc::getUnknownLoc();
|
DebugLoc dl = (MBBI != MBB.end() ?
|
||||||
|
MBBI->getDebugLoc() : DebugLoc::getUnknownLoc());
|
||||||
|
|
||||||
// Prepare for debug frame info.
|
// Prepare for debug frame info.
|
||||||
bool hasDebugInfo = MMI && MMI->hasDebugInfo();
|
bool hasDebugInfo = MMI && MMI->hasDebugInfo();
|
||||||
@ -521,6 +522,8 @@ void SPURegisterInfo::emitPrologue(MachineFunction &MF) const
|
|||||||
// this is just a best guess based on the basic block's size.
|
// this is just a best guess based on the basic block's size.
|
||||||
if (MBB.size() >= (unsigned) SPUFrameInfo::branchHintPenalty()) {
|
if (MBB.size() >= (unsigned) SPUFrameInfo::branchHintPenalty()) {
|
||||||
MachineBasicBlock::iterator MBBI = prior(MBB.end());
|
MachineBasicBlock::iterator MBBI = prior(MBB.end());
|
||||||
|
dl = MBBI->getDebugLoc();
|
||||||
|
|
||||||
// Insert terminator label
|
// Insert terminator label
|
||||||
unsigned BranchLabelId = MMI->NextLabelID();
|
unsigned BranchLabelId = MMI->NextLabelID();
|
||||||
BuildMI(MBB, MBBI, dl, TII.get(SPU::DBG_LABEL)).addImm(BranchLabelId);
|
BuildMI(MBB, MBBI, dl, TII.get(SPU::DBG_LABEL)).addImm(BranchLabelId);
|
||||||
@ -535,7 +538,7 @@ SPURegisterInfo::emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const
|
|||||||
const MachineFrameInfo *MFI = MF.getFrameInfo();
|
const MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||||
int FrameSize = MFI->getStackSize();
|
int FrameSize = MFI->getStackSize();
|
||||||
int LinkSlotOffset = SPUFrameInfo::stackSlotSize();
|
int LinkSlotOffset = SPUFrameInfo::stackSlotSize();
|
||||||
DebugLoc dl = DebugLoc::getUnknownLoc();
|
DebugLoc dl = MBBI->getDebugLoc();
|
||||||
|
|
||||||
assert(MBBI->getOpcode() == SPU::RET &&
|
assert(MBBI->getOpcode() == SPU::RET &&
|
||||||
"Can only insert epilog into returning blocks");
|
"Can only insert epilog into returning blocks");
|
||||||
|
@ -165,7 +165,8 @@ void IA64RegisterInfo::emitPrologue(MachineFunction &MF) const {
|
|||||||
MachineBasicBlock::iterator MBBI = MBB.begin();
|
MachineBasicBlock::iterator MBBI = MBB.begin();
|
||||||
MachineFrameInfo *MFI = MF.getFrameInfo();
|
MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||||
bool FP = hasFP(MF);
|
bool FP = hasFP(MF);
|
||||||
DebugLoc dl = DebugLoc::getUnknownLoc();
|
DebugLoc dl = (MBBI != MBB.end() ?
|
||||||
|
MBBI->getDebugLoc() : DebugLoc::getUnknownLoc());
|
||||||
|
|
||||||
// first, we handle the 'alloc' instruction, that should be right up the
|
// first, we handle the 'alloc' instruction, that should be right up the
|
||||||
// top of any function
|
// top of any function
|
||||||
@ -208,6 +209,8 @@ void IA64RegisterInfo::emitPrologue(MachineFunction &MF) const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (MBBI != MBB.end()) dl = MBBI->getDebugLoc();
|
||||||
|
|
||||||
BuildMI(MBB, MBBI, dl, TII.get(IA64::ALLOC)).
|
BuildMI(MBB, MBBI, dl, TII.get(IA64::ALLOC)).
|
||||||
addReg(dstRegOfPseudoAlloc).addImm(0).
|
addReg(dstRegOfPseudoAlloc).addImm(0).
|
||||||
addImm(numStackedGPRsUsed).addImm(numOutRegsUsed).addImm(0);
|
addImm(numStackedGPRsUsed).addImm(numOutRegsUsed).addImm(0);
|
||||||
@ -261,24 +264,21 @@ void IA64RegisterInfo::emitEpilogue(MachineFunction &MF,
|
|||||||
MachineBasicBlock::iterator MBBI = prior(MBB.end());
|
MachineBasicBlock::iterator MBBI = prior(MBB.end());
|
||||||
assert(MBBI->getOpcode() == IA64::RET &&
|
assert(MBBI->getOpcode() == IA64::RET &&
|
||||||
"Can only insert epilog into returning blocks");
|
"Can only insert epilog into returning blocks");
|
||||||
DebugLoc dl = DebugLoc::getUnknownLoc();
|
DebugLoc dl = MBBI->getDebugLoc();
|
||||||
|
|
||||||
bool FP = hasFP(MF);
|
bool FP = hasFP(MF);
|
||||||
|
|
||||||
// Get the number of bytes allocated from the FrameInfo...
|
// Get the number of bytes allocated from the FrameInfo...
|
||||||
unsigned NumBytes = MFI->getStackSize();
|
unsigned NumBytes = MFI->getStackSize();
|
||||||
|
|
||||||
//now if we need to, restore the old FP
|
//now if we need to, restore the old FP
|
||||||
if (FP)
|
if (FP) {
|
||||||
{
|
|
||||||
//copy the FP into the SP (discards allocas)
|
//copy the FP into the SP (discards allocas)
|
||||||
BuildMI(MBB, MBBI, dl, TII.get(IA64::MOV), IA64::r12).addReg(IA64::r5);
|
BuildMI(MBB, MBBI, dl, TII.get(IA64::MOV), IA64::r12).addReg(IA64::r5);
|
||||||
//restore the FP
|
//restore the FP
|
||||||
BuildMI(MBB, MBBI, dl, TII.get(IA64::LD8), IA64::r5).addReg(IA64::r5);
|
BuildMI(MBB, MBBI, dl, TII.get(IA64::LD8), IA64::r5).addReg(IA64::r5);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NumBytes != 0)
|
if (NumBytes != 0) {
|
||||||
{
|
|
||||||
if (NumBytes <= 8191) {
|
if (NumBytes <= 8191) {
|
||||||
BuildMI(MBB, MBBI, dl, TII.get(IA64::ADDIMM22),IA64::r12).
|
BuildMI(MBB, MBBI, dl, TII.get(IA64::ADDIMM22),IA64::r12).
|
||||||
addReg(IA64::r12).addImm(NumBytes);
|
addReg(IA64::r12).addImm(NumBytes);
|
||||||
@ -289,7 +289,6 @@ void IA64RegisterInfo::emitEpilogue(MachineFunction &MF,
|
|||||||
addReg(IA64::r22);
|
addReg(IA64::r22);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned IA64RegisterInfo::getRARegister() const {
|
unsigned IA64RegisterInfo::getRARegister() const {
|
||||||
|
@ -391,7 +391,8 @@ emitPrologue(MachineFunction &MF) const
|
|||||||
MachineFrameInfo *MFI = MF.getFrameInfo();
|
MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||||
MipsFunctionInfo *MipsFI = MF.getInfo<MipsFunctionInfo>();
|
MipsFunctionInfo *MipsFI = MF.getInfo<MipsFunctionInfo>();
|
||||||
MachineBasicBlock::iterator MBBI = MBB.begin();
|
MachineBasicBlock::iterator MBBI = MBB.begin();
|
||||||
DebugLoc dl = DebugLoc::getUnknownLoc();
|
DebugLoc dl = (MBBI != MBB.end() ?
|
||||||
|
MBBI->getDebugLoc() : DebugLoc::getUnknownLoc());
|
||||||
bool isPIC = (MF.getTarget().getRelocationModel() == Reloc::PIC_);
|
bool isPIC = (MF.getTarget().getRelocationModel() == Reloc::PIC_);
|
||||||
|
|
||||||
// Get the right frame order for Mips.
|
// Get the right frame order for Mips.
|
||||||
@ -449,7 +450,7 @@ emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const
|
|||||||
MachineBasicBlock::iterator MBBI = prior(MBB.end());
|
MachineBasicBlock::iterator MBBI = prior(MBB.end());
|
||||||
MachineFrameInfo *MFI = MF.getFrameInfo();
|
MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||||
MipsFunctionInfo *MipsFI = MF.getInfo<MipsFunctionInfo>();
|
MipsFunctionInfo *MipsFI = MF.getInfo<MipsFunctionInfo>();
|
||||||
DebugLoc dl = DebugLoc::getUnknownLoc();
|
DebugLoc dl = MBBI->getDebugLoc();
|
||||||
|
|
||||||
// Get the number of bytes from FrameInfo
|
// Get the number of bytes from FrameInfo
|
||||||
int NumBytes = (int) MFI->getStackSize();
|
int NumBytes = (int) MFI->getStackSize();
|
||||||
|
@ -120,7 +120,9 @@ processFunctionBeforeFrameFinalized(MachineFunction &MF) const {}
|
|||||||
void SparcRegisterInfo::emitPrologue(MachineFunction &MF) const {
|
void SparcRegisterInfo::emitPrologue(MachineFunction &MF) const {
|
||||||
MachineBasicBlock &MBB = MF.front();
|
MachineBasicBlock &MBB = MF.front();
|
||||||
MachineFrameInfo *MFI = MF.getFrameInfo();
|
MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||||
DebugLoc dl = DebugLoc::getUnknownLoc();
|
MachineBasicBlock::iterator MBBI = MBB.begin();
|
||||||
|
DebugLoc dl = (MBBI != MBB.end() ?
|
||||||
|
MBBI->getDebugLoc() : DebugLoc::getUnknownLoc());
|
||||||
|
|
||||||
// Get the number of bytes to allocate from the FrameInfo
|
// Get the number of bytes to allocate from the FrameInfo
|
||||||
int NumBytes = (int) MFI->getStackSize();
|
int NumBytes = (int) MFI->getStackSize();
|
||||||
@ -133,24 +135,24 @@ void SparcRegisterInfo::emitPrologue(MachineFunction &MF) const {
|
|||||||
// ----------
|
// ----------
|
||||||
// 23 words * 4 bytes per word = 92 bytes
|
// 23 words * 4 bytes per word = 92 bytes
|
||||||
NumBytes += 92;
|
NumBytes += 92;
|
||||||
|
|
||||||
// Round up to next doubleword boundary -- a double-word boundary
|
// Round up to next doubleword boundary -- a double-word boundary
|
||||||
// is required by the ABI.
|
// is required by the ABI.
|
||||||
NumBytes = (NumBytes + 7) & ~7;
|
NumBytes = (NumBytes + 7) & ~7;
|
||||||
NumBytes = -NumBytes;
|
NumBytes = -NumBytes;
|
||||||
|
|
||||||
if (NumBytes >= -4096) {
|
if (NumBytes >= -4096) {
|
||||||
BuildMI(MBB, MBB.begin(), dl, TII.get(SP::SAVEri),
|
BuildMI(MBB, MBBI, dl, TII.get(SP::SAVEri), SP::O6)
|
||||||
SP::O6).addReg(SP::O6).addImm(NumBytes);
|
.addReg(SP::O6).addImm(NumBytes);
|
||||||
} else {
|
} else {
|
||||||
MachineBasicBlock::iterator InsertPt = MBB.begin();
|
|
||||||
// Emit this the hard way. This clobbers G1 which we always know is
|
// Emit this the hard way. This clobbers G1 which we always know is
|
||||||
// available here.
|
// available here.
|
||||||
unsigned OffHi = (unsigned)NumBytes >> 10U;
|
unsigned OffHi = (unsigned)NumBytes >> 10U;
|
||||||
BuildMI(MBB, InsertPt, dl, TII.get(SP::SETHIi), SP::G1).addImm(OffHi);
|
BuildMI(MBB, MBBI, dl, TII.get(SP::SETHIi), SP::G1).addImm(OffHi);
|
||||||
// Emit G1 = G1 + I6
|
// Emit G1 = G1 + I6
|
||||||
BuildMI(MBB, InsertPt, dl, TII.get(SP::ORri), SP::G1)
|
BuildMI(MBB, MBBI, dl, TII.get(SP::ORri), SP::G1)
|
||||||
.addReg(SP::G1).addImm(NumBytes & ((1 << 10)-1));
|
.addReg(SP::G1).addImm(NumBytes & ((1 << 10)-1));
|
||||||
BuildMI(MBB, InsertPt, dl, TII.get(SP::SAVErr), SP::O6)
|
BuildMI(MBB, MBBI, dl, TII.get(SP::SAVErr), SP::O6)
|
||||||
.addReg(SP::O6).addReg(SP::G1);
|
.addReg(SP::O6).addReg(SP::G1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -158,7 +160,7 @@ void SparcRegisterInfo::emitPrologue(MachineFunction &MF) const {
|
|||||||
void SparcRegisterInfo::emitEpilogue(MachineFunction &MF,
|
void SparcRegisterInfo::emitEpilogue(MachineFunction &MF,
|
||||||
MachineBasicBlock &MBB) const {
|
MachineBasicBlock &MBB) const {
|
||||||
MachineBasicBlock::iterator MBBI = prior(MBB.end());
|
MachineBasicBlock::iterator MBBI = prior(MBB.end());
|
||||||
DebugLoc dl = DebugLoc::getUnknownLoc();
|
DebugLoc dl = MBBI->getDebugLoc();
|
||||||
assert(MBBI->getOpcode() == SP::RETL &&
|
assert(MBBI->getOpcode() == SP::RETL &&
|
||||||
"Can only put epilog before 'retl' instruction!");
|
"Can only put epilog before 'retl' instruction!");
|
||||||
BuildMI(MBB, MBBI, dl, TII.get(SP::RESTORErr), SP::G0).addReg(SP::G0)
|
BuildMI(MBB, MBBI, dl, TII.get(SP::RESTORErr), SP::G0).addReg(SP::G0)
|
||||||
|
@ -398,7 +398,8 @@ void XCoreRegisterInfo::emitPrologue(MachineFunction &MF) const {
|
|||||||
MachineFrameInfo *MFI = MF.getFrameInfo();
|
MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||||
MachineModuleInfo *MMI = MFI->getMachineModuleInfo();
|
MachineModuleInfo *MMI = MFI->getMachineModuleInfo();
|
||||||
XCoreFunctionInfo *XFI = MF.getInfo<XCoreFunctionInfo>();
|
XCoreFunctionInfo *XFI = MF.getInfo<XCoreFunctionInfo>();
|
||||||
DebugLoc dl = DebugLoc::getUnknownLoc();
|
DebugLoc dl = (MBBI != MBB.end() ?
|
||||||
|
MBBI->getDebugLoc() : DebugLoc::getUnknownLoc());
|
||||||
|
|
||||||
bool FP = hasFP(MF);
|
bool FP = hasFP(MF);
|
||||||
|
|
||||||
@ -515,7 +516,7 @@ void XCoreRegisterInfo::emitEpilogue(MachineFunction &MF,
|
|||||||
MachineBasicBlock &MBB) const {
|
MachineBasicBlock &MBB) const {
|
||||||
MachineFrameInfo *MFI = MF.getFrameInfo();
|
MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||||
MachineBasicBlock::iterator MBBI = prior(MBB.end());
|
MachineBasicBlock::iterator MBBI = prior(MBB.end());
|
||||||
DebugLoc dl = DebugLoc::getUnknownLoc();
|
DebugLoc dl = MBBI->getDebugLoc();
|
||||||
|
|
||||||
bool FP = hasFP(MF);
|
bool FP = hasFP(MF);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user