On Tue, Jun 27, 2023 at 9:03 AM Julian Waters via Gcc <[email protected]> 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 == 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 <[email protected]>
> Date: Tue, 27 Jun 2023 23:56:38 +0800
> Subject: [PATCH] asm not using extended syntax should always be volatile
>
> ---
> 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 = true;
> + }
> asm_stmt = 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