public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "rguenther at suse dot de" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug ipa/110334] [13/14 Regresssion] unused functions not eliminated before LTO streaming Date: Tue, 27 Jun 2023 06:41:34 +0000 [thread overview] Message-ID: <bug-110334-4-QQWDY8FJAR@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-110334-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110334 --- Comment #12 from rguenther at suse dot de <rguenther at suse dot de> --- On Mon, 26 Jun 2023, hubicka at ucw dot cz wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110334 > > --- Comment #11 from Jan Hubicka <hubicka at ucw dot cz> --- > Hi, > what about this. It should make at least quite basic inlining to happen > to always_inline. I do not think many critical always_inlines have > indirect calls in them. The test for lto is quite bad and I can > work on solving this incrementally (it would be nice to have this > tested and possibly backport it). > > diff --git a/gcc/ipa-inline.cc b/gcc/ipa-inline.cc > index efc8df7d4e0..dcec07e49e1 100644 > --- a/gcc/ipa-inline.cc > +++ b/gcc/ipa-inline.cc > @@ -702,6 +702,38 @@ can_early_inline_edge_p (struct cgraph_edge *e) > if (!can_inline_edge_p (e, true, true) > || !can_inline_edge_by_limits_p (e, true, false, true)) > return false; > + /* When inlining regular functions into always-inline functions > + during early inlining watch for possible inline cycles. */ > + if (DECL_DISREGARD_INLINE_LIMITS (caller->decl) > + && lookup_attribute ("always_inline", DECL_ATTRIBUTES (caller->decl)) > + && (!DECL_DISREGARD_INLINE_LIMITS (callee->decl) > + || !lookup_attribute ("always_inline", DECL_ATTRIBUTES > (callee->decl)))) > + { > + /* If there are indirect calls, inlining may produce direct call. > + TODO: We may lift this restriction if we avoid errors on formely > + indirect calls to always_inline functions. Taking address > + of always_inline function is generally bad idea and should > + have been declared as undefined, but sadly we allow this. */ > + if (caller->indirect_calls || e->callee->indirect_calls) why disallow caller->indirect_calls? > + return false; > + for (cgraph_edge *e2 = callee->callees; e2; e2 = e2->next_callee) I don't think this flys - it looks quadratic. Can we compute this in the inline summary once instead? As for indirect calls, can we maybe mark initial direct GIMPLE call stmts as "always-inline" and only look at that marking, thus an indirect call will never become "always-inline"? Iff cgraph edges prevail during all early inlining we could mark call edges for this purpose? > + { > + struct cgraph_node *callee2 = e2->callee->ultimate_alias_target (); > + /* As early inliner runs in RPO order, we will see uninlined > + always_inline calls only in the case of cyclic graphs. */ > + if (DECL_DISREGARD_INLINE_LIMITS (callee2->decl) > + || lookup_attribute ("always_inline", callee2->decl)) > + return false; > + /* With LTO watch for case where function is later replaced > + by always_inline definition. > + TODO: We may either stop treating noninlined cross-module always > + inlines as errors, or we can extend decl merging to produce > + syntacic alias and honor always inline only in units it has > + been declared as such. */ > + if (flag_lto && callee2->externally_visible) > + return false; > + } > + } > return true; > } > > @@ -3034,18 +3066,7 @@ early_inliner (function *fun) > > if (!optimize > || flag_no_inline > - || !flag_early_inlining > - /* Never inline regular functions into always-inline functions > - during incremental inlining. This sucks as functions calling > - always inline functions will get less optimized, but at the > - same time inlining of functions calling always inline > - function into an always inline function might introduce > - cycles of edges to be always inlined in the callgraph. > - > - We might want to be smarter and just avoid this type of inlining. */ > - || (DECL_DISREGARD_INLINE_LIMITS (node->decl) > - && lookup_attribute ("always_inline", > - DECL_ATTRIBUTES (node->decl)))) > + || !flag_early_inlining) > ; > else if (lookup_attribute ("flatten", > DECL_ATTRIBUTES (node->decl)) != NULL) > >
next prev parent reply other threads:[~2023-06-27 6:41 UTC|newest] Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-06-21 7:05 [Bug ipa/110334] New: " rguenth at gcc dot gnu.org 2023-06-21 7:06 ` [Bug ipa/110334] " rguenth at gcc dot gnu.org 2023-06-21 7:08 ` rguenth at gcc dot gnu.org 2023-06-21 7:12 ` rguenth at gcc dot gnu.org 2023-06-22 11:15 ` rguenth at gcc dot gnu.org 2023-06-22 11:45 ` rguenth at gcc dot gnu.org 2023-06-22 12:02 ` rguenth at gcc dot gnu.org 2023-06-23 10:47 ` hubicka at gcc dot gnu.org 2023-06-23 11:21 ` rguenth at gcc dot gnu.org 2023-06-23 12:59 ` hubicka at ucw dot cz 2023-06-23 13:07 ` Jan Hubicka 2023-06-23 13:07 ` hubicka at ucw dot cz 2023-06-26 6:39 ` rguenther at suse dot de 2023-06-26 17:50 ` hubicka at ucw dot cz 2023-06-27 6:41 ` rguenther at suse dot de [this message] 2023-06-28 10:00 ` Jan Hubicka 2023-06-28 4:42 ` cvs-commit at gcc dot gnu.org 2023-06-28 10:00 ` hubicka at ucw dot cz 2023-06-28 10:20 ` rguenther at suse dot de 2023-06-28 10:45 ` hubicka at ucw dot cz 2023-06-28 21:06 ` cvs-commit at gcc dot gnu.org 2023-07-03 7:05 ` jakub at gcc dot gnu.org 2023-07-10 7:40 ` rguenth at gcc dot gnu.org 2023-07-10 8:24 ` rguenth at gcc dot gnu.org 2023-07-10 8:24 ` rguenth at gcc dot gnu.org 2023-07-11 14:45 ` hubicka at ucw dot cz 2023-07-11 14:46 ` hubicka at ucw dot cz 2023-07-12 7:05 ` rguenther at suse dot de 2023-07-27 9:26 ` rguenth at gcc dot gnu.org 2023-11-25 10:00 ` egallager at gcc dot gnu.org 2023-11-27 7:28 ` rguenth at gcc dot gnu.org 2024-05-21 9:16 ` jakub at gcc dot gnu.org
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=bug-110334-4-QQWDY8FJAR@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /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: linkBe 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).