[llvm-bugs] [Bug 45733] weak symbol should be ignored for optimisation like early CSE .

via llvm-bugs llvm-bugs at lists.llvm.org
Fri May 15 07:36:02 PDT 2020


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

James Y Knight <jyknight at google.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jyknight at google.com,
                   |                            |richard-llvm at metafoo.co.uk
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID

--- Comment #3 from James Y Knight <jyknight at google.com> ---
This is not a bug. Or, at the least, it's an intentional longstanding behavior,
and is consistent with GCC's behavior.

Richard Smith looked into this behavior a couple years ago, so cc'ing.

When a variable is const-qualified, both the frontend's constant evaluator (for
some types like int), and the optimizer, can propagate the known constant value
to users. Adding __attribute__((weak)), or #pragma weak does not change this.

Thus, Clang intentionally emits such variables as "weak_odr" which indicates to
the optimizer that, while the symbol may be overridden by another definition,
the value can be assumed not to change.

You say that you don't like this behavior, and I definitely sympathize with
that -- it is a bit surprising! But that doesn't make it a bug.

-- 
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/20200515/ac5ae79c/attachment.html>


More information about the llvm-bugs mailing list