1
0
mirror of https://github.com/RPCS3/llvm.git synced 2025-04-07 07:41:54 +00:00

Propagate more debug loc infos. This also includes some code cleaning.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65207 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Bill Wendling 2009-02-21 00:43:56 +00:00
parent 2625f9b2e4
commit 3d2445f5d9

@ -728,12 +728,14 @@ void X86RegisterInfo::emitPrologue(MachineFunction &MF) const {
bool needsFrameMoves = (MMI && MMI->hasDebugInfo()) || bool needsFrameMoves = (MMI && MMI->hasDebugInfo()) ||
!Fn->doesNotThrow() || !Fn->doesNotThrow() ||
UnwindTablesMandatory; UnwindTablesMandatory;
DebugLoc DL = DebugLoc::getUnknownLoc(); DebugLoc DL = MBBI->getDebugLoc();
// Prepare for frame info. // Prepare for frame info.
unsigned FrameLabelId = 0; unsigned FrameLabelId = 0;
// Get the number of bytes to allocate from the FrameInfo. // Get the number of bytes to allocate from the FrameInfo.
uint64_t StackSize = MFI->getStackSize(); uint64_t StackSize = MFI->getStackSize();
// Get desired stack alignment // Get desired stack alignment
uint64_t MaxAlign = MFI->getMaxAlignment(); uint64_t MaxAlign = MFI->getMaxAlignment();
@ -812,8 +814,9 @@ void X86RegisterInfo::emitPrologue(MachineFunction &MF) const {
// The EFLAGS implicit def is dead. // The EFLAGS implicit def is dead.
MI->getOperand(3).setIsDead(); MI->getOperand(3).setIsDead();
} }
} else } else {
NumBytes = StackSize - X86FI->getCalleeSavedFrameSize(); NumBytes = StackSize - X86FI->getCalleeSavedFrameSize();
}
unsigned ReadyLabelId = 0; unsigned ReadyLabelId = 0;
if (needsFrameMoves) { if (needsFrameMoves) {
@ -828,6 +831,9 @@ void X86RegisterInfo::emitPrologue(MachineFunction &MF) const {
MBBI->getOpcode() == X86::PUSH64r)) MBBI->getOpcode() == X86::PUSH64r))
++MBBI; ++MBBI;
if (MBBI != MBB.end())
DL = MBBI->getDebugLoc();
if (NumBytes) { // adjust stack pointer: ESP -= numbytes if (NumBytes) { // adjust stack pointer: ESP -= numbytes
if (NumBytes >= 4096 && Subtarget->isTargetCygMing()) { if (NumBytes >= 4096 && Subtarget->isTargetCygMing()) {
// Check, whether EAX is livein for this function // Check, whether EAX is livein for this function
@ -845,7 +851,8 @@ void X86RegisterInfo::emitPrologue(MachineFunction &MF) const {
// necessary to ensure that the guard pages used by the OS virtual memory // necessary to ensure that the guard pages used by the OS virtual memory
// manager are allocated in correct sequence. // manager are allocated in correct sequence.
if (!isEAXAlive) { if (!isEAXAlive) {
BuildMI(MBB, MBBI,DL, TII.get(X86::MOV32ri), X86::EAX).addImm(NumBytes); BuildMI(MBB, MBBI, DL, TII.get(X86::MOV32ri), X86::EAX)
.addImm(NumBytes);
BuildMI(MBB, MBBI, DL, TII.get(X86::CALLpcrel32)) BuildMI(MBB, MBBI, DL, TII.get(X86::CALLpcrel32))
.addExternalSymbol("_alloca"); .addExternalSymbol("_alloca");
} else { } else {
@ -921,7 +928,7 @@ void X86RegisterInfo::emitEpilogue(MachineFunction &MF,
NumBytes = FrameSize - CSSize; NumBytes = FrameSize - CSSize;
// pop EBP. // pop EBP.
BuildMI(MBB, MBBI, DL, BuildMI(MBB, MBBI, DL,
TII.get(Is64Bit ? X86::POP64r : X86::POP32r), FramePtr); TII.get(Is64Bit ? X86::POP64r : X86::POP32r), FramePtr);
} else { } else {
NumBytes = StackSize - CSSize; NumBytes = StackSize - CSSize;
@ -938,6 +945,8 @@ void X86RegisterInfo::emitEpilogue(MachineFunction &MF,
--MBBI; --MBBI;
} }
DL = MBBI->getDebugLoc();
// If there is an ADD32ri or SUB32ri of ESP immediately before this // If there is an ADD32ri or SUB32ri of ESP immediately before this
// instruction, merge the two instructions. // instruction, merge the two instructions.
if (NumBytes || MFI->hasVarSizedObjects()) if (NumBytes || MFI->hasVarSizedObjects())
@ -997,19 +1006,22 @@ void X86RegisterInfo::emitEpilogue(MachineFunction &MF,
// Incoporate the retaddr area. // Incoporate the retaddr area.
Offset = StackAdj-MaxTCDelta; Offset = StackAdj-MaxTCDelta;
assert(Offset >= 0 && "Offset should never be negative"); assert(Offset >= 0 && "Offset should never be negative");
if (Offset) { if (Offset) {
// Check for possible merge with preceeding ADD instruction. // Check for possible merge with preceeding ADD instruction.
Offset += mergeSPUpdates(MBB, MBBI, StackPtr, true); Offset += mergeSPUpdates(MBB, MBBI, StackPtr, true);
emitSPUpdate(MBB, MBBI, StackPtr, Offset, Is64Bit, TII); emitSPUpdate(MBB, MBBI, StackPtr, Offset, Is64Bit, TII);
} }
// Jump to label or value in register. // Jump to label or value in register.
if (RetOpcode == X86::TCRETURNdi|| RetOpcode == X86::TCRETURNdi64) if (RetOpcode == X86::TCRETURNdi|| RetOpcode == X86::TCRETURNdi64)
BuildMI(MBB, MBBI, DL, TII.get(X86::TAILJMPd)). BuildMI(MBB, MBBI, DL, TII.get(X86::TAILJMPd)).
addGlobalAddress(JumpTarget.getGlobal(), JumpTarget.getOffset()); addGlobalAddress(JumpTarget.getGlobal(), JumpTarget.getOffset());
else if (RetOpcode== X86::TCRETURNri64) { else if (RetOpcode== X86::TCRETURNri64)
BuildMI(MBB, MBBI, DL, TII.get(X86::TAILJMPr64), JumpTarget.getReg()); BuildMI(MBB, MBBI, DL, TII.get(X86::TAILJMPr64), JumpTarget.getReg());
} else else
BuildMI(MBB, MBBI, DL, TII.get(X86::TAILJMPr), JumpTarget.getReg()); BuildMI(MBB, MBBI, DL, TII.get(X86::TAILJMPr), JumpTarget.getReg());
// Delete the pseudo instruction TCRETURN. // Delete the pseudo instruction TCRETURN.
MBB.erase(MBBI); MBB.erase(MBBI);
} else if ((RetOpcode == X86::RET || RetOpcode == X86::RETI) && } else if ((RetOpcode == X86::RET || RetOpcode == X86::RETI) &&