Message ID | 20240516092606.41242-33-poulhies@adacore.com |
---|---|
State | New |
Headers | show
Return-Path: <gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org> X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=ArjyR5gf; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Vg4k11XCwz1yfq for <incoming@patchwork.ozlabs.org>; Thu, 16 May 2024 19:36:57 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 763EC3846401 for <incoming@patchwork.ozlabs.org>; Thu, 16 May 2024 09:36:55 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by sourceware.org (Postfix) with ESMTPS id 5F9093849AC7 for <gcc-patches@gcc.gnu.org>; Thu, 16 May 2024 09:26:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5F9093849AC7 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 5F9093849AC7 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::330 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715851601; cv=none; b=xawVRBbgQa0rN2+ej5MlcqnfdNQsBHKZIjVYaoZOHlcHid5ajpMPnHVW1IbKb/KpjMV/fifKqwVCSYGjfm+UJwaO/zfDChpNOzSJIzkM6hU3OAB3/J953Ft/xdttaXJSPcjuoMbfytTjKj2p1nWwCv+9Cn+t6HV44eVmw1yqbFg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715851601; c=relaxed/simple; bh=pCuZYBZArmX3zwmSxihdUuOeZKDtlmuPeWsnbgtVZs0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=d2fMATop4K+aTREBN2npLPLttEHJfKFQ7EFO+t+q1xgp23PUJZyV+ft9eIWYJlwvcsVqLW0quEAlQI3FsC9U6DfQeE2IY1VDSS6wG9MO4IzCrIjQ0ZJpA3VQa3pVvKLF4e2rr56YeSp+z7ILPjyfQUc9lJZJV5fyJWjsvgbFe30= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-41fc5645bb1so55412945e9.1 for <gcc-patches@gcc.gnu.org>; Thu, 16 May 2024 02:26:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1715851595; x=1716456395; 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=8xFlzuTmJjuX0DAw6Q4j9e46Gcc1/DXGi8WXeafswcE=; b=ArjyR5gfKXtRL1rJycD0xJO0NZmkSfOieQ46/l8Ou8F9uuP0SCYyuBKdE38fCzHLX+ cte5tx3W99Pnh+aBjHex9MhzZggLSh3ghOqfJo7nCC4gkTVwMtRTE0ztHHMh1gogGeFp XxCwocbSg2bUaEiMNitv7lG5/SmObMbtM2G7r3PyE/EtP/c6slxg56hlaAmtyLs2GY3V Sq33AZhelrifR7vTEKs/FYjkwOHF4Rl0W7flTd4XmOitpBkAISmFVdxfkFLhrbf+jneA 4lS74n1bjqwoF6kG6Sl4Sv85HRoE6vUUmwDxsqkLrSkCUpXUCSciObX5NraaFFr+GQka cdAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715851595; x=1716456395; 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=8xFlzuTmJjuX0DAw6Q4j9e46Gcc1/DXGi8WXeafswcE=; b=JmThX9FpMjpRAdtUJbqCQMQACn1VIkBvUMZDN9gx5vduT6fPLq5U6HYwk31qovXpPI IIpO1dr6WT+c0VrgkgbbOFC7GpXHSXpZ/hksJ6l2u1ziq6xkazcoJKAuWIjzSTScShUM OB3WECiDyhQH8yyXJJqWJW/1lkyXeIl9T842mKVyKPb/y6svDGFSuyTLe5mMU5z0qt/1 YsRixWgNrgtzq+DHq5hPclrTxlmjd6aNfz2p3O8J36njllNNbSs+5+aA7gnWhuvvqPmV vfv4wWJI41B2qd/GDOp4XtMX2pTRqg1PR5U+u/uZIkqESPtfmbfjYt/G9WxHl65quIyk ndiA== X-Gm-Message-State: AOJu0Yy4VT65CLawUrKYPOR/Flystq0rLYvfu8vUBNjCVaGvjz3/9X5A 97ndNRpRoMSuCLftJGRDHjtvqn03wJp8gQ2YNpjJWKDQvsRmNE1MM4eztnb2yN+xjF1McCTP+Uk = X-Google-Smtp-Source: AGHT+IG2vuO8XdYZ2TGZVjk0EfHrsq5Z2rK5uJVU2WbBUm4GBZW3pI4D3xCubMVKBYB55yPIXFbCzA== X-Received: by 2002:a1c:4c07:0:b0:418:f826:58c3 with SMTP id 5b1f17b1804b1-41feaa3947dmr134623255e9.15.1715851595225; Thu, 16 May 2024 02:26:35 -0700 (PDT) Received: from poulhies-Precision-5550.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-41fd10cf8besm135802635e9.1.2024.05.16.02.26.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 02:26:34 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= <poulhies@adacore.com> To: gcc-patches@gcc.gnu.org Cc: Steve Baird <baird@adacore.com> Subject: [COMMITTED 33/35] ada: Redundant validity checks Date: Thu, 16 May 2024 11:26:02 +0200 Message-ID: <20240516092606.41242-33-poulhies@adacore.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240516092606.41242-1-poulhies@adacore.com> References: <20240516092606.41242-1-poulhies@adacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.7 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+incoming=patchwork.ozlabs.org@gcc.gnu.org |
Series |
[COMMITTED,01/35] ada: Fix docs and comments about pragmas for Boolean-valued aspects
|
expand
|
diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb index 6af392eeda8..bada3dffcbf 100644 --- a/gcc/ada/checks.adb +++ b/gcc/ada/checks.adb @@ -6839,6 +6839,9 @@ package body Checks is then return True; + elsif Is_Static_Expression (Expr) then + return True; + -- If the expression is the value of an object that is known to be -- valid, then clearly the expression value itself is valid. diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb index 057cf3ebc48..b71f7739481 100644 --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -416,6 +416,11 @@ package body Exp_Util is if Validity_Checks_On and then (Validity_Check_Tests or else Is_Hardbool_Type (T)) + + -- no check needed here if validity has already been checked + and then not + (Validity_Check_Operands and then + (Nkind (N) in N_Op or else Nkind (Parent (N)) in N_Op)) then Ensure_Valid (N); end if;
From: Steve Baird <baird@adacore.com> In some cases with validity checking enabled via the -gnatVa option, the compiler generates validity checks that can (obviously) never fail. These include validity checks for (some) static expressions, and consecutive identical checks generated for a single read of an object. gcc/ada/ * checks.adb (Expr_Known_Valid): Return True for a static expression. * exp_util.adb (Adjust_Condition): No validity check needed for a condition if it is an expression for which a validity check has already been generated. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/checks.adb | 3 +++ gcc/ada/exp_util.adb | 5 +++++ 2 files changed, 8 insertions(+)