From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp001-out.apm-internet.net (smtp001-out.apm-internet.net [85.119.248.222]) by sourceware.org (Postfix) with ESMTPS id A68023858D39 for ; Thu, 2 Dec 2021 09:54:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A68023858D39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sandoe.co.uk Authentication-Results: sourceware.org; spf=none smtp.mailfrom=sandoe.co.uk Received: (qmail 75559 invoked from network); 2 Dec 2021 09:54:19 -0000 X-APM-Out-ID: 16384388587555 X-APM-Authkey: 257869/1(257869/1) 2 Received: from unknown (HELO ?192.168.1.214?) (81.138.1.83) by smtp001.apm-internet.net with SMTP; 2 Dec 2021 09:54:19 -0000 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.21\)) Subject: [ping][PATCH] DWARF: Match behaviour of .cfi_xxx when doing manual frame output. From: Iain Sandoe In-Reply-To: <20211117171718.59536-1-iain@sandoe.co.uk> Date: Thu, 2 Dec 2021 09:54:18 +0000 Cc: Jakub Jelinek Content-Transfer-Encoding: quoted-printable Message-Id: References: <20211117171718.59536-1-iain@sandoe.co.uk> To: GCC Patches X-Mailer: Apple Mail (2.3445.104.21) X-Spam-Status: No, score=-14.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_COUK, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Dec 2021 09:54:22 -0000 Hi, I=E2=80=99d like to ping this patch at least for opinion on whether the = approach is reasonable (as noted below it could be put behind a target hook if = necessary) thanks Iain > On 17 Nov 2021, at 17:17, Iain Sandoe via Gcc-patches = wrote: >=20 > At present, for several reasons, it is not possible to switch > Darwin to use .cfi instructions for frame output. >=20 > When GCC uses .cfi_ instructions, the behaviour w.r.t frame > sections (for a target with unwind frames by defaults): >=20 > (no options ) .eh_frame > (-g ) .eh_frame > (-g -fno-unwind-tables -fno-asynchronous-unwind-tables) .debug_frame > ( -fno-unwind-tables -fno-asynchronous-unwind-tables) --- >=20 > However, for a target which outputs the FDEs "manually" (using > output_call_frame_info()) we have: >=20 > (no options ) __eh_frame > (-g ) __eh_frame *and* __debug_frame > (-g -fno-unwind-tables -fno-asynchronous-unwind-tables) __debug_frame > ( -fno-unwind-tables -fno-asynchronous-unwind-tables) --- >=20 > The first two cases are, of course, the most common and the extra > frame table is (a) a waste of space and (b) actually triggers a bug > when used with the LLVM assembler [with assertions enabled] for > Mach-O when we have hot/cold partitioning on, since that emits > Letext{.cold}0 labels *after* the __DWARF,__debug_frame and the > assembler is set up reject switches to non-debug sections after the > first __DWARF debug one has been seen. >=20 > The following patch makes the manual output of frame data follow the > same pattern as the .cfi instructions. >=20 > (a) =46rom testing on Darwin which uses the 'manual frame output' I = see > around 200Mb saving on gcc/ for master (5%). > (b) Since Darwin defaults to unwind frames for all languages, we see > only eh_frame sections before the "real debug" is emitted, so that > the LLVM constraint is avoided. >=20 > On testing on x86_64 and powerpc64le Linux, I see only a single test > that would need amendment (it counts the number of references to the > start/end local labels). >=20 > Since the majority of targets are using .cfi instructions, it is hard > to get wider testing. >=20 > It would be possible, of course, to wrap the change in a target hook > but it's not clear that we need to. >=20 > Is there some case that I've missed? > or - OK for master (the testcase amendments are not attached here) > but are simple. >=20 > thanks, > Iain >=20 > Signed-off-by: Iain Sandoe >=20 > gcc/ChangeLog: >=20 > * dwarf2out.c (output_call_frame_info): Output the FDEs when > either EH or debug support is needed. > (dwarf2out_frame_finish): When either EH or debug support is > needed, call output_call_frame_info(). > --- > gcc/dwarf2out.c | 15 ++++++--------- > 1 file changed, 6 insertions(+), 9 deletions(-) >=20 > diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c > index e1d6a79ecd7..96307d6747a 100644 > --- a/gcc/dwarf2out.c > +++ b/gcc/dwarf2out.c > @@ -283,7 +283,7 @@ static GTY(()) dw_die_ref decltype_auto_die; >=20 > /* Forward declarations for functions defined in this file. */ >=20 > -static void output_call_frame_info (int); > +static void output_call_frame_info (bool, bool); >=20 > /* Personality decl of current unit. Used only when assembler does = not support > personality CFI. */ > @@ -750,7 +750,7 @@ fde_needed_for_eh_p (dw_fde_ref fde) > location of saved registers. */ >=20 > static void > -output_call_frame_info (int for_eh) > +output_call_frame_info (bool for_eh, bool for_debug) > { > unsigned int i; > dw_fde_ref fde; > @@ -795,7 +795,7 @@ output_call_frame_info (int for_eh) > targetm.asm_out.emit_unwind_label (asm_out_file, fde->decl, = 1, 1); > } >=20 > - if (!any_eh_needed) > + if (!any_eh_needed && !for_debug) > return; > } >=20 > @@ -1271,12 +1271,9 @@ void > dwarf2out_frame_finish (void) > { > /* Output call frame information. */ > - if (targetm.debug_unwind_info () =3D=3D UI_DWARF2) > - output_call_frame_info (0); > - > - /* Output another copy for the unwinder. */ > - if (do_eh_frame) > - output_call_frame_info (1); > + if (targetm.debug_unwind_info () =3D=3D UI_DWARF2 || do_eh_frame) > + output_call_frame_info (do_eh_frame, > + targetm.debug_unwind_info () =3D=3D = UI_DWARF2); > } >=20 > static void var_location_switch_text_section (void); > --=20 > 2.24.3 (Apple Git-128) >=20