public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-8312] cgraph: Don't verify semantic_interposition flag for aliases [PR105399]
@ 2022-04-28 13:46 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2022-04-28 13:46 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:b85e79dce149df68b92ef63ca2a40ff1dfa61396

commit r12-8312-gb85e79dce149df68b92ef63ca2a40ff1dfa61396
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Apr 28 15:45:33 2022 +0200

    cgraph: Don't verify semantic_interposition flag for aliases [PR105399]
    
    The following testcase ICEs, because the ctors during cc1plus all have
    !opt_for_fn (decl, flag_semantic_interposition) - they have NULL
    DECL_FUNCTION_SPECIFIC_OPTIMIZATION (decl) and optimization_default_node
    is for -Ofast and so has flag_semantic_interposition cleared.
    During free lang data, we set DECL_FUNCTION_SPECIFIC_OPTIMIZATION (decl)
    for the ctor which has body (or for thunks), but don't touch it for
    aliases.
    During lto1 optimization_default_node reflects the lto1 flags which
    are -O2 rather than -Ofast and so has flag_semantic_interposition
    set, for the ctor which has body that makes no difference, but as the
    alias doesn't still have DECL_FUNCTION_SPECIFIC_OPTIMIZATION (decl) set,
    we now trigger this verification check.
    
    The following patch just doesn't verify it for aliases during lto1.
    Another possibility would be to set DECL_FUNCTION_SPECIFIC_OPTIMIZATION (decl)
    during free lang data even for aliases.
    
    2022-04-28  Jakub Jelinek  <jakub@redhat.com>
    
            PR lto/105399
            * cgraph.cc (cgraph_node::verify_node): Don't verify
            semantic_interposition flag against
            opt_for_fn (decl, flag_semantic_interposition) for aliases in lto1.
    
            * g++.dg/lto/pr105399_0.C: New test.

Diff:
---
 gcc/cgraph.cc                         | 6 +++++-
 gcc/testsuite/g++.dg/lto/pr105399_0.C | 9 +++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/gcc/cgraph.cc b/gcc/cgraph.cc
index d3cc06bbaed..0159eaa768b 100644
--- a/gcc/cgraph.cc
+++ b/gcc/cgraph.cc
@@ -3488,7 +3488,11 @@ cgraph_node::verify_node (void)
 	     "returns a pointer");
       error_found = true;
     }
-  if (definition && externally_visible
+  if (definition
+      && externally_visible
+      /* For aliases in lto1 free_lang_data doesn't guarantee preservation
+	 of opt_for_fn (decl, flag_semantic_interposition).  See PR105399.  */
+      && (!alias || !in_lto_p)
       && semantic_interposition
 	 != opt_for_fn (decl, flag_semantic_interposition))
     {
diff --git a/gcc/testsuite/g++.dg/lto/pr105399_0.C b/gcc/testsuite/g++.dg/lto/pr105399_0.C
new file mode 100644
index 00000000000..fc9149a7aa2
--- /dev/null
+++ b/gcc/testsuite/g++.dg/lto/pr105399_0.C
@@ -0,0 +1,9 @@
+// PR lto/105399
+// { dg-lto-do link }
+// { dg-lto-options { { -fPIC -flto -Ofast } } }
+// { dg-require-effective-target shared }
+// { dg-require-effective-target fpic }
+// { dg-extra-ld-options "-shared -O2" }
+
+struct S { S (); };
+S::S () {}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-04-28 13:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-28 13:46 [gcc r12-8312] cgraph: Don't verify semantic_interposition flag for aliases [PR105399] Jakub Jelinek

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).