public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: Jan Hubicka <hubicka@ucw.cz>
Cc: Eric Botcazou <ebotcazou@adacore.com>,
	GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [patch] Restore cross-language inlining into Ada
Date: Thu, 21 Jan 2016 14:14:00 -0000	[thread overview]
Message-ID: <CAFiYyc25MQZoZYEbRRNGRiaHn1o1=2zWYmr=UHm4111fqrnaeQ@mail.gmail.com> (raw)
In-Reply-To: <20160121141352.GB12209@atrey.karlin.mff.cuni.cz>

On Thu, Jan 21, 2016 at 3:13 PM, Jan Hubicka <hubicka@ucw.cz> wrote:
>> On Wed, Jan 20, 2016 at 9:32 AM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>> > Hi,
>> >
>> > this patch from Jan:
>> >   https://gcc.gnu.org/ml/gcc-patches/2015-03/msg01388.html
>> > totally disabled cross-language inlining into Ada without notice, by adding a
>> > check that always fails when the language of the callee is not Ada...
>> > The attached patch simply deletes this new check to restore the initial state.
>
> I only updated
> -  /* Don't inline if the callee can throw non-call exceptions but the
> -     caller cannot.
> -     FIXME: this is obviously wrong for LTO where STRUCT_FUNCTION is missing.
> -     Move the flag into cgraph node or mirror it in the inline summary.  */
> -  else if (callee_fun && callee_fun->can_throw_non_call_exceptions
> -          && !(caller_fun && caller_fun->can_throw_non_call_exceptions))
> -    {
> -      e->inline_failed = CIF_NON_CALL_EXCEPTIONS;
> -      inlinable = false;
> -    }
> to actually work with LTO where callee_fun/caller_fun is not always available
> (but sometimes, like when ICF requested the body or when we merged profiles, it
> is).
>
>> >
>> > Tested on x86_64-suse-linux, OK for the mainline?
>>
>> I think the intent was to allow inlining a non-throwing -fnon-call-exceptions
>> function into a not -fnon-call-exceptions function but _not_ a
>> non-throwing not -fnon-call-exceptions function (that "not-throwing" is
>> basically a non-sensible test) into a -fnon-call-exceptions function
>> because that may now miss EH edges.
>>
>> So the test looks conservatively correct to me - we can't reliably
>> check whether the callee throws if the IL now were -fnon-call-exceptions
>> (which we know the caller is after !opt_for_fn (callee->decl,
>> flag_non_call_exceptions)
>>
>> So - this doesn't look correct to me.
>>
>> OTOH
>>
>> static inline int foo (int a, int *b)
>> {
>>   return a / *b;
>> }
>>
>> int __attribute__((optimize("non-call-exceptions")))
>> bar (int *p, int *b)
>> {
>>   try
>>     {
>>       return foo (*p, b);
>>     }
>>   catch (...)
>>     {
>>       return 0;
>>     }
>> }
>>
>> happily inlines foo with your patch but doesn't ICE during stmt verification.
>>
>> So maybe we're not verifying that "correctness" part - ah, yeah, I think
>> we changed it to only verify EH tree vs. stmt consistency but not the
>> other way around.
>
> Well, it is a while since I looked deeper into EH code, but if I remember
> correctly we have EH region associated with statements and the non-call
> exceptions do not have EH region that is taken by EH code as an information
> that the statement was proved to not throw? In that case inlining could be
> safe, if the inlined statements are not placed in EH region (I think inliner
> does that)
>
> So perhaps this inlining is always safe?

That's what I think.

Richard.

> Honza

  reply	other threads:[~2016-01-21 14:14 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-20  8:32 Eric Botcazou
2016-01-20 11:34 ` Richard Biener
2016-01-21 14:13   ` Jan Hubicka
2016-01-21 14:14     ` Richard Biener [this message]
2016-01-21 14:20       ` Jan Hubicka
2016-01-22 11:06         ` Eric Botcazou
2016-01-22 11:30           ` Richard Biener
2016-01-22 10:53     ` Eric Botcazou
2016-01-22 12:00       ` Jan Hubicka
2016-01-22 12:06         ` Eric Botcazou
2016-01-22 12:12           ` Arnaud Charlet
2016-01-22 12:40             ` Eric Botcazou
2016-01-22 18:22               ` Jan Hubicka
2016-01-23  9:25                 ` Eric Botcazou
2016-01-23  9:51                   ` Arnaud Charlet
2016-01-23 12:34                   ` Duncan Sands
2016-01-22 12:33         ` Richard Biener

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFiYyc25MQZoZYEbRRNGRiaHn1o1=2zWYmr=UHm4111fqrnaeQ@mail.gmail.com' \
    --to=richard.guenther@gmail.com \
    --cc=ebotcazou@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).