From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by sourceware.org (Postfix) with ESMTPS id 05A4E3857BAD for ; Fri, 4 Nov 2022 13:54:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 05A4E3857BAD Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-wm1-x32e.google.com with SMTP id fn7-20020a05600c688700b003b4fb113b86so3245379wmb.0 for ; Fri, 04 Nov 2022 06:54:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Zer2FjIytOmZfk9YNavA0eSfTw1RrlN3MYtYwaurn9o=; b=CGKgfZQZg6dOz2fWLR6oGmQ2yB+DGxor5AQxVqv2JHp7PaekAYhu1AZkrgqIjYCUZD hyVFC26c4Kg604xMKvAkXkbdh1bqUwsej9CAcgwrv0aEEeN9bOMqpge81MTupVo3l006 07ApNB5uoAvC11WqQyMc6OIFlDElA35rJTokPK6cZh7SRZMATZTzotEQ+sVlNUFP3mVl HTwrU/6Vn2U/EdhbtgVgjsFdm9E4LW0hrgse5C9l8waXnwtvbaBk62i6H2+D3sj4+AIm ZoVymUStN/srKU0KgOUBDLZ1gdki4H5s+kDcPhZU7Q95Tv3Fow9jWpdfMLwk0HuT8SKF nS0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Zer2FjIytOmZfk9YNavA0eSfTw1RrlN3MYtYwaurn9o=; b=qXJRNEG3PzeczA1JU7REQobfZfDgACA5cW8DYgP31d1UfdwrAvz57losoAdOgozJ4l cEEgvJ/r4HmN8bISL9psVgigsDUPpSjN6F/WoowlzUP3QEaN0itK+wG3QxECnzujzw9T TqbwlBcbhBi9EkwrZ6yFzquf566Rd0lYbTRzAm3bZUmYXjUEsZsnbJrbJCR4p6kl/mPf Gug6GN/b2NpubdXiYhIisAzd5shr8nBLH9G3hxeEG+kg8QCmhrVJmgTQY9TZtL8DM7v7 0OXrnBBx4p9biYBhSyTSLPcWdN/xu2lVGl2gOOPjTPHmZ348QHV7QNi0mVrHSMtfgpMH 06jg== X-Gm-Message-State: ACrzQf1LBb0dRD2NDiJG+vAY5wczlH4pgGD0TgTwYSZqVMyalKZVDpqK +Xho7mE3uKP03zTjIHPPLpn++D4JkL/jPA== X-Google-Smtp-Source: AMsMyM4jU7G5Jef39KKzHYEwfLjFbfqTcz+2OiRLZ87+v6ZLuuUfknpOL+zRtHi8sXfeDO8lxEwIBA== X-Received: by 2002:a7b:cc15:0:b0:3b4:ca90:970d with SMTP id f21-20020a7bcc15000000b003b4ca90970dmr24034493wmh.198.1667570071774; Fri, 04 Nov 2022 06:54:31 -0700 (PDT) Received: from localhost.localdomain (static-176-191-105-132.ftth.abo.bbox.fr. [176.191.105.132]) by smtp.gmail.com with ESMTPSA id n21-20020a05600c3b9500b003b4c979e6bcsm3316098wms.10.2022.11.04.06.54.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Nov 2022 06:54:31 -0700 (PDT) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED] ada: Support lock-free protected objects with pragma Initialize_Scalars Date: Fri, 4 Nov 2022 14:54:27 +0100 Message-Id: <20221104135427.85477-1-poulhies@adacore.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.2 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: Piotr Trojanek In general, protected subprograms are only eligible for a lock-free expansion if they do not reference global assignable objects. However, it seems reasonable to ignore references to variables in System.Scalar_Values, which are generated when pragma Initialize_Scalars is active. Such references appear, for example, when protected subprogram has formal parameters of mode out. gcc/ada/ * sem_ch9.adb (Satisfies_Lock_Free_Requirements): Ignore references to global variables inserted due to pragma Initialize_Scalars. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch9.adb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gcc/ada/sem_ch9.adb b/gcc/ada/sem_ch9.adb index 5dee216256c..e43e3ae0b41 100644 --- a/gcc/ada/sem_ch9.adb +++ b/gcc/ada/sem_ch9.adb @@ -474,6 +474,12 @@ package body Sem_Ch9 is begin -- Prohibit references to non-constant entities -- outside the protected subprogram scope. + -- + -- References to variables in System.Scalar_Values + -- generated because of pragma Initialize_Scalars are + -- allowed, because once those variables are + -- initialized by the binder-generated code, they + -- behave like constants. if Is_Assignable (Id) and then not @@ -482,6 +488,9 @@ package body Sem_Ch9 is Scope_Within_Or_Same (Scope (Id), Protected_Body_Subprogram (Sub_Id)) + and then not + (Is_RTU (Scope (Id), System_Scalar_Values) + and then not Comes_From_Source (N)) then if Lock_Free_Given then Error_Msg_NE -- 2.34.1