Hi,<br><br>  In that case, shouldn't the DW_CFA_offset instructions contain positive offsets, since <br>sp points at the last saved register (%rbx) ?<br><br>                            Zoltan<br><br><div class="gmail_quote">
On Sun, Aug 2, 2009 at 11:12 PM, Bill Wendling <span dir="ltr"><<a href="mailto:isanbard@gmail.com">isanbard@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Correct, because it's using the %esp register unmodified as the CFA<br>
offset, so it doesn't need to use DW_CFA_def_cfa_offset to define a<br>
new one. Here's the DWARF definition of DW_CFA_def_cfa_offset:<br>
<div class="im"><br>
"DW_CFA_def_cfa_offset<br>
<br>
</div>The DW_CFA_def_cfa_offset instruction takes a single unsigned LEB128<br>
operand representing a (non-factored) offset. The required action is<br>
to define the current CFA rule to use the provided offset (but to keep<br>
the old register)."<br>
<br>
In other words, the DW_CFA_def_cfa_offset isn't be needed in this case.<br>
<br>
-bw<br>
<div><div></div><div class="h5"><br>
On Aug 2, 2009, at 6:03 AM, Zoltan Varga wrote:<br>
<br>
> Hi,<br>
><br>
>   Attached an .ll file which reproduces this on x86-64. Compile it<br>
> using:<br>
><br>
> llvm-as -f empty.ll && llc -f empty.bc && as empty.s<br>
><br>
> The prolog of the 'stelemref' function looks like this:<br>
><br>
> 0000000000000000 <stelemref>:<br>
>    0:   41 57                   push   %r15<br>
>    2:   41 56                   push   %r14<br>
>    4:   53                      push   %rbx<br>
><br>
> While the unwind info looks like this:<br>
><br>
> 00000018 00000014 0000001c FDE cie=00000000 pc=00000000..00000045<br>
>   DW_CFA_advance_loc: 5 to 00000005<br>
>   DW_CFA_offset: r3 (rbx) at cfa-32<br>
>   DW_CFA_offset: r14 (r14) at cfa-24<br>
>   DW_CFA_offset: r15 (r15) at cfa-16<br>
><br>
> Notice that there is no DW_CFA_def_cfa_offset instruction.<br>
><br>
>                     Zoltan<br>
><br>
><br>
> On Sun, Aug 2, 2009 at 1:48 PM, Bill Wendling <<a href="mailto:isanbard@gmail.com">isanbard@gmail.com</a>><br>
> wrote:<br>
> On Jul 31, 2009, at 10:56 AM, Zoltan Varga wrote:<br>
> > Hi,<br>
> ><br>
> > This is a resend of a patch sent earlier which got lost in the ml<br>
> > traffic.<br>
> ><br>
> >   The x86 jit doesn't generate a def_cfa_offset unwind instruction<br>
> > after the<br>
> > pushes in the function prolog if the function doesn't<br>
> ><br>
> > have any stack space, i.e. for a prolog like:<br>
> ><br>
> > 0x40011870:     push %r15<br>
> ><br>
> > 0x40011872:     push %r14<br>
> ><br>
> > 0x40011874:     push %rbx<br>
> ><br>
> > The attached patch fixes this.<br>
> ><br>
> Hi Zoltan,<br>
><br>
> (Sorry it took me a while to look at this email.)<br>
><br>
> I don't think that this patch is the correct solution. The unwind info<br>
> for callee-saved registers should be emitted in this code:<br>
><br>
>   // Skip the callee-saved push instructions.<br>
>   bool RegsSaved = false;<br>
>   while (MBBI != MBB.end() &&<br>
>          (MBBI->getOpcode() == X86::PUSH32r ||<br>
>           MBBI->getOpcode() == X86::PUSH64r)) {<br>
>     RegsSaved = true;<br>
>     ++MBBI;<br>
>   }<br>
><br>
>   if (RegsSaved && needsFrameMoves) {<br>
>     // Mark end of callee-saved push instructions.<br>
>     unsigned LabelId = MMI->NextLabelID();<br>
>     BuildMI(MBB, MBBI, DL, TII.get(X86::DBG_LABEL)).addImm(LabelId);<br>
><br>
>     // Emit DWARF info specifying the offsets of the callee-saved<br>
> registers.<br>
>     emitCalleeSavedFrameMoves(MF, LabelId, HasFP ? FramePtr :<br>
> StackPtr);<br>
>   }<br>
><br>
> The code you modified is placing a label/machine-move after the "subl<br>
> X, %esp" instruction when there isn't a frame pointer. (N.B., this<br>
> instruction won't exist if NumBytes == 0.)<br>
><br>
> Do you have a code example for me to look at?<br>
><br>
> -bw<br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
><br>
</div></div>> <empty.ll>_______________________________________________<br>
<div><div></div><div class="h5">> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br>