<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Extraneous enum record in DWARF with type units"
   href="https://bugs.llvm.org/show_bug.cgi?id=51087">51087</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Extraneous enum record in DWARF with type units
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Keywords</th>
          <td>wrong-debug
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Common Code Generator Code
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>jeremy.morse.llvm@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>aprantl@apple.com, dblaikie@gmail.com, llvm-bugs@lists.llvm.org, paul.robinson@am.sony.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This PR is a summary of an interesting scenario I've run into, where using type
units increases binary size, although only compared to constructor homing
de-duplication of types. Take a look at this reproducer, compiled with the
following flags using main / ee8da6369225f4:

clang++ test.cpp -o test.o -c -g -O2 -fdebug-types-section -gdwarf-5

--------8<--------
class fudge {
public:
  enum blah {
    a = 1,
    b = 2
  };

  blah baz;

  fudge() { }
};

fudge bar;
-------->8--------

If you take a look with llvm-dwarfdump at the output file, there are type units
for "fudge" and "blah" as expected, and for the "bar variable:

  0x0000001e:   DW_TAG_variable
                  DW_AT_name      ("bar")
                  DW_AT_type      (0x00000029 "class ")
                  DW_AT_external  (true)
                  DW_AT_decl_file ("test.cpp")
                  DW_AT_decl_line (13)
                  DW_AT_location  (DW_OP_addrx 0x0)

  0x00000029:   DW_TAG_class_type
                  DW_AT_declaration       (true)
                  DW_AT_signature (0x1c93e96b85e3f5c8)

  0x00000032:     DW_TAG_enumeration_type
                    DW_AT_declaration     (true)
                    DW_AT_signature       (0x9b7ed24ce9445148)

To me, the DW_TAG_enumeration_type in the class definition is unexpected, as
the "fudge" type unit completely describes the contents of the class. Nothing
in the DWARF refers to the enum type. To me, this seems like an inefficiency.

Not shown is the larger project I've looked at, where there are enough
redundant child-enum-DIEs and child-class-DIEs in each class DIE to add a few
Mb of .debug_info (out of ~160Mb of .debug_info). The net effect is that
running with "-Xclang -fuse-ctor-homing -fdebug-types-section" is larger than
just using "-Xclang -fuse-ctor-homing"</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>