This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Make attribute functions pure
Paolo Bonzini <paolo.bonzini@polimi.it> writes:
>> But don't the get_attr_* functions usually call recog_memoized?
>> That certainly isn't a pure function.
>
> IIUC, a pure function can modify the global status as long as a single
> call can always give the same result.
Well, that's not what the documentation says:
@item pure
@cindex @code{pure} function attribute
Many functions have no effects except the return value and their
return value depends only on the parameters and/or global variables.
[...]
GCC assumes that pure functions don't modify memory. And even
though recog_memoized() conceptually depends only on PATTERN (insn),
the implementation really does modify insn. Saying that it's pure
could lead to some subtle miscompilation later.
Richard