From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by sourceware.org (Postfix) with ESMTPS id 2092E3858430 for ; Tue, 21 May 2024 07:31:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2092E3858430 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 2092E3858430 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716276676; cv=none; b=Dy51DHG6l2OUre6jXqzoHJ6wm1d8ZSIiTM4muju36fQqYO2QVTOrdg6+mzEJ2iDXsdwZwCtqUwyRWsuKjSYMcU/vf86IYAXI/hUzzvCpIKCH7HKXOd2lSIz73Jzq+ISfSaCJ0Rqd7Pg6sD/Rk+bFU6R8rghA+4gONZuW7RDoHRc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716276676; c=relaxed/simple; bh=KG86oMXf9/afv7Ivj1Js9Gaz1ajkMayj/ht1nM+wvu4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=AFSMA1PM+118vgM7TpaHNBNo3+fXfADkatuCvxjJjR2up3V1FcfRxsTyfclE6SVu1qw39oMQAIZ+bKUqujDy1dPTa0ifHMP1+Zuleig5Tbt3hM6a6aW/bx/bCp+QHsbwobrSk6RHRUsLw+Wn4yKQvX4SaT5Mwf+isGEZLvSmNUs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4202ca70270so38993455e9.3 for ; Tue, 21 May 2024 00:31:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1716276670; x=1716881470; 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=cD3DQCHy7uAAvXcNJwNjX5AzG9skbgX8eYJyzkAMufk=; b=iQyKacATnk0W9JuyYP52E2SLYC1KP8bYxW7RQPTgFsg06CWkI9IRL8dnU4RsnxNlLR ruC7osHw0gZs4i9hGNA80Y86yMLTXYSaNqtTIM7SKAQybJ3NLTSInSNa2P0/XBA7bBz6 GO9jnz1zsESpcdPWSxNKJOu5Og8Kq/VJEbeRDz1ok4RUq9fNjjRA6LpUN65UBGKGjxld ISIn3eqf+EpUDXXSb8HX3maCLPkpR4Jj9vIUX9egQamleS5UfYbFtiDyVqnyBub4aBfQ /rnA9VTxpCg86rKgHQuSameqEFrA8y699w4xH1u/yCEHPyrIE9Qb5NIhdLHHFCUWWU8Q L61g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716276670; x=1716881470; 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=cD3DQCHy7uAAvXcNJwNjX5AzG9skbgX8eYJyzkAMufk=; b=VoqwRq+ntorgaz4MAd0gHlfwFyBUBaf7kq1Lv1mt6ZRe5VMblAnUwrCXODeBVySBV5 4/s74boIkcBzaYrZllRfaBCEjdf9HoHwPFAfF3UQ2o1OIKYx8sKZshOgKe12C+FxZ31m p++rpJeVgNMjNu/1h8r5H2Tbex5Pzzh/DTv63pkbc3TIvG1Rq9L8uo3wIY/ivasp6STK YRWD6f2A/ycZjsVL5YUR5oMY7a5jHwf2KRN5AM5CSDSxgLMVbefwgWMU6FuCmztUnZNt /eeZddQOLJXgjtQvUpal4KavOJJuOqwm7lr7lK58RLOXWFATNI6LM1WVxEG68VmqrxZD +s7Q== X-Gm-Message-State: AOJu0Yz2zrFdELFx/cxGtCmQI3DkF2QQbsMw0TPz/O27EVRLTm5KTHSb aiJHTHYt3EY0TyvxewcBlt/Idr5PhoSdQMc3TfXULxXNrSaBec8feeKtEyz9VzZDQdDzMy/Thdo = X-Google-Smtp-Source: AGHT+IHNhvtQky3fr3541Rd/pGrlyBD/qNwuXl6N1hP4QdiwNjdFxWQDLMC9H8c5O4A5wqJ3fBMjqA== X-Received: by 2002:a05:600c:3ca3:b0:41c:23f3:65fa with SMTP id 5b1f17b1804b1-41feac55e3cmr294760655e9.28.1716276669935; Tue, 21 May 2024 00:31:09 -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.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 00:31:09 -0700 (PDT) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED 29/31] ada: Fix internal error on discriminated record with Atomic aspect in Ada 2022 Date: Tue, 21 May 2024 09:30:32 +0200 Message-ID: <20240521073035.314024-29-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 List-Id: From: Eric Botcazou It occurs in build_load_modify_store where the pattern matching logic cannot find the atomic load that is present in the tree because it has been wrapped in a SAVE_EXPR by gnat_protect_expr, which is unnecessary. gcc/ada/ * gcc-interface/utils2.cc (gnat_protect_expr): Deal specifically with atomic loads. Document the relationship with gnat_save_expr. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/gcc-interface/utils2.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/gcc/ada/gcc-interface/utils2.cc b/gcc/ada/gcc-interface/utils2.cc index c1346cfadeb..8fb86ab29e3 100644 --- a/gcc/ada/gcc-interface/utils2.cc +++ b/gcc/ada/gcc-interface/utils2.cc @@ -2887,7 +2887,11 @@ gnat_save_expr (tree exp) /* Protect EXP for immediate reuse. This is a variant of gnat_save_expr that is optimized under the assumption that EXP's value doesn't change before - its subsequent reuse(s) except through its potential reevaluation. */ + its subsequent reuse(s) except potentially through its reevaluation. + + gnat_protect_expr guarantees that multiple evaluations of the expression + will not generate multiple side effects, whereas gnat_save_expr further + guarantees that all evaluations will yield the same result. */ tree gnat_protect_expr (tree exp) @@ -2932,6 +2936,13 @@ gnat_protect_expr (tree exp) return build3 (code, type, gnat_protect_expr (TREE_OPERAND (exp, 0)), TREE_OPERAND (exp, 1), NULL_TREE); + /* An atomic load is an INDIRECT_REF of its first argument, so apply the + same transformation as in the INDIRECT_REF case above. */ + if (code == CALL_EXPR && call_is_atomic_load (exp)) + return build_call_expr (TREE_OPERAND (CALL_EXPR_FN (exp), 0), 2, + gnat_protect_expr (CALL_EXPR_ARG (exp, 0)), + CALL_EXPR_ARG (exp, 1)); + /* If this is a COMPONENT_REF of a fat pointer, save the entire fat pointer. This may be more efficient, but will also allow us to more easily find the match for the PLACEHOLDER_EXPR. */ -- 2.43.2