mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-13 01:15:32 +00:00
Repair debug frames as a prelude to eh_frames. Switched to using MachineMoves
by value so that clean up is less confusing (these vectors tend to be small.) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33488 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7cce0ac42b
commit
5e73d5bd2e
@ -985,7 +985,7 @@ private:
|
|||||||
|
|
||||||
// FrameMoves - List of moves done by a function's prolog. Used to construct
|
// FrameMoves - List of moves done by a function's prolog. Used to construct
|
||||||
// frame maps by debug consumers.
|
// frame maps by debug consumers.
|
||||||
std::vector<MachineMove *> FrameMoves;
|
std::vector<MachineMove> FrameMoves;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MachineDebugInfo();
|
MachineDebugInfo();
|
||||||
@ -1145,7 +1145,7 @@ public:
|
|||||||
|
|
||||||
/// getFrameMoves - Returns a reference to a list of moves done in the current
|
/// getFrameMoves - Returns a reference to a list of moves done in the current
|
||||||
/// function's prologue. Used to construct frame maps for debug comsumers.
|
/// function's prologue. Used to construct frame maps for debug comsumers.
|
||||||
std::vector<MachineMove *> &getFrameMoves() { return FrameMoves; }
|
std::vector<MachineMove> &getFrameMoves() { return FrameMoves; }
|
||||||
|
|
||||||
}; // End class MachineDebugInfo
|
}; // End class MachineDebugInfo
|
||||||
|
|
||||||
|
@ -79,10 +79,16 @@ private:
|
|||||||
unsigned LabelID; // Label ID number for post-instruction
|
unsigned LabelID; // Label ID number for post-instruction
|
||||||
// address when result of move takes
|
// address when result of move takes
|
||||||
// effect.
|
// effect.
|
||||||
const MachineLocation Destination; // Move to location.
|
MachineLocation Destination; // Move to location.
|
||||||
const MachineLocation Source; // Move from location.
|
MachineLocation Source; // Move from location.
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
MachineMove()
|
||||||
|
: LabelID(0)
|
||||||
|
, Destination()
|
||||||
|
, Source()
|
||||||
|
{}
|
||||||
|
|
||||||
MachineMove(unsigned ID, MachineLocation &D, MachineLocation &S)
|
MachineMove(unsigned ID, MachineLocation &D, MachineLocation &S)
|
||||||
: LabelID(ID)
|
: LabelID(ID)
|
||||||
, Destination(D)
|
, Destination(D)
|
||||||
|
@ -456,7 +456,7 @@ public:
|
|||||||
/// getInitialFrameState - Returns a list of machine moves that are assumed
|
/// getInitialFrameState - Returns a list of machine moves that are assumed
|
||||||
/// on entry to all functions. Note that LabelID is ignored (assumed to be
|
/// on entry to all functions. Note that LabelID is ignored (assumed to be
|
||||||
/// the beginning of the function.)
|
/// the beginning of the function.)
|
||||||
virtual void getInitialFrameState(std::vector<MachineMove *> &Moves) const;
|
virtual void getInitialFrameState(std::vector<MachineMove> &Moves) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
// This is useful when building DenseMaps keyed on virtual registers
|
// This is useful when building DenseMaps keyed on virtual registers
|
||||||
|
@ -2112,16 +2112,25 @@ private:
|
|||||||
/// EmitFrameMoves - Emit frame instructions to describe the layout of the
|
/// EmitFrameMoves - Emit frame instructions to describe the layout of the
|
||||||
/// frame.
|
/// frame.
|
||||||
void EmitFrameMoves(const char *BaseLabel, unsigned BaseLabelID,
|
void EmitFrameMoves(const char *BaseLabel, unsigned BaseLabelID,
|
||||||
std::vector<MachineMove *> &Moves) {
|
std::vector<MachineMove> &Moves) {
|
||||||
|
int stackGrowth =
|
||||||
|
Asm->TM.getFrameInfo()->getStackGrowthDirection() ==
|
||||||
|
TargetFrameInfo::StackGrowsUp ?
|
||||||
|
TAI->getAddressSize() : -TAI->getAddressSize();
|
||||||
|
|
||||||
for (unsigned i = 0, N = Moves.size(); i < N; ++i) {
|
for (unsigned i = 0, N = Moves.size(); i < N; ++i) {
|
||||||
MachineMove *Move = Moves[i];
|
MachineMove &Move = Moves[i];
|
||||||
unsigned LabelID = DebugInfo->MappedLabel(Move->getLabelID());
|
unsigned LabelID = Move.getLabelID();
|
||||||
|
|
||||||
// Throw out move if the label is invalid.
|
if (LabelID) {
|
||||||
if (!LabelID) continue;
|
LabelID = DebugInfo->MappedLabel(LabelID);
|
||||||
|
|
||||||
const MachineLocation &Dst = Move->getDestination();
|
// Throw out move if the label is invalid.
|
||||||
const MachineLocation &Src = Move->getSource();
|
if (!LabelID) continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const MachineLocation &Dst = Move.getDestination();
|
||||||
|
const MachineLocation &Src = Move.getSource();
|
||||||
|
|
||||||
// Advance row if new location.
|
// Advance row if new location.
|
||||||
if (BaseLabel && LabelID && BaseLabelID != LabelID) {
|
if (BaseLabel && LabelID && BaseLabelID != LabelID) {
|
||||||
@ -2134,11 +2143,6 @@ private:
|
|||||||
BaseLabel = "loc";
|
BaseLabel = "loc";
|
||||||
}
|
}
|
||||||
|
|
||||||
int stackGrowth =
|
|
||||||
Asm->TM.getFrameInfo()->getStackGrowthDirection() ==
|
|
||||||
TargetFrameInfo::StackGrowsUp ?
|
|
||||||
TAI->getAddressSize() : -TAI->getAddressSize();
|
|
||||||
|
|
||||||
// If advancing cfa.
|
// If advancing cfa.
|
||||||
if (Dst.isRegister() && Dst.getRegister() == MachineLocation::VirtualFP) {
|
if (Dst.isRegister() && Dst.getRegister() == MachineLocation::VirtualFP) {
|
||||||
if (!Src.isRegister()) {
|
if (!Src.isRegister()) {
|
||||||
@ -2159,6 +2163,16 @@ private:
|
|||||||
} else {
|
} else {
|
||||||
assert(0 && "Machine move no supported yet.");
|
assert(0 && "Machine move no supported yet.");
|
||||||
}
|
}
|
||||||
|
} else if (Src.isRegister() &&
|
||||||
|
Src.getRegister() == MachineLocation::VirtualFP) {
|
||||||
|
if (Dst.isRegister()) {
|
||||||
|
EmitInt8(DW_CFA_def_cfa_register);
|
||||||
|
EOL("DW_CFA_def_cfa_register");
|
||||||
|
EmitULEB128Bytes(RI->getDwarfRegNum(Dst.getRegister()));
|
||||||
|
EOL("Register");
|
||||||
|
} else {
|
||||||
|
assert(0 && "Machine move no supported yet.");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
unsigned Reg = RI->getDwarfRegNum(Src.getRegister());
|
unsigned Reg = RI->getDwarfRegNum(Src.getRegister());
|
||||||
int Offset = Dst.getOffset() / stackGrowth;
|
int Offset = Dst.getOffset() / stackGrowth;
|
||||||
@ -2433,10 +2447,9 @@ private:
|
|||||||
EmitSLEB128Bytes(stackGrowth); EOL("CIE Data Alignment Factor");
|
EmitSLEB128Bytes(stackGrowth); EOL("CIE Data Alignment Factor");
|
||||||
EmitInt8(RI->getDwarfRegNum(RI->getRARegister())); EOL("CIE RA Column");
|
EmitInt8(RI->getDwarfRegNum(RI->getRARegister())); EOL("CIE RA Column");
|
||||||
|
|
||||||
std::vector<MachineMove *> Moves;
|
std::vector<MachineMove> Moves;
|
||||||
RI->getInitialFrameState(Moves);
|
RI->getInitialFrameState(Moves);
|
||||||
EmitFrameMoves(NULL, 0, Moves);
|
EmitFrameMoves(NULL, 0, Moves);
|
||||||
for (unsigned i = 0, N = Moves.size(); i < N; ++i) delete Moves[i];
|
|
||||||
|
|
||||||
Asm->EmitAlignment(2);
|
Asm->EmitAlignment(2);
|
||||||
EmitLabel("frame_common_end", 0);
|
EmitLabel("frame_common_end", 0);
|
||||||
@ -2467,7 +2480,7 @@ private:
|
|||||||
"func_begin", SubprogramCount);
|
"func_begin", SubprogramCount);
|
||||||
EOL("FDE address range");
|
EOL("FDE address range");
|
||||||
|
|
||||||
std::vector<MachineMove *> &Moves = DebugInfo->getFrameMoves();
|
std::vector<MachineMove> &Moves = DebugInfo->getFrameMoves();
|
||||||
|
|
||||||
EmitFrameMoves("func_begin", SubprogramCount, Moves);
|
EmitFrameMoves("func_begin", SubprogramCount, Moves);
|
||||||
|
|
||||||
|
@ -1505,7 +1505,6 @@ void MachineDebugInfo::EndFunction() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Clean up frame info.
|
// Clean up frame info.
|
||||||
for (unsigned i = 0, N = FrameMoves.size(); i < N; ++i) delete FrameMoves[i];
|
|
||||||
FrameMoves.clear();
|
FrameMoves.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ void MRegisterInfo::getLocation(MachineFunction &MF, unsigned Index,
|
|||||||
/// getInitialFrameState - Returns a list of machine moves that are assumed
|
/// getInitialFrameState - Returns a list of machine moves that are assumed
|
||||||
/// on entry to a function.
|
/// on entry to a function.
|
||||||
void
|
void
|
||||||
MRegisterInfo::getInitialFrameState(std::vector<MachineMove *> &Moves) const {
|
MRegisterInfo::getInitialFrameState(std::vector<MachineMove> &Moves) const {
|
||||||
// Default is to do nothing.
|
// Default is to do nothing.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -762,6 +762,10 @@ void PPCRegisterInfo::emitPrologue(MachineFunction &MF) const {
|
|||||||
MachineFrameInfo *MFI = MF.getFrameInfo();
|
MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||||
MachineDebugInfo *DebugInfo = MFI->getMachineDebugInfo();
|
MachineDebugInfo *DebugInfo = MFI->getMachineDebugInfo();
|
||||||
|
|
||||||
|
// Prepare for debug frame info.
|
||||||
|
bool hasInfo = DebugInfo && DebugInfo->hasInfo();
|
||||||
|
unsigned FrameLabelId = 0;
|
||||||
|
|
||||||
// Scan the prolog, looking for an UPDATE_VRSAVE instruction. If we find it,
|
// Scan the prolog, looking for an UPDATE_VRSAVE instruction. If we find it,
|
||||||
// process it.
|
// process it.
|
||||||
for (unsigned i = 0; MBBI != MBB.end(); ++i, ++MBBI) {
|
for (unsigned i = 0; MBBI != MBB.end(); ++i, ++MBBI) {
|
||||||
@ -821,6 +825,12 @@ void PPCRegisterInfo::emitPrologue(MachineFunction &MF) const {
|
|||||||
unsigned TargetAlign = MF.getTarget().getFrameInfo()->getStackAlignment();
|
unsigned TargetAlign = MF.getTarget().getFrameInfo()->getStackAlignment();
|
||||||
unsigned MaxAlign = MFI->getMaxAlignment();
|
unsigned MaxAlign = MFI->getMaxAlignment();
|
||||||
|
|
||||||
|
if (hasInfo) {
|
||||||
|
// Mark effective beginning of when frame pointer becomes valid.
|
||||||
|
FrameLabelId = DebugInfo->NextLabelID();
|
||||||
|
BuildMI(MBB, MBBI, TII.get(PPC::DWARF_LABEL)).addImm(FrameLabelId);
|
||||||
|
}
|
||||||
|
|
||||||
// Adjust stack pointer: r1 += NegFrameSize.
|
// Adjust stack pointer: r1 += NegFrameSize.
|
||||||
// If there is a preferred stack alignment, align R1 now
|
// If there is a preferred stack alignment, align R1 now
|
||||||
if (!IsPPC64) {
|
if (!IsPPC64) {
|
||||||
@ -866,26 +876,44 @@ void PPCRegisterInfo::emitPrologue(MachineFunction &MF) const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DebugInfo && DebugInfo->hasInfo()) {
|
if (hasInfo) {
|
||||||
std::vector<MachineMove *> &Moves = DebugInfo->getFrameMoves();
|
std::vector<MachineMove> &Moves = DebugInfo->getFrameMoves();
|
||||||
unsigned LabelID = DebugInfo->NextLabelID();
|
|
||||||
|
|
||||||
// Mark effective beginning of when frame pointer becomes valid.
|
if (NegFrameSize) {
|
||||||
BuildMI(MBB, MBBI, TII.get(PPC::DWARF_LABEL)).addImm(LabelID);
|
// Show update of SP.
|
||||||
|
MachineLocation SPDst(MachineLocation::VirtualFP);
|
||||||
|
MachineLocation SPSrc(MachineLocation::VirtualFP, NegFrameSize);
|
||||||
|
Moves.push_back(MachineMove(FrameLabelId, SPDst, SPSrc));
|
||||||
|
} else {
|
||||||
|
MachineLocation SP(IsPPC64 ? PPC::X31 : PPC::R31);
|
||||||
|
Moves.push_back(MachineMove(FrameLabelId, SP, SP));
|
||||||
|
}
|
||||||
|
|
||||||
// Show update of SP.
|
if (HasFP) {
|
||||||
MachineLocation SPDst(MachineLocation::VirtualFP);
|
MachineLocation FPDst(MachineLocation::VirtualFP, FPOffset);
|
||||||
MachineLocation SPSrc(MachineLocation::VirtualFP, NegFrameSize);
|
MachineLocation FPSrc(IsPPC64 ? PPC::X31 : PPC::R31);
|
||||||
Moves.push_back(new MachineMove(LabelID, SPDst, SPSrc));
|
Moves.push_back(MachineMove(FrameLabelId, FPDst, FPSrc));
|
||||||
|
}
|
||||||
|
|
||||||
// Add callee saved registers to move list.
|
// Add callee saved registers to move list.
|
||||||
const std::vector<CalleeSavedInfo> &CSI = MFI->getCalleeSavedInfo();
|
const std::vector<CalleeSavedInfo> &CSI = MFI->getCalleeSavedInfo();
|
||||||
for (unsigned I = 0, E = CSI.size(); I != E; ++I) {
|
for (unsigned I = 0, E = CSI.size(); I != E; ++I) {
|
||||||
MachineLocation CSDst(MachineLocation::VirtualFP,
|
int Offset = MFI->getObjectOffset(CSI[I].getFrameIdx());
|
||||||
MFI->getObjectOffset(CSI[I].getFrameIdx()));
|
unsigned Reg = CSI[I].getReg();
|
||||||
MachineLocation CSSrc(CSI[I].getReg());
|
if (Reg == PPC::LR || Reg == PPC::LR8) continue;
|
||||||
Moves.push_back(new MachineMove(LabelID, CSDst, CSSrc));
|
MachineLocation CSDst(MachineLocation::VirtualFP, Offset);
|
||||||
|
MachineLocation CSSrc(Reg);
|
||||||
|
Moves.push_back(MachineMove(FrameLabelId, CSDst, CSSrc));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mark effective beginning of when frame pointer is ready.
|
||||||
|
unsigned ReadyLabelId = DebugInfo->NextLabelID();
|
||||||
|
BuildMI(MBB, MBBI, TII.get(PPC::DWARF_LABEL)).addImm(ReadyLabelId);
|
||||||
|
|
||||||
|
MachineLocation FPDst(HasFP ? (IsPPC64 ? PPC::X31 : PPC::R31) :
|
||||||
|
(IsPPC64 ? PPC::X1 : PPC::R1));
|
||||||
|
MachineLocation FPSrc(MachineLocation::VirtualFP);
|
||||||
|
Moves.push_back(MachineMove(ReadyLabelId, FPDst, FPSrc));
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there is a frame pointer, copy R1 into R31
|
// If there is a frame pointer, copy R1 into R31
|
||||||
@ -983,12 +1011,12 @@ unsigned PPCRegisterInfo::getFrameRegister(MachineFunction &MF) const {
|
|||||||
return hasFP(MF) ? PPC::X31 : PPC::X1;
|
return hasFP(MF) ? PPC::X31 : PPC::X1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PPCRegisterInfo::getInitialFrameState(std::vector<MachineMove *> &Moves)
|
void PPCRegisterInfo::getInitialFrameState(std::vector<MachineMove> &Moves)
|
||||||
const {
|
const {
|
||||||
// Initial state of the frame pointer is R1.
|
// Initial state of the frame pointer is R1.
|
||||||
MachineLocation Dst(MachineLocation::VirtualFP);
|
MachineLocation Dst(MachineLocation::VirtualFP);
|
||||||
MachineLocation Src(PPC::R1, 0);
|
MachineLocation Src(PPC::R1, 0);
|
||||||
Moves.push_back(new MachineMove(0, Dst, Src));
|
Moves.push_back(MachineMove(0, Dst, Src));
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "PPCGenRegisterInfo.inc"
|
#include "PPCGenRegisterInfo.inc"
|
||||||
|
@ -81,7 +81,7 @@ public:
|
|||||||
// Debug information queries.
|
// Debug information queries.
|
||||||
unsigned getRARegister() const;
|
unsigned getRARegister() const;
|
||||||
unsigned getFrameRegister(MachineFunction &MF) const;
|
unsigned getFrameRegister(MachineFunction &MF) const;
|
||||||
void getInitialFrameState(std::vector<MachineMove *> &Moves) const;
|
void getInitialFrameState(std::vector<MachineMove> &Moves) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace llvm
|
} // end namespace llvm
|
||||||
|
Loading…
x
Reference in New Issue
Block a user