[PATCH] Have HasSideEffects() return false for __attribute__((const)) functions

hfinkel at anl.gov hfinkel at anl.gov
Mon Mar 23 09:00:21 PDT 2015


In http://reviews.llvm.org/D8548#145202, @mkuper wrote:

> Also, there's something a bit odd about the warning text for an assume with side-effects.
>
> "the argument to '__assume' has side effects that will be discarded" suggests that only the side effects will be discarded. 
> This:
>  (a) doesn't make a lot of sense to me, and


This was done for MSVC compatibility (and to likewise avoid related questions about what the assumption should mean if it has side-effects that cannot be CSE'd with similar side effects outside the assumption).

> (b) doesn't imply that nothing at all will be emitted.


Fair enough. From the user's perspective, the most "important" things is that the side effects are being dropped -- the optimizer effects are secondary. Nevertheless, we can certainly say something that the optimizer will ignore the assumption.

> That is, for "assume(a > 0 && i++)", the warning would make me expect that what I ended up with was equivalent to "assume(a > 0)" or perhaps "assume(a > 0 && i)".


Reasonable point.

> Is this just a problem with how I'm reading the warning? If not, any suggestions for alternative text?


How about just saying?:

  the argument to '__assume' has side effects that will be discarded, and the optimizer will ignore the assumption


http://reviews.llvm.org/D8548

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list