[llvm-bugs] [Bug 39088] __attribute__((alias)) should prevent DCE

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Sep 26 11:28:22 PDT 2018


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

Nick Desaulniers <ndesaulniers at google.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID

--- Comment #1 from Nick Desaulniers <ndesaulniers at google.com> ---
Sorry, after thinking more about this and discussing more with a coworker, I
think Clang is doing the right thing, and that `static` should be removed from
declarations passed to MODULE_DEVICE_TABLE without other references.  Clang's
Dead Code Elimination (DCE) here seems to be more aggressive, but it still
looks correct to me.

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

GCC and Clang at -O2 both produce references to foo and bar.

Adding `static` to foo, then GCC produces both references, while Clang moves
the data to bar and removes foo.  This is safe because foo has no other
references, and bar is what we care about in the Linux kernel's case.

-- 
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/4b42a642/attachment-0001.html>


More information about the llvm-bugs mailing list