Message ID | 20240521073035.314024-27-poulhies@adacore.com |
---|---|
State | Committed |
Commit | d851e08ba97f5d0671711763f6a7d4c94afb8457 |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 764A0385828E for <patchwork@sourceware.org>; Tue, 21 May 2024 07:40:39 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by sourceware.org (Postfix) with ESMTPS id BFF843858410 for <gcc-patches@gcc.gnu.org>; Tue, 21 May 2024 07:31:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BFF843858410 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BFF843858410 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::22e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716276673; cv=none; b=Tb+N7GqGJLgkFauQXhsZlFxuT1j5DnFIRh0hKtU3ELHGpaT7we0l45DXHMUUhSCfEjueGlNlpegGXl32ZKLrTA5Dryz7wgTZVJQJQyoYg0x/I327pwmvAg0z4yIUT4yBU876khJlWKGXYtb/GP76X5OvxsrRpIWESP8u492zLO0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716276673; c=relaxed/simple; bh=iV9xLAPEB4BQJU1k7WuXF2TAOHXoHC6jHFhIMUV0dKc=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=wOum9AreWMYNujosttY5Ik0X9l6rz0RvJiCGCctRP6jSzNIz0rCaNV8Dt/Jv8oTHegXZIBHD6lnSDYb7+H2jNmKhctTUjGVE9wKVhm/fnynqFcCwlSbYNegRFUwSgjlcQVE51+EwMC6mCfOLpc9A3/GxBibqFrBsU/uiWv18EtU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2e72b8931caso17719311fa.0 for <gcc-patches@gcc.gnu.org>; Tue, 21 May 2024 00:31:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1716276668; x=1716881468; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jZf0erDPoNSnir1D7bJlTDYPeUNJ0sHNSvTCMWgvYKw=; b=envdQl5zXLQP859MHPOhHM6hNW2xSE7+dLAUap/r2ZDTZv4i3PxwYkwxvnadTIx0nB ZovN0OUHWEtOrMZ6mez8ijRCbPbIqQC2yYZiQ1ZcYUhAyYsDCv0QPgsaXYQ12/kwWQmO SQJkgrTL+B5qe205fhSvJtSArOiV9h2NvW1wtYyFW1E1gqhCYzFrNiWMLnzBqB/VwOyH fRiWJ9SU10HctYDviYn0pV+0IhIrFTNwa3/wDihuMClZ4jwyKRGwwRuG6LNmn4LZfy6a IJnjJbXGyycuS0pY0v6BIVy4hjWjMaTjTpjiFfvQ8tK4IOyKqo4GjsQyIZ7gKH9vs8Y6 TVUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716276668; x=1716881468; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jZf0erDPoNSnir1D7bJlTDYPeUNJ0sHNSvTCMWgvYKw=; b=VOGSDApZBz4i5FileZRLMwJdjoWQaV4WRjZj6KhLENmYCRy4BI5kGoAE4nkTfhyxLd wEjJAUHM3LJcd7S6cqhUsqv0g+6tO6i6uslYtJQkxIdfLsSFYcqG4Q4KfzdPElTE+gxD 2qEVnEEhvLSXeahpzfRyJGnDWz/BNz7VGltnzhx6u26oui5z8aRfh9j1e+A5ILhT4yon i/00SdUHq7oqXPbAdJtF2n4qI47Azi2CrXRp6jqOn2uNWka4fJIGOss9FOvSlgvaHuEQ mW6/rPwSsahvO+jK/9AdWlq9zpsGX0rI1YJpTQXl5se5kHjCGdg6dzt477KgPqaKQpcd GYLg== X-Gm-Message-State: AOJu0YwSaX1zFrbI9bAXqiKusTdykFSw00gM8ujmLKkMaXKYChvdomnS SCeavYx4UALEHv88J95eRLmxxA1q5u535wBep4fEIUoA58xp1133eFoUxB6QyLiLcbaUrSrPsMo = X-Google-Smtp-Source: AGHT+IG1Ltt+SKAojE95t5p0VNtqOJjOYI6gM8PhrNB/sOUasqMeXlosMrdclUf2rOO9DJI9/SvkvQ== X-Received: by 2002:a2e:b0d5:0:b0:2e0:2ef4:a985 with SMTP id 38308e7fff4ca-2e5204ccd6bmr195038411fa.35.1716276668361; Tue, 21 May 2024 00:31:08 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:de37:8b1c:1f33:2610]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-41fccee9292sm453333645e9.37.2024.05.21.00.31.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 00:31:08 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= <poulhies@adacore.com> To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou <ebotcazou@adacore.com> Subject: [COMMITTED 27/31] ada: Make detection of useless copy for return more robust Date: Tue, 21 May 2024 09:30:30 +0200 Message-ID: <20240521073035.314024-27-poulhies@adacore.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240521073035.314024-1-poulhies@adacore.com> References: <20240521073035.314024-1-poulhies@adacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org |
Series |
[COMMITTED,01/31] ada: Add new Mingw task priority mapping
|
|
Commit Message
Marc Poulhiès
May 21, 2024, 7:30 a.m. UTC
From: Eric Botcazou <ebotcazou@adacore.com>
In the return-by-invisible-reference case, the return object of an extended
return statement is allocated directly on the return stack and, therefore,
the copy operation on return is useless. The code detecting this was not
robust enough and missed some complex cases.
gcc/ada/
* gcc-interface/trans.cc (gnat_to_gnu) <N_Simple_Return_Statement>:
In the return-by-invisible-reference case, remove conversions before
looking for a dereference in the return values and building the test
protecting against a useless copy operation.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/gcc-interface/trans.cc | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc index a6b86ec8b51..4ae599b8b4c 100644 --- a/gcc/ada/gcc-interface/trans.cc +++ b/gcc/ada/gcc-interface/trans.cc @@ -7767,11 +7767,12 @@ gnat_to_gnu (Node_Id gnat_node) gnu_result = build2 (INIT_EXPR, void_type_node, gnu_ret_deref, gnu_ret_val); /* Avoid a useless copy with __builtin_return_slot. */ - if (INDIRECT_REF_P (gnu_ret_val)) + tree gnu_inner_val = remove_conversions (gnu_ret_val, false); + if (INDIRECT_REF_P (gnu_inner_val)) gnu_result = build3 (COND_EXPR, void_type_node, fold_build2 (NE_EXPR, boolean_type_node, - TREE_OPERAND (gnu_ret_val, 0), + TREE_OPERAND (gnu_inner_val, 0), gnu_ret_obj), gnu_result, NULL_TREE); add_stmt_with_node (gnu_result, gnat_node);