Re: [PATCH] Basic asm blocks should always be volatile

2023-06-30 Thread Julian Waters via Gcc
Hi Michael, I'm on gcc 13.1 compiling for Windows x64, with the MinGW UCRT64 runtime library best regards, Julian On Thu, Jun 29, 2023 at 9:27 PM Michael Matz wrote: > Hello, > > On Thu, 29 Jun 2023, Julian Waters via Gcc wrote: > > > int main() { > > asm ("nop" "\n" > > "\t"

Re: [PATCH] Basic asm blocks should always be volatile

2023-06-29 Thread Michael Matz via Gcc
Hello, On Thu, 29 Jun 2023, Julian Waters via Gcc wrote: > int main() { > asm ("nop" "\n" > "\t" "nop" "\n" > "\t" "nop"); > > asm volatile ("nop" "\n" > "\t" "nop" "\n" > "\t" "nop"); > } > > objdump --disassemble-all -M intel -M

Re: [PATCH] Basic asm blocks should always be volatile

2023-06-29 Thread Julian Waters via Gcc
Hi Andrew, Here is a simpler testcase, with the resulting assembly attached below int main() { asm ("nop" "\n" "\t" "nop" "\n" "\t" "nop"); asm volatile ("nop" "\n" "\t" "nop" "\n" "\t" "nop"); } objdump --disassemble-all -M intel

Re: [PATCH] Basic asm blocks should always be volatile

2023-06-28 Thread Andrew Pinski via Gcc
On Wed, Jun 28, 2023 at 8:04 AM Michael Matz wrote: > > Hello, > > On Wed, 28 Jun 2023, Julian Waters via Gcc wrote: > > > On the contrary, code compiled with gcc with or without the applied patch > > operates very differently, with only gcc with the applied patch producing a > > fully correctly

Re: [PATCH] Basic asm blocks should always be volatile

2023-06-28 Thread Michael Matz via Gcc
Hello, On Wed, 28 Jun 2023, Julian Waters via Gcc wrote: > On the contrary, code compiled with gcc with or without the applied patch > operates very differently, with only gcc with the applied patch producing a > fully correctly operating program as expected. Even if the above inline > assembly

Re: [PATCH] Basic asm blocks should always be volatile

2023-06-28 Thread Julian Waters via Gcc-patches
Hi all, I've revised the change to be much neater >From 480954bc7d2b24e5d19a98260a2be0b49e112c42 Mon Sep 17 00:00:00 2001 From: TheShermanTanker Date: Wed, 28 Jun 2023 19:11:34 +0800 Subject: [PATCH] asm not using extended syntax should always be volatile --- gcc/cp/parser.cc | 2 +- 1 file

Re: [PATCH] Basic asm blocks should always be volatile

2023-06-28 Thread Julian Waters via Gcc
Hi Andrew, On the contrary, code compiled with gcc with or without the applied patch operates very differently, with only gcc with the applied patch producing a fully correctly operating program as expected. Even if the above inline assembly blocks never worked due to other optimizations however,

Re: [PATCH] Basic asm blocks should always be volatile

2023-06-28 Thread Andrew Pinski via Gcc
On Wed, Jun 28, 2023 at 12:32 AM Julian Waters wrote: > > Hi Andrew, > > On a Microsoft Windows target the following (placed inside a function of > course) will only work correctly if volatile is specified in the basic asm > block (or if the attached patch was applied to gcc): These inline-asm

Re: [PATCH] Basic asm blocks should always be volatile

2023-06-28 Thread Julian Waters via Gcc
Hi Andrew, On a Microsoft Windows target the following (placed inside a function of course) will only work correctly if volatile is specified in the basic asm block (or if the attached patch was applied to gcc): asm ("1:" "\n" "\t" ".seh_handler __C_specific_handler, @except" "\n"

Re: [PATCH] Basic asm blocks should always be volatile

2023-06-27 Thread Andrew Pinski via Gcc
On Tue, Jun 27, 2023 at 9:16 AM Julian Waters wrote: > > Perhaps this only affects compilation when GIMPLE isn't being used? The only time GIMPLE is not used is if you supply -fsyntax-only so ... Thanks, Andrew > > On Wed, Jun 28, 2023 at 12:15 AM Julian Waters > wrote: >> >> Hi Andrew, >>

Re: [PATCH] Basic asm blocks should always be volatile

2023-06-27 Thread Andrew Pinski via Gcc
On Tue, Jun 27, 2023 at 9:15 AM Julian Waters wrote: > > Hi Andrew, > > That can't be right, on my system a test of asm vs asm volatile with -O3 and > -flto=auto yields very different results, with only the latter being correct. > The patch fixed it and caused gcc to emit correct assembly Can

Re: [PATCH] Basic asm blocks should always be volatile

2023-06-27 Thread Julian Waters via Gcc
Perhaps this only affects compilation when GIMPLE isn't being used? On Wed, Jun 28, 2023 at 12:15 AM Julian Waters wrote: > Hi Andrew, > > That can't be right, on my system a test of asm vs asm volatile with -O3 > and -flto=auto yields very different results, with only the latter being >

Re: [PATCH] Basic asm blocks should always be volatile

2023-06-27 Thread Julian Waters via Gcc
Hi Andrew, That can't be right, on my system a test of asm vs asm volatile with -O3 and -flto=auto 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 AM Andrew Pinski

Re: [PATCH] Basic asm blocks should always be volatile

2023-06-27 Thread Andrew Pinski via Gcc
On Tue, Jun 27, 2023 at 9:03 AM 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

Re: [PATCH] Basic asm blocks should always be volatile

2023-06-27 Thread Julian Waters via Gcc
My apologies, I sent this to the wrong list. I have already resent it to the correct one regards, Julian

[PATCH] Basic asm blocks should always be volatile

2023-06-27 Thread Julian Waters via Gcc-patches
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_stmt is called

[PATCH] Basic asm blocks should always be volatile

2023-06-27 Thread Julian Waters via Gcc
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