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: ipa-pure-const fixes


On Sat, Jun 5, 2010 at 1:35 PM, Richard Guenther
<richard.guenther@gmail.com> wrote:
> On Sat, Jun 5, 2010 at 1:15 PM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>>> noreturn functions should at most become looping pure/const. ?I suppose
>>> this worked sofar as a call to abort () _inside_ a noreturn function would
>>> magically do that. ?I guess we need to make sure that functions annotated
>>> noreturn can at most become looping pure/const as well.
>>
>> That would certainly help, but I'm under the impression that the problem is
>> more serious, the ECF_NORETURN flag seems to overrule side-effects and turn
>> calls into ECF_PURE calls alone.
>
> That would mean it would be simple to create a C-only testcase showing this, no?
>
> At least
>
> void __attribute__((noreturn,noinline)) foo(void)
> {
> ?__builtin_trap ();
> }
> int main ().
> {
> ?foo();
> ?return 0;
> }
>
> or with __builtin_abort (); work as expected.
>
> Now there seems to be an issue with call analysis in IPA mode:
>
> ?/* Either calle is unknown or we are doing local analysis.
> ? ? Look to see if there are any bits available for the callee (such as by
> ? ? declaration or because it is builtin) and process solely on the basis of
> ? ? those bits. */
> ?else if (!ipa || !callee_t)
>
> this disregards that functions for which we do not see the body still
> may have callee_t. ?Thus the abort/trap call isn't honored at all
> during IPA analysis.
>
> Honza?

Similar to what IPA-PTA does

Index: ipa-pure-const.c
===================================================================
--- ipa-pure-const.c	(revision 160311)
+++ ipa-pure-const.c	(working copy)
@@ -422,7 +422,7 @@ check_call (funct_state local, gimple ca
      Look to see if there are any bits available for the callee (such as by
      declaration or because it is builtin) and process solely on the basis of
      those bits. */
-  else if (!ipa || !callee_t)
+  else if (!ipa || !callee_t || !gimple_has_body_p (callee_t))
     {
       if (possibly_throws && cfun->can_throw_non_call_exceptions)
         {

gives me

 local analysis of foo
   scanning: __builtin_trap ();
    noreturn nothrow call is looping pure
Function is locally looping.
Function is locally pure.

which is sane and what is expected.  Eric - does the above patch fix the
Ada issue?

Thanks,
Richard.


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