public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-8644] cgraphunit: Don't emit asm thunks for -dx [PR106261]
Date: Sat, 30 Jul 2022 09:34:45 +0000 (GMT)	[thread overview]
Message-ID: <20220730093445.D0597385703C@sourceware.org> (raw)

https://gcc.gnu.org/g:0062d8491c20eb95411ac0b112e09ec0cee836d1

commit r12-8644-g0062d8491c20eb95411ac0b112e09ec0cee836d1
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Jul 27 12:06:22 2022 +0200

    cgraphunit: Don't emit asm thunks for -dx [PR106261]
    
    When -dx option is used (didn't know we have it and no idea what is it
    useful for), we just expand functions to RTL and then omit all further
    RTL passes, so the normal functions aren't actually emitted into assembly,
    just variables.
    The following testcase ICEs, because we don't emit the methods, but do
    emit thunks pointing to that and those thunks have unwind info and rely on
    at least some real functions to be emitted (which is normally the case,
    thunks are only emitted for locally defined functions) because otherwise
    there are no CIEs, only FDEs and dwarf2out is upset about it.
    
    The following patch fixes that by not emitting assembly thunks for -dx
    either.
    
    2022-07-27  Jakub Jelinek  <jakub@redhat.com>
    
            PR debug/106261
            * cgraphunit.cc (cgraph_node::assemble_thunks_and_aliases): Don't
            output asm thunks for -dx.
    
            * g++.dg/debug/pr106261.C: New test.
    
    (cherry picked from commit f9671b60f9395cb1dca128b92f5dd215f5aeaae1)

Diff:
---
 gcc/cgraphunit.cc                     |  2 +-
 gcc/testsuite/g++.dg/debug/pr106261.C | 36 +++++++++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/gcc/cgraphunit.cc b/gcc/cgraphunit.cc
index bc3dc754481..76d541755b8 100644
--- a/gcc/cgraphunit.cc
+++ b/gcc/cgraphunit.cc
@@ -1754,7 +1754,7 @@ cgraph_node::assemble_thunks_and_aliases (void)
 	cgraph_node *thunk = e->caller;
 
 	e = e->next_caller;
-	expand_thunk (thunk, true, false);
+	expand_thunk (thunk, !rtl_dump_and_exit, false);
 	thunk->assemble_thunks_and_aliases ();
       }
     else
diff --git a/gcc/testsuite/g++.dg/debug/pr106261.C b/gcc/testsuite/g++.dg/debug/pr106261.C
new file mode 100644
index 00000000000..6dee7e68ff5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/pr106261.C
@@ -0,0 +1,36 @@
+// PR debug/106261
+// { dg-do compile }
+// { dg-options "-dx -fno-dwarf2-cfi-asm" }
+
+struct A
+{
+  virtual void foo ();
+  int a;
+};
+class C : virtual public A
+{
+};
+struct B
+{
+  A *b;
+
+  B (A *x) : b (x) { b->foo (); }
+};
+struct E
+{
+  virtual ~E ();
+};
+class D : public C, E
+{
+};
+struct F : D
+{
+  F (int);
+
+  static void bar ()
+  {
+    F a (0);
+    B b (&a);
+  }
+};
+void baz () { F::bar (); }


                 reply	other threads:[~2022-07-30  9:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20220730093445.D0597385703C@sourceware.org \
    --to=jakub@gcc.gnu.org \
    --cc=gcc-cvs@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: 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).