Pranav Bhandarkar
2012-Mar-08 01:19 UTC
[LLVMdev] A question about DBG_VALUE and Frame Index
Hi, I have a case that is causing me grief in the form of an assert. The prolog Epilog inserter tries to remove Frame Index references. I have a DBG_VALUE instruction that looks like this (alongwith the Frame Index). This is for the Hexagon backend. ************************** fi#2: size=4, align=4, at location [SP-84] DBG_VALUE <fi#2>, 0, !"fooBar"; line no:299 ************************** Clearly, the FI in question is at an offset of -84 from the SP at entry to the function i.e. FP - 84. So I remove the FI by changing the instruction to. ************************** DBG_VALUE %R30, -84, !"fooBar"; line no:299 ************************** (R30 is the frame pointer register in Hexagon.) So, logically we have moved from frame indices to actually base + offset representation. However the assembly printer, while trying to emit debug info, sticks to the frame index representation and looks for a base+offset reference for -84 !! This is at DwarfCompileUnit.cpp:1334 ************************** int Offset TFI->getFrameIndexReference(*Asm->MF, DVInsn->getOperand(1).getImm(), FrameReg); ************************** In my view we have lost information that (R30-84) is <fi#2>. The above statement is asking the Frame Lowering Information to give it a base+offset pair for the frame index -84. I do not think this is correct or am I missing something here ? For the sake of completeness, I must mention that Hexagon uses the base class version of getFrameIndexReference and does not provide its own. Pranav Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Jakob Stoklund Olesen
2012-Mar-08 16:58 UTC
[LLVMdev] A question about DBG_VALUE and Frame Index
On Mar 7, 2012, at 5:19 PM, Pranav Bhandarkar <pranavb at codeaurora.org> wrote:> Hi, > > I have a case that is causing me grief in the form of an assert. The prolog > Epilog inserter tries to remove Frame Index references. I have a DBG_VALUE > instruction that looks like this (alongwith the Frame Index). This is for > the Hexagon backend. > ************************** > fi#2: size=4, align=4, at location [SP-84] > DBG_VALUE <fi#2>, 0, !"fooBar"; line no:299 > ************************** > > Clearly, the FI in question is at an offset of -84 from the SP at entry to > the function i.e. FP - 84. So I remove the FI by changing the instruction > to. > ************************** > DBG_VALUE %R30, -84, !"fooBar"; line no:299 > ************************** > (R30 is the frame pointer register in Hexagon.)The offset field on a DBG_VALUE instruction refers to the user variable, not the first register argument. Your DBG_VALUE above is saying that fooBar[-84] can be found in %R30. You want something like: DBG_VALUE %R30, -84, 0, !"fooBar" That is a target-dependent DBG_VALUE, you will need to implement the target hooks to create and parse it. Target-dependent DBG_VALUE instrs are recognized by having more than 3 operands. /jakob
Pranav Bhandarkar
2012-Mar-08 20:08 UTC
[LLVMdev] A question about DBG_VALUE and Frame Index
> The offset field on a DBG_VALUE instruction refers to the user > variable, not the first register argument. > > Your DBG_VALUE above is saying that fooBar[-84] can be found in %R30. > > You want something like: > > DBG_VALUE %R30, -84, 0, !"fooBar" > > That is a target-dependent DBG_VALUE, you will need to implement the > target hooks to create and parse it. Target-dependent DBG_VALUE instrs > are recognized by having more than 3 operands. > > /jakobRight, thanks for the information Jakob. I'll dig through the source code / documentation, looking for the necessary target hooks and bother folks on this list, if I have questions regarding this. Thanks again, Pranav