From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 88D0E3944416; Tue, 17 Mar 2020 12:16:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 88D0E3944416 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1584447389; bh=DOf5/+xL2GcZdId8k6QVOmVRe2hYpTmNMbwRTMxmWH8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=r1gag6p67WofDyo4penWDMZ1Xxv7ATEOAhlEhp8ZNJ/Hi3D4jZNZhQrfneF+0R1cC 0+HBt+Sx5zbGcwcO6Mhrhnpun1ukb0LuHiUughkXEE51g5owXGC+CYpcwpZSZtPvMc cW9hhHVsr/aEi9JBrulafiOzq5G4regj3nCw1JZ4= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/51663] Desirable/undesirable elimination of unused variables & functions at -O0, -O0 -flto and -O0 -fwhole-program Date: Tue, 17 Mar 2020 12:16:29 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 4.7.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: hubicka at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Mar 2020 12:16:29 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D51663 --- Comment #14 from Richard Biener --- (In reply to Tom de Vries from comment #13) > (In reply to Richard Biener from comment #12) > > (In reply to Tom de Vries from comment #11) > > > Cross-referencing PR gdb/25684 - "gdb testing with gcc -flto" ( > > > https://sourceware.org/bugzilla/show_bug.cgi?id=3D25684 ). > > >=20 > > > Ideally there would be a way to enable the lto infrastructure without > > > actually optimizing, such that when running the gdb testsuite with and > > > without flto and comparing results, any regression would indicate som= ething > > > that needs fixing. > > >=20 > > > In the current situation, each individual regression needs investigat= ion > > > whether something needs fixing or whether the failure is just an > > > optimization artifact. And due to the fact there are optimizations, t= here > > > are thousands of such regressions. > >=20 > > I suppose we're talking about -O0 -flto here. >=20 > Right, and ideally -flto plain, with -O0 implicit. >=20 > > What kind of transforms > > are undesirable? I think at -O0 you'll get > >=20 > > - more aggressive unused variable/function removal > > - promotion of variables from global to local > >=20 >=20 > Right, is there a way to switch these off? Not at the moment I think. The main unused variable/function removal is in cgraphunit.c:analyze_functions. I guess the simplest thing would be to try diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index a9dd288be57..3aa8137efad 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -1158,7 +1158,7 @@ analyze_functions (bool first_time) { /* Convert COMDAT group designators to IDENTIFIER_NODEs. */ node->get_comdat_group_id (); - if (node->needed_p ()) + if (!optimize || node->needed_p ()) { enqueue_node (node); if (!changed && symtab->dump_file) but I'm not sure this is enough since we remove not refered to things at several points during the compilation (including during partitioning I think). Another possibility would be to make all nodes force_output when not optimizing like with diff --git a/gcc/cgraph.h b/gcc/cgraph.h index aa4cdc95506..b07bf9745d0 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -115,7 +115,7 @@ public: transparent_alias (false), weakref (false), cpp_implicit_alias (fals= e), symver (false), analyzed (false), writeonly (false), refuse_visibility_changes (false), externally_visible (false), - no_reorder (false), force_output (false), forced_by_abi (false), + no_reorder (false), force_output (optimize), forced_by_abi (false), unique_name (false), implicit_section (false), body_removed (false), used_from_other_partition (false), in_other_partition (false), address_taken (false), in_init_priority_hash (false), or in a more suitable place. That should eventually also avoid promotion to local. > > some of the transforms are unavoidable due to partitioning(?) but we co= uld > > default to 1:1 partitioning at -O0 ... >=20 > At this point I'm not interested in defaults yet. I can achieve 1:1 > partition by testing target board unix/-flto/-flto-partition=3D1to1. >=20 > For now I'm interested in a combination of flags that exercises the speci= fic > type of debug info generation as is done for lto, without actually doing = any > optimizations. >=20 > F.i., an open question for me is the following: I'm now using > -flto-partition=3Dnone for testing, but maybe 1to1 should yield better re= sults?=