[PATCH 5/5] Remove const attribute on get_log2

Richard Henderson rth@twiddle.net
Wed May 15 14:56:00 GMT 2013


On 05/15/2013 12:50 AM, Andreas Schwab wrote:
> Florian Weimer <fweimer@redhat.com> writes:
> 
>> I think that at one point, it was fully acceptable to label functions
>> which perform memoization as "const".
> 
> I think that's what pure is for.

No, "pure" is for functions that only read from memory, but don't write.
So if we're talking about the letter of the law, memoization isn't allowed
there either.

I don't like that LLVM's optimization breaks with such long standing usage of
the attribute, and I will claim that it's a bug.

That said, get_log2 is used in exactly one place in math/atest-exp2.c, and it's
a place that's not going to be helped by the const attribute at all.  I'm ok
with removing the attribute in this case.

Much more useful would be figuring out a way to store the log2/exp1/exp_m1
values as mp_limb_t's rather than strings.  Then we have no runtime
initialization at all.


r~



More information about the Libc-alpha mailing list