This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Ada] Stop mapping Pure on Ada functions to GCC const


On Friday 01 August 2008 13:28:00 Richard Guenther wrote:
> On Fri, Aug 1, 2008 at 1:02 PM, Duncan Sands <baldrick@free.fr> wrote:
> > Hi,
> >
> >> Pure functions in Ada might raise and this doesn't match (any more)
> >> "const" functions in the middle-end, currently assumed to be
> >> SIDE_EFFECTS free, so ...
> >
> > so a decision was finally made that const functions can't throw?
> > Is the reasoning behind that explained anywhere?  I'm worried
> > that this will represent a big performance hit for Ada: for
> > example, the routines in Ada.Numerics.Elementary_Functions
> > won't be "const" anymore, so won't be CSE'd etc.
> 
> const functions can be CSE'd and DCE'd
> if their result is not used.  const functions without a return value do
> not make sense (this is even documented).
> 
> But - stmt_could_throw_p only returns false if NOTRHOW is set
> on a function.  So, what is the failure mode you are seeing?  That
> a const call is DCE'd?

ACT just proposed an Ada patch that means that vast numbers of functions
will no longer be marked "const".  This is not something to be done lightly,
since (for example) this includes all the math functions, which previously
were "const" in Ada.  The reason for the change is that gcc nowadays assumes
that a "const" function cannot throw (it seems this used not to be the case),
so code that makes use of "const" functions that do sometimes throw may not
work properly when compiled with recent gcc's.  A different solution is to
allow "const" functions to throw.  This would mean, for example, that if the
result of a "const" function is not used then it can only be eliminated as
dead if it is also marked nothrow.

Ciao,

Duncan.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]