From patchwork Sun Jun 23 13:53:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 1120802 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-503528-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="XoNdjqWn"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45Wv6K2Bqcz9s3l for ; Sun, 23 Jun 2019 23:54:00 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=default; b=okdXcedYbg6WysK47LxSEw2x/LFPo mV87Rn08dErh2/faX9b6+f8fMpjYpmYwdUpeoOqrH+rAnTVb+/uyIGb9jLnclUve RQQJJ+WSR0P2Jlw6ixxEnuSTo2qLvmstdyqfDoxMeptxkGZ06NOBAKTL9mLmSDls 3iNXM7H0m1BKm4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:references:date:in-reply-to:message-id:mime-version :content-type; s=default; bh=Lohhan560vMHIsMs2eYWNydsa5c=; b=XoN djqWnxvyDBFjyLX/b47n2hep/2yw6cdzNaoohfiIup7mrSBddJQ8Q0+7qJYU2SZH JKELKrBKNQo9tAdkxqbTyyNz+Fdjik95r4jD81xfpnmdsMvvkN65mO7XRbCeBwVJ VobXkzRzEHFlakB5Na6nOV6I8yM7rvaMDf576jvE= Received: (qmail 93500 invoked by alias); 23 Jun 2019 13:53:54 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 93492 invoked by uid 89); 23 Jun 2019 13:53:53 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, SPF_PASS autolearn=ham version=3.3.1 spammy=slim, gol, consideration, HX-Languages-Length:5758 X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.110.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 23 Jun 2019 13:53:52 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id ADAD1C0A for ; Sun, 23 Jun 2019 06:53:50 -0700 (PDT) Received: from localhost (e121540-lin.manchester.arm.com [10.32.98.39]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 55A753F71E for ; Sun, 23 Jun 2019 06:53:50 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [PATCH 3/3] RFC: Add -O1g References: Date: Sun, 23 Jun 2019 14:53:49 +0100 In-Reply-To: (Richard Sandiford's message of "Sun, 23 Jun 2019 14:51:06 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 This patch adds an option called -O1g, a half-way house between -Og and -O1 in terms of both performance and debuggability. 2019-06-23 Richard Sandiford config/ * bootstrap-O1g.mk: New file. gcc/ * common.opt (O1g): New option. * doc/invoke.texi: Document it. * opts.c (default_options_optimization): Handle it. (common_handle_option): Likewise. gcc/testsuite/ * g++.dg/guality/guality.exp: Add "-O1g -g" to the list of options to try for Og-* tests. * gcc.dg/guality/guality.exp: Likewise. * gcc.dg/sso/sso.exp (SSO_TORTURE_OPTIONS): Add "-O1g -g". * gnat.dg/sso/sso.exp (SSO_TORTURE_OPTIONS): Likewise. * lib/c-torture.exp (TORTURE_OPTIONS): Likewise. Index: config/bootstrap-O1g.mk =================================================================== --- /dev/null 2019-06-14 15:59:19.298479944 +0100 +++ config/bootstrap-O1g.mk 2019-06-23 14:48:59.302941670 +0100 @@ -0,0 +1,1 @@ +BOOT_CFLAGS := -O1g $(filter-out -O%, $(BOOT_CFLAGS)) Index: gcc/common.opt =================================================================== --- gcc/common.opt 2019-06-23 14:48:44.495065059 +0100 +++ gcc/common.opt 2019-06-23 14:48:59.302941670 +0100 @@ -487,6 +487,9 @@ Og Common Optimization Optimize for debugging experience rather than speed or size. +O1g +Common Optimization + Q Driver Index: gcc/doc/invoke.texi =================================================================== --- gcc/doc/invoke.texi 2019-06-18 09:35:52.089892867 +0100 +++ gcc/doc/invoke.texi 2019-06-23 14:48:59.314941570 +0100 @@ -8403,6 +8403,19 @@ optimization flags except for those that -fmove-loop-invariants -fssa-phiopt @gol -ftree-bit-ccp -ftree-pta -ftree-sra} +@item -O1g +@opindex O1g +Perform the same optimizations as @option{-O1}, but take the debug +experience into consideration when optimizing. In particular, try to +make sure that the values of simple variables are printable at any +point during their scope. + +This option is a compromise between @option{-Og} and @option{-O1}. +The code it produces is generally faster than the code that +@option{-Og} produces, but not as fast as the code that @option{-O1} +produces. In contrast, the code that @option{-O1g} produces should be +easier to debug than code that @option{-O1} produces, but might not be +as easy to debug as the code that @option{-Og} produces. @end table If you use multiple @option{-O} options, with or without level numbers, Index: gcc/opts.c =================================================================== --- gcc/opts.c 2019-06-23 14:48:44.507064959 +0100 +++ gcc/opts.c 2019-06-23 14:48:59.314941570 +0100 @@ -639,6 +639,14 @@ default_options_optimization (struct gcc opts->x_flag_tangible_debug = 1; break; + case OPT_O1g: + opts->x_optimize_size = 0; + opts->x_optimize = 1; + opts->x_optimize_fast = 0; + opts->x_optimize_debug = 0; + opts->x_flag_tangible_debug = 1; + break; + case OPT_fopenacc: if (opt->value) openacc_mode = true; @@ -2323,6 +2331,7 @@ common_handle_option (struct gcc_options case OPT_Os: case OPT_Ofast: case OPT_Og: + case OPT_O1g: /* Currently handled in a prescan. */ break; Index: gcc/testsuite/g++.dg/guality/guality.exp =================================================================== --- gcc/testsuite/g++.dg/guality/guality.exp 2019-06-23 14:48:44.511064925 +0100 +++ gcc/testsuite/g++.dg/guality/guality.exp 2019-06-23 14:48:59.314941570 +0100 @@ -78,9 +78,9 @@ if {[check_guality " gcc-dg-runtest [lsort [glob $srcdir/$subdir/*.C]] "" "" gcc-dg-runtest $general "" "" set-torture-options \ - [list "-O0" "-Og"] \ + [list "-O0" "-Og" "-O1g"] \ [list {}] \ - [list "-Og -flto"] + [list "-Og -flto" "-O1g -flto"] gcc-dg-runtest $Og "" "" } Index: gcc/testsuite/gcc.dg/guality/guality.exp =================================================================== --- gcc/testsuite/gcc.dg/guality/guality.exp 2019-06-23 14:48:44.511064925 +0100 +++ gcc/testsuite/gcc.dg/guality/guality.exp 2019-06-23 14:48:59.314941570 +0100 @@ -93,9 +93,9 @@ if {[check_guality " gcc-dg-runtest [lsort [glob $srcdir/$subdir/*.c]] "" "" gcc-dg-runtest $general "" "-Wc++-compat" set-torture-options \ - [list "-O0" "-Og"] \ + [list "-O0" "-Og" "-O1g"] \ [list {}] \ - [list "-Og -flto"] + [list "-Og -flto" "-O1g -flto"] gcc-dg-runtest $Og "" "-Wc++-compat" } Index: gcc/testsuite/gcc.dg/sso/sso.exp =================================================================== --- gcc/testsuite/gcc.dg/sso/sso.exp 2019-03-08 18:15:04.412863081 +0000 +++ gcc/testsuite/gcc.dg/sso/sso.exp 2019-06-23 14:48:59.314941570 +0100 @@ -32,7 +32,8 @@ set SSO_TORTURE_OPTIONS [list \ { -O2 } \ { -O3 -finline-functions } \ { -Os } \ - { -Og -g } ] + { -Og -g } \ + { -O1g -g } ] set-torture-options $SSO_TORTURE_OPTIONS Index: gcc/testsuite/gnat.dg/sso/sso.exp =================================================================== --- gcc/testsuite/gnat.dg/sso/sso.exp 2019-03-08 18:14:54.692900030 +0000 +++ gcc/testsuite/gnat.dg/sso/sso.exp 2019-06-23 14:48:59.314941570 +0100 @@ -28,7 +28,8 @@ set SSO_TORTURE_OPTIONS [list \ { -O2 } \ { -O3 -finline-functions } \ { -Os } \ - { -Og -g } ] + { -Og -g } \ + { -O1g -g } ] set-torture-options $SSO_TORTURE_OPTIONS Index: gcc/testsuite/lib/c-torture.exp =================================================================== --- gcc/testsuite/lib/c-torture.exp 2019-03-08 18:14:42.504946361 +0000 +++ gcc/testsuite/lib/c-torture.exp 2019-06-23 14:48:59.314941570 +0100 @@ -56,7 +56,8 @@ if [info exists TORTURE_OPTIONS] { { -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions } \ { -O3 -g } \ { -Os } \ - { -Og -g } ] + { -Og -g } \ + { -O1g -g } ] if [check_effective_target_lto] { # When having plugin test both slim and fat LTO and plugin/nonplugin