[llvm-dev] [debug-info] Stack pointer based variable locations

Reid Kleckner via llvm-dev llvm-dev at lists.llvm.org
Fri May 7 12:58:36 PDT 2021


On Fri, May 7, 2021 at 4:01 AM via llvm-dev <llvm-dev at lists.llvm.org> wrote:

> > Looks like GCC manages to use DW_OP_fbreg for the example given, which
> > looks like it works/is correct despite the the pushes/pops (because
> > it's rbp, I guess - base pointer rather than stack pointer). Perhaps
> > we could do something like that too, in cases like this?
>
> RBP isn't used as a frame pointer in 'example' when building with gcc
> (7.5.0) or clang
> (71597d40e878). It looks like gcc is able to use DW_OP_fbreg because it
> sets DW_AT_frame_base in the
> parent DIE to DW_OP_call_frame_cfa. Is there anything stopping us from
> doing the same?
>

That sounds like the right solution. The variable location of a stack
object should be based on something that does not change throughout the
function.

LLVM's behavior was probably less of an issue before we started doing call
frame optimization for x86 (X86CallFrameOptimization), meaning converting
stores to pushes. Before that, LLVM would mostly only emit SP adjustments
when a frame pointer was in use, so the variable location would be based on
RBP.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210507/d69f0a41/attachment.html>


More information about the llvm-dev mailing list