[llvm-bugs] [Bug 50735] Missing optimization for member function with const attribute

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jun 16 23:03:00 PDT 2021


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

David Blaikie <dblaikie at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dblaikie at gmail.com
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID

--- Comment #1 from David Blaikie <dblaikie at gmail.com> ---
"const" on member functions is very different than __attribute__((const)) for
instance, in the code below it would be entirely valid for the
Function_Attributes_const_0 member function to return a different value on each
call (eg: it could use a global variable and increment it then return the
incremented value) - so this optimization cannot be performed.

You can put __attribute__((const)) on the member function and then it should do
what you expect.

-- 
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/20210617/884c13e0/attachment-0001.html>


More information about the llvm-bugs mailing list