From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by sourceware.org (Postfix) with ESMTPS id E52D83857020 for ; Tue, 27 Jun 2023 16:16:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E52D83857020 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-qt1-x831.google.com with SMTP id d75a77b69052e-40292285362so5799141cf.3 for ; Tue, 27 Jun 2023 09:16:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687882588; x=1690474588; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=Uqq3B78sZZbRNAljZaNZ4Is/y47blFzZNs8Y8cToLR8=; b=TUcA8VcK0pPKHiFYchMBBtPHn/SvpnYyFIKT78fytMTWtXUH6aWgzDdF4wB0wEauWX EZZBhoRR52nX/fAwh+in4dyw1/mz4f+KW6g6UI3IoRo1Tl+oEXUdC+OZdQ1NWwTnJlVq 1/zRvDfokEDazIfTRwBKLP/KLPi48FzSPXBC9Ql1ZrPS0S+XHpTtfd+X79lcNkFkTmvV exl3fq3iilxV7vEEuHDST8x4iRhwh6OiHXZ0QBLoC3QDiZmnXEo7i4JHR1N1H2e03osh dx0dVd0BSY9z2djTa8UNP1ocv2fUlwZld9024NU4kT6yuEaMgUleAq7KgOr6FTFzDpfl xvEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687882588; x=1690474588; h=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=Uqq3B78sZZbRNAljZaNZ4Is/y47blFzZNs8Y8cToLR8=; b=Wj5d+4hVlSjBkpSPA80YOyM0imeyjtmraTE8OPjLrotPkZUry6wRcpJ7vYX14TO4SB 8H09uqjx2E7bPqf73hFAFtY4Xf/cK9PTELAQVgnDUWvk+aJUv0kmUlcOdOrf/cjl2ky5 RhPyvClccLNt5RidU1z5VU18Tj2lMrz+qw24i6mytaY3HLry6Ky1dtLW51dlHIEbXx9v aejQaCcjyEcRcFKY79oO6dke2ICq3zMMQrriCYD1t4whqAfhbuE4BLTxdkIBYJgh/HTC WXqJX0cFwfd2gQis1Yc06eNfI0tQE8tiRY0lJXFHzAAXyydnYrzHrk+Sx2nYhXbcz9w6 z2YA== X-Gm-Message-State: AC+VfDyhew6ifZ3ybOX00f0F1Cd+4pAhAhdkG7Xi31NNB04qSr6heW68 RjOiH1FlrSSNMYO1ReydpvhrNriqOiYZE5ZsuyY= X-Google-Smtp-Source: ACHHUZ6JkfYY8cyHC0PW8puLxQO7qcmaZjOm4aZB59JkEKvlIY6wzKt9RRuhEGN5DSW037UFpQsMFU109ip8mLw9d6M= X-Received: by 2002:a05:622a:134a:b0:400:995d:6a3 with SMTP id w10-20020a05622a134a00b00400995d06a3mr11339810qtk.49.1687882588235; Tue, 27 Jun 2023 09:16:28 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Julian Waters Date: Wed, 28 Jun 2023 00:15:52 +0800 Message-ID: Subject: Re: [PATCH] Basic asm blocks should always be volatile To: Andrew Pinski , gcc@gcc.gnu.org Content-Type: multipart/alternative; boundary="000000000000182c3d05ff1eca2d" X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,GIT_PATCH_0,HTML_MESSAGE,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: --000000000000182c3d05ff1eca2d Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Perhaps this only affects compilation when GIMPLE isn't being used? On Wed, Jun 28, 2023 at 12: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 > > 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 >> volatile, >> > 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 called >> >> 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 >> > --000000000000182c3d05ff1eca2d--