[PATCH] D147506: [DebugLine] save one debug line entry for empty prologue

Shoaib Meenai via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 22 13:34:12 PDT 2023


smeenai added a comment.

This appears to break Godbolt's strategy for filtering code to only include your own functions. As a simple example, https://godbolt.org/z/6cbGeqc11 only displays the `ret`, whereas unchecking the filter for library functions (https://godbolt.org/z/qzGv7nGKq) displays the entire function. See https://github.com/compiler-explorer/compiler-explorer/issues/5020 and https://github.com/compiler-explorer/compiler-explorer/issues/5050 for more examples.

For the code in my Godbolt link, we'd previously emit debug info like:

  _Z1fOSt10shared_ptrIiE:                 # @_Z1fOSt10shared_ptrIiE
  .Lfunc_begin0:
          .file   15 "llvm-bisect/inputs" "godbolt-filtering.cpp" md5 0xa1c9e6751ece14286108589bebeb1200
          .loc    15 3 0                          # llvm-bisect/inputs/godbolt-filtering.cpp:3:0
          .cfi_startproc
  # %bb.0:
          #DEBUG_VALUE: f:sp <- $rdi
          #DEBUG_VALUE: operator bool:this <- $rdi
          .loc    2 1300 23 prologue_end          # /usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/bits/shared_ptr_base.h:1300:23
          cmpq    $0, (%rdi)
          setne   %al
  .Ltmp0:
          .loc    15 4 5                          # llvm-bisect/inputs/godbolt-filtering.cpp:4:5
          retq

So it was obvious that the function was associated with user code and not library code. We now emit the following debug info:

  _Z1fOSt10shared_ptrIiE:                 # @_Z1fOSt10shared_ptrIiE
  .Lfunc_begin0:
          .cfi_startproc
  # %bb.0:                                # %entry
          #DEBUG_VALUE: f:sp <- $rdi
          #DEBUG_VALUE: operator bool:this <- $rdi
          .loc    2 1300 23 prologue_end          # /usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/bits/shared_ptr_base.h:1300:23
          cmpq    $0, (%rdi)
          setne   %al
  .Ltmp0:
          .file   15 "llvm-bisect/inputs" "godbolt-filtering.cpp" md5 0xa1c9e6751ece14286108589bebeb1200
          .loc    15 4 5                          # llvm-bisect/inputs/godbolt-filtering.cpp:4:5
          retq

So the `retq` is the first place we see the association of the assembly with the user's input file, hence the truncated Godbolt output. How should Godbolt be handling the association of functions with user code (vs. library code) instead?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147506/new/

https://reviews.llvm.org/D147506



More information about the llvm-commits mailing list