From patchwork Thu Oct 26 17:12:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 830816 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-465248-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="YuqgcXLf"; 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 3yND946p75z9rxm for ; Fri, 27 Oct 2017 04:12:55 +1100 (AEDT) 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:cc:subject:date:message-id:content-type :content-transfer-encoding:mime-version; q=dns; s=default; b=s0X cBybnljEa32QN1eeNOe2aLIhVg6ekXaqRrwpYokLUr9O0IM0BAff3p5kF/Yi++Im VwEwYrn+E1LAejthn06WNtpxcLm3hHRs+O5ZMVnKZHcGFJRkjDUhrOK+T2LKnqeB xCy1meGKWw8kbUQODHu10VTGt1gxT4Lr2xDSpTug= 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:cc:subject:date:message-id:content-type :content-transfer-encoding:mime-version; s=default; bh=lpUBynH6Y iag4BC8q74LgQf/n9o=; b=YuqgcXLfmuFX+VrXbeN2vo5vOAUUS294GCe9rrRpP ce+JipQbkpbQZgM0kQhQ6+lYBu0VlYndfBPpX99yD0zGlcL8BUrBe3+zoUADmLA8 6e/FhyAol1vPEDxiFQVYq4INnlNPFryN9im5AEdLSbNZJDk4WfYzpPs78Brj38KI n0= Received: (qmail 114223 invoked by alias); 26 Oct 2017 17:12:47 -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 113606 invoked by uid 89); 26 Oct 2017 17:12:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=inspection, inefficient X-HELO: EUR01-VE1-obe.outbound.protection.outlook.com Received: from mail-ve1eur01on0041.outbound.protection.outlook.com (HELO EUR01-VE1-obe.outbound.protection.outlook.com) (104.47.1.41) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 26 Oct 2017 17:12:44 +0000 Received: from DB6PR0801MB2053.eurprd08.prod.outlook.com (10.168.86.22) by DB6PR0801MB2054.eurprd08.prod.outlook.com (10.168.86.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.156.4; Thu, 26 Oct 2017 17:12:41 +0000 Received: from DB6PR0801MB2053.eurprd08.prod.outlook.com ([fe80::d9d5:2017:ca12:1d9d]) by DB6PR0801MB2053.eurprd08.prod.outlook.com ([fe80::d9d5:2017:ca12:1d9d%18]) with mapi id 15.20.0156.007; Thu, 26 Oct 2017 17:12:41 +0000 From: Wilco Dijkstra To: GCC Patches CC: nd Subject: [PATCH] Change default optimization level to -Og Date: Thu, 26 Oct 2017 17:12:40 +0000 Message-ID: x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB6PR0801MB2054; 6:k/SszZfZTxaBWTxGYsGkuMtmTbHeMvoGQEJBZclu7gUb7BfCZycoApkbK8doZhqpnQkYg2MWWVg5GDvIYtUPC8td2JpKm1diZScgbG537wnTJd/ElZP9TgVOoyG48TC+nuDnNGWG5q5/jWCXFdM6Qffy+/xgrYHLdqm5+/+G3r08btK96FkvdUrJHv5PN0x2OhQqYqTDooitgOhKEOZTLnvln70UWxIZBkNGMfdbftvEmDzZbw3dZrckthbNwvjm2nHI6JDjtsTPSG/YmZnnlXymo8A5q0rr5Yl7xTGFpdA1y6pNI0b+Ajv4X9zioH9OAY6jVoxunaHche2GaXYc/Q==; 5:iJjutdEUae9/0IdxLD4VGtL70oDrMe7CDOKjZXqHyrt6C5CPykxpcdcOzHljkOJshUG1UTQyIc1c9alr+quOsQsN5a5VmVIMtUZEGCXW6jkSn+KHbJn+3Qt2qQ6C80HRT3Ql2mN+Ggam7Xg3cIofNA==; 24:AS3hfO1PP47rtzGAmsIL7smvHyPmleKOrmjneBBEL6oupimDUZKJy0/xSbCwTxSJfih1fv64UDIc8TgTqVdgzLT7/q8DzZ42VWSBIgHMU/0=; 7:pCOBNvfadt6mkBMw25bOqN4msHhEgQRnTINitQqVNMt0qE+VA12ctpHhLEDZuL2fbMZAd2WnfAtGdAaad18Cy8CbKZE95Dq1riirQv/jf1WZ6qd+D8rFMxinxjKwMOR5YEWYtetOU3ereMpUQhaWRuxt3S0BpqhGl46qyE+dwFtaZtNnO7myVBjoLu6jj5z/yh6hAdjOe3qCYaA84GHdv6D+kg2KQElx+hJbt0HS3GA= x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: 961555ae-0be1-46af-ccc3-08d51c94c3eb x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(4534020)(4602075)(4627075)(201703031133081)(201702281549075)(2017052603238); SRVR:DB6PR0801MB2054; x-ms-traffictypediagnostic: DB6PR0801MB2054: nodisclaimer: True x-exchange-antispam-report-test: UriScan:(180628864354917); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(3231020)(10201501046)(3002001)(93006095)(93001095)(100000703101)(100105400095)(6055026)(6041248)(20161123560025)(20161123555025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123564025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DB6PR0801MB2054; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DB6PR0801MB2054; x-forefront-prvs: 04724A515E x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(39860400002)(346002)(376002)(377424004)(199003)(189002)(99286003)(4326008)(478600001)(55016002)(4001150100001)(6506006)(53936002)(2906002)(8936002)(81156014)(14454004)(8676002)(68736007)(72206003)(54356999)(50986999)(5250100002)(97736004)(6436002)(33656002)(316002)(101416001)(3846002)(6116002)(102836003)(7736002)(81166006)(189998001)(25786009)(305945005)(2900100001)(5660300001)(7696004)(66066001)(6916009)(9686003)(105586002)(106356001)(3660700001)(74316002)(3280700002)(86362001); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR0801MB2054; H:DB6PR0801MB2053.eurprd08.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Wilco.Dijkstra@arm.com; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: 961555ae-0be1-46af-ccc3-08d51c94c3eb X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Oct 2017 17:12:40.9447 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB2054 GCC's default optimization level is -O0. Unfortunately unlike other compilers, GCC generates extremely inefficient code with -O0. It is almost unusable for low-level debugging or manual inspection of generated code. So a -O option is always required for compilation. -Og not only allows for fast compilation, but also produces code that is efficient, readable as well as debuggable. Therefore -Og makes for a much better default setting. Any comments? 2017-10-26 Wilco Dijkstra * opts.c (default_options_optimization): Set default to -Og. doc/ * invoke.texi (-O0) Remove default mention. (-Og): Add mention of default setting. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 3328a3b5fafa6a98007eff52d2a26af520de9128..74c33ea35b9f320b419a3417e6007d2391536f1b 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -7343,7 +7343,7 @@ by @option{-O2} and also turns on the following optimization flags: @item -O0 @opindex O0 Reduce compilation time and make debugging produce the expected -results. This is the default. +results. @item -Os @opindex Os @@ -7371,7 +7371,7 @@ Optimize debugging experience. @option{-Og} enables optimizations that do not interfere with debugging. It should be the optimization level of choice for the standard edit-compile-debug cycle, offering a reasonable level of optimization while maintaining fast compilation -and a good debugging experience. +and a good debugging experience. This is the default. @end table If you use multiple @option{-O} options, with or without level numbers, diff --git a/gcc/opts.c b/gcc/opts.c index dfad955e220870a3250198640f3790c804b191e0..74511215309f11445685db4894be2ab6881695d3 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -565,6 +565,12 @@ default_options_optimization (struct gcc_options *opts, int opt2; bool openacc_mode = false; + /* Set the default optimization to -Og. */ + opts->x_optimize_size = 0; + opts->x_optimize = 1; + opts->x_optimize_fast = 0; + opts->x_optimize_debug = 1; + /* Scan to see what optimization level has been specified. That will determine the default value of many flags. */ for (i = 1; i < decoded_options_count; i++)