[PATCH] Have HasSideEffects() return false for __attribute__((const)) functions
Aaron Ballman
aaron.ballman at gmail.com
Mon Mar 23 09:38:02 PDT 2015
On Mon, Mar 23, 2015 at 12:33 PM, hfinkel at anl.gov <hfinkel at anl.gov> wrote:
> In http://reviews.llvm.org/D8548#145253, @mkuper wrote:
>
>> I think PureAttr isn't strong enough.
>>
>> char foo(char *a)
>> {
>>
>> return *a;
>>
>> }
>>
>> is pure, but isn't side-effect free.
>
>
> Loads are not considered side effects currently, however. This works fine:
>
> void bar(int *i) {
> __builtin_assume(*i > 0);
> }
>
> and, thus, my recommendation ;)
Some loads are side-effecting though, such as volatile loads:
int foo(volatile int *a) {
return *a;
}
Can that be marked __attribute__((pure))? Or can pure access a
volatile global variable?
~Aaron
>
>
> http://reviews.llvm.org/D8548
>
> EMAIL PREFERENCES
> http://reviews.llvm.org/settings/panel/emailpreferences/
>
>
More information about the cfe-commits
mailing list