[llvm-bugs] [Bug 49953] New: No DW_AT_abstract_origin emitted for a DW_TAG_lexical_block in an inlined function

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Apr 13 08:08:44 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=49953

            Bug ID: 49953
           Summary: No DW_AT_abstract_origin emitted for a
                    DW_TAG_lexical_block in an inlined function
           Product: clang
           Version: 11.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: tankut.baris.aktemur at intel.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

Suppose we have

  __attribute__((always_inline))
  static void aFunction() {
    int a = 42;
    if(a > 2) {
      int value = a;
      value += 10;
    }
  }

The debug info for the concrete inlined instance of this function does not
contain DW_AT_abstract_origin attributes in the DW_TAG_lexical_block
entries.  E.g. the DIE of the inlined function above is

0x00000087:     DW_TAG_inlined_subroutine
                  DW_AT_abstract_origin (0x0000002a "aFunction")
                  DW_AT_low_pc  (0x00000000004004b2)
                  DW_AT_high_pc (0x00000000004004d2)
                  DW_AT_call_file       ("/tmp/test.c")
                  DW_AT_call_line       (11)
                  DW_AT_call_column     (0x03)

0x0000009b:       DW_TAG_variable
                    DW_AT_location      (DW_OP_fbreg -4)
                    DW_AT_abstract_origin       (0x00000032 "a")

0x000000a3:       DW_TAG_lexical_block
                    DW_AT_low_pc        (0x00000000004004c3)
                    DW_AT_high_pc       (0x00000000004004d2)

0x000000b0:         DW_TAG_variable
                      DW_AT_location    (DW_OP_fbreg -8)
                      DW_AT_abstract_origin     (0x0000003e "value")

whereas the abstract DIE is

0x0000002a:   DW_TAG_subprogram
                DW_AT_name      ("aFunction")
                DW_AT_decl_file ("/tmp/test.c")
                DW_AT_decl_line (2)
                DW_AT_inline    (DW_INL_inlined)

0x00000032:     DW_TAG_variable
                  DW_AT_name    ("a")
                  DW_AT_decl_file       ("/tmp/test.c")
                  DW_AT_decl_line       (3)
                  DW_AT_type    (0x0000004b "int")

0x0000003d:     DW_TAG_lexical_block

0x0000003e:       DW_TAG_variable
                    DW_AT_name  ("value")
                    DW_AT_decl_file     ("/tmp/test.c")
                    DW_AT_decl_line     (5)
                    DW_AT_type  (0x0000004b "int")

I'm not 100% sure that omitting the DW_AT_abstract_origin is a bug.
However, the DWARF 5 spec states in Section 3.3.8.2 that 

   A concrete instance tree may contain entries which do not correspond to
   entries in the abstract instance tree to describe new entities that are
specific to
   a particular inlined expansion. In that case, they will not have associated
   entries in the abstract instance tree, do not contain DW_AT_abstract_origin
   attributes, and must contain all their own attributes directly.

If I read this backward, I interpret that an entry without a
DW_AT_abstract_origin
attribute denotes an entry that does not exist in the abstract instance tree.
This makes me believe that Clang's behavior is a bug.

When the DW_AT_abstract_origin attribute is missing, a consumer may try
to find the corresponding abstract origin, but this may not be a bullet-proof
process in general.  If Clang emitted it explicitly, the association could be
done with precision.

-- 
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/20210413/115404df/attachment-0001.html>


More information about the llvm-bugs mailing list