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

            Bug ID: 39088
           Summary: __attribute__((alias)) should prevent DCE
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Interprocedural Optimizations
          Assignee: unassignedb...@nondot.org
          Reporter: ndesaulni...@google.com
                CC: george.burgess...@gmail.com, jykni...@google.com,
                    lloz...@chromium.org, llvm-bugs@lists.llvm.org,
                    manojgu...@google.com, nir...@google.com,
                    srhi...@google.com

Consider this test case, from the Linux kernel's heavily used
MODULE_DEVICE_TABLE macro: https://godbolt.org/z/Dpxnbp

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to