<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 - __attribute__((alias)) should prevent DCE"
   href="https://bugs.llvm.org/show_bug.cgi?id=39088">39088</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>__attribute__((alias)) should prevent DCE
          </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>Severity</th>
          <td>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Interprocedural Optimizations
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>ndesaulniers@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>george.burgess.iv@gmail.com, jyknight@google.com, llozano@chromium.org, llvm-bugs@lists.llvm.org, manojgupta@google.com, niravd@google.com, srhines@google.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Consider this test case, from the Linux kernel's heavily used
MODULE_DEVICE_TABLE macro: <a href="https://godbolt.org/z/Dpxnbp">https://godbolt.org/z/Dpxnbp</a>

static int foo [] = { 42, 0xDEAD };
extern typeof(foo) bar __attribute__((unused, alias("foo")));

At -O2, GCC emits essentially:
  .type foo, @object
  .size foo, 8
foo:
  .long 42
  .long 57005
  .globl bar
  .set bar,fo

Clang with -Wall (and thus -Wunneeded-internal-declaration) warns for
-Wunneeded-internal-declaration, then at -O1 and up produces:

  .type bar,@object # @bar
  .globl bar
bar:
  .long 42 # 0x2a
  .long 57005 # 0xdead
  .size bar, 8

indeed dropping all references to foo.  Removing the `static` type qualifier
can work around this, but it seems that DCE should not remove variables that
are referenced by alias attributes.</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>