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

Kuperstein, Michael M michael.m.kuperstein at intel.com
Mon Mar 23 09:04:59 PDT 2015


Sorry for any confusion, Hal, I didn't mean that the implementation doesn’t make sense to me (it does!), only the phrasing of the warning.

The alternative phrasing sounds good.

-----Original Message-----
From: hfinkel at anl.gov [mailto:hfinkel at anl.gov] 
Sent: Monday, March 23, 2015 18:00
To: Kuperstein, Michael M; richard at metafoo.co.uk; aaron.ballman at gmail.com; hfinkel at anl.gov
Cc: cfe-commits at cs.uiuc.edu
Subject: Re: [PATCH] Have HasSideEffects() return false for __attribute__((const)) functions

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/


---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.




More information about the cfe-commits mailing list