From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id 9450C385842D; Fri, 4 Nov 2022 08:30:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9450C385842D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667550643; bh=b2AqpkXNk6Rj4JHs1K0StGe1zSALvu/SeT+txx5WB9I=; h=From:To:Subject:Date:From; b=y3TEZXIgl2O2d4sAGVFaHBtdvqCFcj/lqQaH+8A2rKi2tVN2wrNctV3tdvWRn/14g a/zh2F2YjofMeApzPjvBZN1vx99m1+P4lbM/h+YhanzNj9YaH+tu28NtJTn+fEz1Bz 3XqIsgwJXeWd8OFvKH/vqjlxw5rj1d1oZKk++91U= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-10356] cgraphunit: Don't emit asm thunks for -dx [PR106261] X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/releases/gcc-11 X-Git-Oldrev: 4d853d49202a3b9fdaade64a6d5f920304c2b38d X-Git-Newrev: 904b0d0418077c1fe2c3ab328002bba40c6b0271 Message-Id: <20221104083043.9450C385842D@sourceware.org> Date: Fri, 4 Nov 2022 08:30:43 +0000 (GMT) List-Id: https://gcc.gnu.org/g:904b0d0418077c1fe2c3ab328002bba40c6b0271 commit r11-10356-g904b0d0418077c1fe2c3ab328002bba40c6b0271 Author: Jakub Jelinek 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 PR debug/106261 * cgraphunit.c (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.c | 2 +- gcc/testsuite/g++.dg/debug/pr106261.C | 36 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index 0b70e4d4fde..802b01d3b97 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -1749,7 +1749,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 (); }