From patchwork Mon Sep 23 08:32:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 1165884 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-509431-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="QcSy/WKJ"; 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 46cHcr2sMgz9s00 for ; Mon, 23 Sep 2019 18:32:27 +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:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=TDut1Q5+5NvwxxV8 UJkbEFxA8y9kF9K0nB5fpK6D1Nt088PLABOop9FU3KOON1Z0B6FwliamcZVuV0+/ RadxMZ6YWzNVvrfnmX+uPHSL4m+MYD464dmUOXQuFj2y0JoVNA/PtFS2EZlQE+gs scgmgYeGdJA6BIrsy6MX0vSoUeo= 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:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=lxbwokucUzZfA1fye8/OoE +MrQg=; b=QcSy/WKJ7YVytE8apV7Q2xwMfLodGFI+HiNGNlPHHYci1+Y77MUO/s XhP9t8Mv3YmqK0CZLrIpPagErvZUfiL3QNJnvThh25IzG4Tz2rUG2KeGWyZ59b7b wUeglFKkd0t911eBoltcGPhdDjLEJ5boxBQBrhnj1JQDRcmikxv4c= Received: (qmail 9777 invoked by alias); 23 Sep 2019 08:32:11 -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 9743 invoked by uid 89); 23 Sep 2019 08:32:11 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=selected, optimizations X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 23 Sep 2019 08:32:09 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 85B0981392 for ; Mon, 23 Sep 2019 10:32:07 +0200 (CEST) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Mae6PIOQvLGT for ; Mon, 23 Sep 2019 10:32:07 +0200 (CEST) Received: from polaris.localnet (unknown [IPv6:2a01:e35:8a16:3850:1a03:73ff:fe45:373a]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 5B1C581385 for ; Mon, 23 Sep 2019 10:32:07 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Disable selected optimizations done in gigi at -Og Date: Mon, 23 Sep 2019 10:32:05 +0200 Message-ID: <1710019.EuIro4DUz7@polaris> MIME-Version: 1.0 This disables 3 optimizations done in gigi when the -Og switch is passed: the rotation of loops, the NRV optimization (Named Return Value) and the inlining of local finalizers. Tested on x86_64-suse-linux, applied on the mainline. 2019-09-23 Eric Botcazou * gcc-interface/trans.c (Regular_Loop_to_gnu): Do not rotate the loop if -Og is enabled. (build_return_expr): Do not perform NRV if -Og is enabled. (Subprogram_Body_to_gnu): Likewise. (gnat_to_gnu) : Likewise. (Handled_Sequence_Of_Statements_to_gnu): Do not inline finalizers if -Og is enabled. * gcc-interface/utils.c (convert_to_index_type): Return early if -Og is enabled. Index: gcc-interface/trans.c =================================================================== --- gcc-interface/trans.c (revision 276045) +++ gcc-interface/trans.c (working copy) @@ -3653,7 +3653,7 @@ Regular_Loop_to_gnu (Node_Id gnat_node, which works in all cases. */ - if (optimize) + if (optimize && !optimize_debug) { /* We can use the do-while form directly if GNU_FIRST-1 doesn't overflow. */ @@ -4436,6 +4436,7 @@ build_return_expr (tree ret_obj, tree re a candidate for Named Return Value. If so, record it. Otherwise, if this is an expression of some kind, record it elsewhere. */ if (optimize + && !optimize_debug && AGGREGATE_TYPE_P (operation_type) && !TYPE_IS_FAT_POINTER_P (operation_type) && TYPE_MODE (operation_type) == BLKmode @@ -4773,7 +4774,7 @@ Subprogram_Body_to_gnu (Node_Id gnat_nod /* If the function returns an aggregate type and we have candidates for a Named Return Value, finalize the optimization. */ - if (optimize && gnu_subprog_language->named_ret_val) + if (optimize && !optimize_debug && gnu_subprog_language->named_ret_val) { finalize_nrv (gnu_subprog_decl, gnu_subprog_language->named_ret_val, @@ -5893,7 +5894,7 @@ Handled_Sequence_Of_Statements_to_gnu (N /* When not optimizing, disable inlining of finalizers as this can create a more complex CFG in the parent function. */ - if (!optimize) + if (!optimize || optimize_debug) DECL_DECLARED_INLINE_P (proc_decl) = 0; /* If there is no end label attached, we use the location of the At_End @@ -8050,7 +8051,9 @@ gnat_to_gnu (Node_Id gnat_node) /* And find out whether this is a candidate for Named Return Value. If so, record it. */ - if (!TYPE_CI_CO_LIST (gnu_subprog_type) && optimize) + if (optimize + && !optimize_debug + && !TYPE_CI_CO_LIST (gnu_subprog_type)) { tree ret_val = gnu_ret_val; Index: gcc-interface/utils.c =================================================================== --- gcc-interface/utils.c (revision 275988) +++ gcc-interface/utils.c (working copy) @@ -5023,7 +5023,7 @@ convert_to_index_type (tree expr) /* If the type is unsigned, overflow is allowed so we cannot be sure that EXPR doesn't overflow. Keep it simple if optimization is disabled. */ - if (TYPE_UNSIGNED (type) || !optimize) + if (TYPE_UNSIGNED (type) || !optimize || optimize_debug) return convert (sizetype, expr); switch (code)