From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by sourceware.org (Postfix) with ESMTPS id 452B43858D28 for ; Tue, 27 Jun 2023 16:24:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 452B43858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-553a998bca3so3560726a12.2 for ; Tue, 27 Jun 2023 09:24:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687883041; x=1690475041; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=2Aiw0pTzLWAaEkSrQI2pKVjowWWCiSk4jfsyQiwISiU=; b=jUpsOhBcyOBHFUmYISehlkD9zzTqwQH+4JdelyQ7j9lR3jtQS5YIk1kY+yL8HBGPul KGeWgByKy0QGKBlexegQhVVBf8nQ4slJSVbCffdu79S9ZX7hWQE8nUbWSbWccvaks7CS g9pagsuuSNy17PO6qPYunEQFsmew8W+plQHxfaFJdneCTzvou9t7nO4Vxg8R0MboeMfp qPFBher17Zyy7w8n1KDAnBJyH64pv68b8oXGGBRWdVmLQUgR4qPDzvtNGEY2FjdMW7Ma IK4kqxX0qW83mTjETtKC6unv7zwCtUr7Gzb3YnQBD2mIx2pp8b7Kq78m0y/wtaafpmih F3dA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687883041; x=1690475041; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2Aiw0pTzLWAaEkSrQI2pKVjowWWCiSk4jfsyQiwISiU=; b=Ji/vkR1M0/BSRbeHkVUYjI18xTru1mofrQIaGkvCzuefIuiakrOHfgf6nr59TtGMf+ rzvUp4j5s1l1ImC4FO/8uSmaL4E/9Uc5oB5g/RwhlNHBvDraqpEq/20j5JlT/nUdReDx yIEnoA+C8GCiYZMrFGwE1cKW/YipTptXYf8mWwonLerV+cMJBQ7CWU1wHGF4XNURLQ+W lVeCLbx5QY9ZDlL4y/Ydy68QVp1sAXKBgVj1LReikDmRSSsYfUPFVt1LVTqyoJe+8yua McDPbCfLt2yS9uuIuFceWnWSJ4Fd5aYFLvdVcUBOD2GSnbQhtckDUVVz+77hkYPFBCao LKIw== X-Gm-Message-State: AC+VfDw83SYgsuB6ZO5hiNqCQAU4gesO9WmVQnGD+We1pCfpq+mrWBDj HrrJ9j5ly0lBbBB5019uiPj8Q0ndXiPWKzEVSIQ= X-Google-Smtp-Source: ACHHUZ5bC+zAFOYJl4Kmlcd9xDGjC8ZAaE/BSgSe2k2wS3g/6cbFumoOdPCe9FdSP+EVEfuPEgZ8pef3tHZSwmCItV0= X-Received: by 2002:a17:903:1210:b0:1b3:cac7:19cd with SMTP id l16-20020a170903121000b001b3cac719cdmr11974720plh.18.1687883041012; Tue, 27 Jun 2023 09:24:01 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Andrew Pinski Date: Tue, 27 Jun 2023 09:23:49 -0700 Message-ID: Subject: Re: [PATCH] Basic asm blocks should always be volatile To: Julian Waters Cc: gcc@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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: On Tue, Jun 27, 2023 at 9:15=E2=80=AFAM Julian Waters wrote: > > Hi Andrew, > > That can't be right, on my system a test of asm vs asm volatile with -O3 = and -flto=3Dauto yields very different results, with only the latter being = correct. The patch fixed it and caused gcc to emit correct assembly Can you provide a few testcases? Because the gimplifier should always happe= n. Thanks, Andrew Pinski > > best regards, > Julian > > On Wed, Jun 28, 2023 at 12:08=E2=80=AFAM Andrew Pinski wrote: >> >> On Tue, Jun 27, 2023 at 9:03=E2=80=AFAM Julian Waters via Gcc wrote: >> > >> > gcc's documentatation mentions that all basic asm blocks are always vo= latile, >> > yet the parser fails to account for this by only ever setting >> > volatile_p to true >> > if the volatile qualifier is found. This patch fixes this by adding a >> > special case check for extended_p before finish_asm_statement is calle= d >> >> The patch which are you doing will not change the behavior of GCC as >> GCC already treats them as volatile later on. >> non-extended inline-asm has no outputs so the following code in the >> gimplifier will kick in and turn the gimple statement into volatile: >> gimple_asm_set_volatile (stmt, ASM_VOLATILE_P (expr) || noutputs = =3D=3D 0); >> >> (note I am about to push a patch which changes the condition slightly >> to have `asm goto` as volatile). >> >> Thanks, >> Andrew >> >> > >> > From 3094be39e3e65a6a638f05fafd858b89fefde6b5 Mon Sep 17 00:00:00 2001 >> > From: TheShermanTanker >> > Date: Tue, 27 Jun 2023 23:56:38 +0800 >> > Subject: [PATCH] asm not using extended syntax should always be volati= le >> > >> > --- >> > gcc/cp/parser.cc | 3 +++ >> > 1 file changed, 3 insertions(+) >> > >> > diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc >> > index a6341b9..ef3d06a 100644 >> > --- a/gcc/cp/parser.cc >> > +++ b/gcc/cp/parser.cc >> > @@ -22355,6 +22355,9 @@ cp_parser_asm_definition (cp_parser* parser) >> > /* Create the ASM_EXPR. */ >> > if (parser->in_function_body) >> > { >> > + if (!extended_p) { >> > + volatile_p =3D true; >> > + } >> > asm_stmt =3D finish_asm_stmt (asm_loc, volatile_p, string, outputs= , >> > inputs, clobbers, labels, inline_p); >> > /* If the extended syntax was not used, mark the ASM_EXPR. */ >> > -- >> > 2.35.1.windows.2