[llvm-bugs] [Bug 34227] New: LLVM should store register parameters to the stack at -O0 for debugability

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Aug 17 15:39:50 PDT 2017


            Bug ID: 34227
           Summary: LLVM should store register parameters to the stack at
                    -O0 for debugability
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Common Code Generator Code
          Assignee: unassignedbugs at nondot.org
          Reporter: rnk at google.com
                CC: aprantl at apple.com, llvm-bugs at lists.llvm.org,
                    llvm at inglorion.net

Consider this C++ code:

struct Foo { int x; Foo(); ~Foo(); };
void g(int x);
void f(Foo f, int n) {
  while (--n)

Clang will emit a dbg.declare for f:f that looks like this:

define void @_Z1f3Fooi(%struct.Foo* nocapture readnone %f, i32 %n)
local_unnamed_addr #0 !dbg !7 {
  tail call void @llvm.dbg.declare(metadata %struct.Foo* %f, metadata !20,
metadata !22), !dbg !23

The location is not a static alloca, so we must emit DBG_VALUE instructions
rather than recording a simple frame index in a table. On Linux, the value is
in RDI, which is soon killed by the call to g(0), as we can see in the

_Z1f3Fooi:                              # @_Z1f3Fooi
        pushq   %rbx
        #DEBUG_VALUE: f:f <- [%RDI+0]
        cmpl    $1, %esi
        je      .LBB0_3
        #DEBUG_VALUE: f:f <- [%RDI+0]
        movl    $1, %ebx
        subl    %esi, %ebx
        #DEBUG_VALUE: f:f <- [%RDI+0]
        xorl    %edi, %edi    # RDI killed here
        callq   _Z1gi

Debuggers won't be able to print 'f' after the first iteration of the loop.

This would also remove the need for swift to add extra empty inline asm
statements to function epilogues just to keep unused parameters alive for the
entire function, or to emit extra allocas just so it can dbg.declare them. Many
other non-C frontends also directly emit SSA without any intermediate allocas,
and this would improve things for them too.

Debug info quality aside, users have also requested functionality equivalent to
MSVC's /homeparams flag (-msave-regs
http://lists.llvm.org/pipermail/llvm-dev/2017-April/112431.html), so that even
in optimized builds without debug info, they can find initial parameter values.

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170817/38ed6d30/attachment-0001.html>

More information about the llvm-bugs mailing list