[LLVMdev] Expected behavior of eliminateFrameIndex() on dbg_value machine instructions
Richard Osborne
richard at xmos.com
Tue Oct 11 06:18:47 PDT 2011
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>
More information about the llvm-dev
mailing list