Richard Osborne
2011-Oct-10 17:26 UTC
[LLVMdev] Expected behavior of eliminateFrameIndex() on dbg_value machine instructions
I'm investigating a bug associated with debug information that manifests itself in the XCore backend (PR11105). I'd like to understand what the expected behavior of eliminateFrameIndex() is when it is called on a dbg_value machine instruction. Currently the XCore target replaces the frame index with the frame register and sets the next operand to the byte offset from the frame register. A quick glance at some of the other targets suggests this is the right thing to do (for example ARMBaseRegisterInfo::eliminateFrameIndex and Thumb1RegisterInfo::eliminateFrameIndex appear to handle dbg_value in exactly the same way). Unfortunately this results in an assertion firing in MachineFrameInfo::getObjectOffset(). This is due to CompileUnit::constructVariableDIE() passing the second operand of the dbg_value instruction (set to the byte offset) to getFrameIndexReference() which expects a frame index as an argument. Am I doing something wrong in eliminateFrameIndex()? Is this a bug in CompileUnit::constructVariableDIE()? Is there something else I'm missing? Thanks, Richard -- Richard Osborne | XMOS http://www.xmos.com
Jakob Stoklund Olesen
2011-Oct-10 18:19 UTC
[LLVMdev] Expected behavior of eliminateFrameIndex() on dbg_value machine instructions
On Oct 10, 2011, at 10:26 AM, Richard Osborne wrote:> I'm investigating a bug associated with debug information that manifests > itself in the XCore backend (PR11105). I'd like to understand what the > expected behavior of eliminateFrameIndex() is when it is called on a > dbg_value machine instruction.That is up to the target. The TII::emitFrameIndexDebugValue() hook is called to insert DBG_VALUE instructions referring to values on the stack. The target's eliminateFrameIndex() should be able to handle any DBG_VALUE instructions created by this hook. If you don't implement the hook, you will get DBG_VALUE instructions with just a FrameIndex operand followed by the mandatory Offset and Metadata operands. /jakob
Richard Osborne
2011-Oct-11 13:18 UTC
[LLVMdev] Expected behavior of eliminateFrameIndex() on dbg_value machine instructions
On 10/10/11 19:19, Jakob Stoklund Olesen wrote:> On Oct 10, 2011, at 10:26 AM, Richard Osborne wrote: >> I'm investigating a bug associated with debug information that manifests >> itself in the XCore backend (PR11105). I'd like to understand what the >> expected behavior of eliminateFrameIndex() is when it is called on a >> dbg_value machine instruction. > That is up to the target. > > The TII::emitFrameIndexDebugValue() hook is called to insert DBG_VALUE instructions referring to values on the stack.Thanks for pointing this out. Looking at the code in constructVariableDIE it seems to use the number of operands to determine if the DBG_VALUE is target specific or not. It is considered target specific if it does not have exactly 3 operands in which case the getDebugValueLocation hook is called. Implementing both TII::emitFrameIndexDebugValue() and AsmPrinter::getDebugValueLocation() in the XCore backend seems to fix the problem I was seeing. I'm still confused about what the following code in CompileUnit::constructVariableDIE is trying to do: if (const MachineInstr *DVInsn = DV->getMInsn()) { bool updated = false; if (DVInsn->getNumOperands() == 3) { if (DVInsn->getOperand(0).isReg()) { const MachineOperand RegOp = DVInsn->getOperand(0); const TargetRegisterInfo *TRI = Asm->TM.getRegisterInfo(); if (DVInsn->getOperand(1).isImm() && TRI->getFrameRegister(*Asm->MF) == RegOp.getReg()) { unsigned FrameReg = 0; const TargetFrameLowering *TFI = Asm->TM.getFrameLowering(); int Offset TFI->getFrameIndexReference(*Asm->MF, DVInsn->getOperand(1).getImm(), FrameReg); MachineLocation Location(FrameReg, Offset); addVariableAddress(DV, VariableDie, Location); If the intention is to handle the case where the target doesn't implement emitFrameIndexDebugValue(), then there is a mismatch between the operands it expects and the operands added in UserValue::insertDebugValue(). I've attached a patch which fixes this. Does this look correct to you?> The target's eliminateFrameIndex() should be able to handle any DBG_VALUE instructions created by this hook. > > If you don't implement the hook, you will get DBG_VALUE instructions with just a FrameIndex operand followed by the mandatory Offset and Metadata operands.This behavior doesn't match the comment above TII::emitFrameIndexDebugValue() which says "For targets that do not support this the debug info is simply lost". In UserValue::insertDebugValue in LiveDebugVariables.cpp if emitFrameIndexDebugValue returns 0 then it adds a DBG_VALUE with the standard operands. However in other places where emitFrameIndexDebugValue is called it appears to removes the debug value (e.g. in InlineSpiller::spillAroundUses()). Should the comment be updated or is the code in LiveDebugVariables.cpp doing the wrong thing?> /jakob-- Richard Osborne | XMOS http://www.xmos.com -------------- next part -------------- A non-text attachment was scrubbed... Name: dbg_value.patch Type: text/x-patch Size: 1166 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20111011/b4dd9e1b/attachment.bin>
Seemingly Similar Threads
- [LLVMdev] Expected behavior of eliminateFrameIndex() on dbg_value machine instructions
- [LLVMdev] Expected behavior of eliminateFrameIndex() on dbg_value machine instructions
- [LLVMdev] A question about DBG_VALUE and Frame Index
- [LLVMdev] creating a vreg in eliminateFrameIndex()
- [LLVMdev] creating a vreg in eliminateFrameIndex()