From patchwork Mon Nov 24 08:32:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 413574 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 84273140129 for ; Mon, 24 Nov 2014 19:34:47 +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:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=dXH/171tlTQG6pbj i2DtetbkMPxumGrQBpJOJHgs9ujRlzHHpfxQiGvWebNNtULsghfSrkoOU1NFolIZ 02f5Jd9Q7Cen55b6IxXJOAkiRBT9rWXnEfwHVQrCdivkmKT4MNZaOsSkDCjlFWfp xO+8mmznDd5EC9cedHHb7bjVdj8= 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=LQPd4SAEODDOWpNAB8HTw6 h0Mo8=; b=YOyDJvWtB6v76bVCPVkm3PjfC1CLRP3pFlvljwAOnI4Zfi8dxHcZsc lBa6n7Gms0KvM5AqmaUexOeSQOz3QkuyzPk80EpXLUxvExOjwFCmkB7mEsS7bR8d b0GxpEufPupSqE0xvzcIvRxmei0HndavvZQn2tfSgtuOIXyoTrUEM= Received: (qmail 8294 invoked by alias); 24 Nov 2014 08:34:40 -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 8243 invoked by uid 89); 24 Nov 2014 08:34:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 24 Nov 2014 08:34:36 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 4767E2B7F0C5 for ; Mon, 24 Nov 2014 09:34:33 +0100 (CET) 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 R5RKtxoVx3kc for ; Mon, 24 Nov 2014 09:34:33 +0100 (CET) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 244BC2B7F0B7 for ; Mon, 24 Nov 2014 09:34:33 +0100 (CET) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Small adjustment to return construct Date: Mon, 24 Nov 2014 09:32:09 +0100 Message-ID: <32204920.gPM1CHe1Qo@polaris> User-Agent: KMail/4.7.2 (Linux/3.1.10-1.29-desktop; KDE/4.7.2; x86_64; ; ) MIME-Version: 1.0 This slightly improves the way the returns are built in gigi. Tested on x86_64-suse-linux, applied on the mainline. 2014-11-24 Eric Botcazou * gcc-interface/trans.c (build_return_expr): Use INIT_EXPR instead of MODIFY_EXPR to assign to the return object. (finalize_nrv_r): Adjust to above change. (finalize_nrv_unc_r): Likewise. Index: gcc-interface/trans.c =================================================================== --- gcc-interface/trans.c (revision 217998) +++ gcc-interface/trans.c (working copy) @@ -3135,7 +3135,7 @@ finalize_nrv_r (tree *tp, int *walk_subt nop, but differs from using NULL_TREE in that it indicates that we care about the value of the RESULT_DECL. */ else if (TREE_CODE (t) == RETURN_EXPR - && TREE_CODE (TREE_OPERAND (t, 0)) == MODIFY_EXPR) + && TREE_CODE (TREE_OPERAND (t, 0)) == INIT_EXPR) { tree ret_val = TREE_OPERAND (TREE_OPERAND (t, 0), 1), init_expr; @@ -3224,7 +3224,7 @@ finalize_nrv_unc_r (tree *tp, int *walk_ /* Change RETURN_EXPRs of NRVs to assign to the RESULT_DECL only the final return value built by the allocator instead of the whole construct. */ else if (TREE_CODE (t) == RETURN_EXPR - && TREE_CODE (TREE_OPERAND (t, 0)) == MODIFY_EXPR) + && TREE_CODE (TREE_OPERAND (t, 0)) == INIT_EXPR) { tree ret_val = TREE_OPERAND (TREE_OPERAND (t, 0), 1); @@ -3437,7 +3437,7 @@ build_return_expr (tree ret_obj, tree re RETURN_EXPR | - MODIFY_EXPR + INIT_EXPR / \ / \ RET_OBJ ... @@ -3446,13 +3446,14 @@ build_return_expr (tree ret_obj, tree re of the RET_OBJ as the operation type. */ tree operation_type = TREE_TYPE (ret_obj); - /* Convert the right operand to the operation type. Note that it's the - same transformation as in the MODIFY_EXPR case of build_binary_op, + /* Convert the right operand to the operation type. Note that this is + the transformation applied in the INIT_EXPR case of build_binary_op, with the assumption that the type cannot involve a placeholder. */ if (operation_type != TREE_TYPE (ret_val)) ret_val = convert (operation_type, ret_val); - result_expr = build2 (MODIFY_EXPR, void_type_node, ret_obj, ret_val); + /* We always can use an INIT_EXPR for the return object. */ + result_expr = build2 (INIT_EXPR, void_type_node, ret_obj, ret_val); /* If the function returns an aggregate type, find out whether this is a candidate for Named Return Value. If so, record it. Otherwise,