[llvm-bugs] [Bug 39088] New: __attribute__((alias)) should prevent DCE
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Sep 26 10:48:19 PDT 2018
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: unassignedbugs at nondot.org
Reporter: ndesaulniers at google.com
CC: george.burgess.iv at gmail.com, jyknight at google.com,
llozano at chromium.org, llvm-bugs at lists.llvm.org,
manojgupta at google.com, niravd at google.com,
srhines at 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, at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180926/f0efc588/attachment.html>
More information about the llvm-bugs
mailing list