Handle callee saved registers in dwarf frame info (lead up to exception

handling.)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29954 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jim Laskey 2006-08-29 16:24:26 +00:00
parent 85aaf9088e
commit ce50a165c7
2 changed files with 48 additions and 15 deletions

View File

@ -35,7 +35,7 @@ using namespace llvm::dwarf;
static cl::opt<bool>
DwarfVerbose("dwarf-verbose", cl::Hidden,
cl::desc("Add comments to Dwarf directives."));
cl::desc("Add comments to Dwarf directives."));
namespace llvm {
@ -1946,7 +1946,7 @@ void DwarfWriter::EmitFrameMoves(const char *BaseLabel, unsigned BaseLabelID,
// Advance row if new location.
if (BaseLabel && LabelID && BaseLabelID != LabelID) {
EmitULEB128Bytes(DW_CFA_advance_loc4);
EmitInt8(DW_CFA_advance_loc4);
EOL("DW_CFA_advance_loc4");
EmitDifference("loc", LabelID, BaseLabel, BaseLabelID);
EOL("");
@ -1955,30 +1955,56 @@ void DwarfWriter::EmitFrameMoves(const char *BaseLabel, unsigned BaseLabelID,
BaseLabel = "loc";
}
int stackGrowth =
Asm->TM.getFrameInfo()->getStackGrowthDirection() ==
TargetFrameInfo::StackGrowsUp ?
AddressSize : -AddressSize;
// If advancing cfa.
if (Dst.isRegister() && Dst.getRegister() == MachineLocation::VirtualFP) {
if (!Src.isRegister()) {
if (Src.getRegister() == MachineLocation::VirtualFP) {
EmitULEB128Bytes(DW_CFA_def_cfa_offset);
EmitInt8(DW_CFA_def_cfa_offset);
EOL("DW_CFA_def_cfa_offset");
} else {
EmitULEB128Bytes(DW_CFA_def_cfa);
EmitInt8(DW_CFA_def_cfa);
EOL("DW_CFA_def_cfa");
EmitULEB128Bytes(RI->getDwarfRegNum(Src.getRegister()));
EOL("Register");
}
int stackGrowth =
Asm->TM.getFrameInfo()->getStackGrowthDirection() ==
TargetFrameInfo::StackGrowsUp ?
AddressSize : -AddressSize;
int Offset = Src.getOffset() / stackGrowth;
EmitULEB128Bytes(Src.getOffset() / stackGrowth);
EmitULEB128Bytes(Offset);
EOL("Offset");
} else {
assert(0 && "Machine move no supported yet.");
}
} else {
unsigned Reg = RI->getDwarfRegNum(Src.getRegister());
int Offset = Dst.getOffset() / stackGrowth;
if (Offset < 0) {
EmitInt8(DW_CFA_offset_extended_sf);
EOL("DW_CFA_offset_extended_sf");
EmitULEB128Bytes(Reg);
EOL("Reg");
EmitSLEB128Bytes(Offset);
EOL("Offset");
} else if (Reg < 64) {
EmitInt8(DW_CFA_offset + Reg);
EOL("DW_CFA_offset + Reg");
EmitULEB128Bytes(Offset);
EOL("Offset");
} else {
EmitInt8(DW_CFA_offset_extended);
EOL("DW_CFA_offset_extended");
EmitULEB128Bytes(Reg);
EOL("Reg");
EmitULEB128Bytes(Offset);
EOL("Offset");
}
}
}
}

View File

@ -668,15 +668,22 @@ void PPCRegisterInfo::emitPrologue(MachineFunction &MF) const {
std::vector<MachineMove *> &Moves = DebugInfo->getFrameMoves();
unsigned LabelID = DebugInfo->NextLabelID();
// Show update of SP.
MachineLocation Dst(MachineLocation::VirtualFP);
MachineLocation Src(MachineLocation::VirtualFP, NegNumbytes);
Moves.push_back(new MachineMove(LabelID, Dst, Src));
// Mark effective beginning of when frame pointer becomes valid.
BuildMI(MBB, MBBI, PPC::DWARF_LABEL, 1).addImm(LabelID);
// Show update of SP.
MachineLocation SPDst(MachineLocation::VirtualFP);
MachineLocation SPSrc(MachineLocation::VirtualFP, NegNumbytes);
Moves.push_back(new MachineMove(LabelID, SPDst, SPSrc));
// Add callee saved registers to move list.
const std::vector<CalleeSavedInfo> &CSI = MFI->getCalleeSavedInfo();
for (unsigned I = 0, E = CSI.size(); I != E; ++I) {
MachineLocation CSDst(MachineLocation::VirtualFP,
MFI->getObjectOffset(CSI[I].getFrameIdx()));
MachineLocation CSSrc(CSI[I].getReg());
Moves.push_back(new MachineMove(LabelID, CSDst, CSSrc));
}
}
// If there is a frame pointer, copy R1 (SP) into R31 (FP)