From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4C6A53858D39; Tue, 11 Jan 2022 16:29:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4C6A53858D39 From: "gareth.webb+gccbugzilla at outlook dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/103979] New: asm goto is not considered volatile Date: Tue, 11 Jan 2022 16:29:03 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 11.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: gareth.webb+gccbugzilla at outlook dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Jan 2022 16:29:03 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103979 Bug ID: 103979 Summary: asm goto is not considered volatile Product: gcc Version: 11.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: gareth.webb+gccbugzilla at outlook dot com Target Milestone: --- Created attachment 52165 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D52165&action=3Dedit Minimal reproduction of bug I have discovered a bug with GCC's 'asm goto'. It is documented that "note = that an asm goto statement is always implicitly considered volatile." but it is = not. It is using the same heuristic as non-goto asm (no outputs =3D> volatile. o= utputs =3D> not-volatile, unless explicitly specified). This can result in the optimizer removing the asm block completely. Confirmed the bug is present on Ubuntu 20.10's gcc package, as well as my o= wn build from source (tag: releases/gcc-11.2.0). A minimal pre-processed reproduction is attached. Compile with gcc -O2 -c asmgoto.c -o asmgoto.o, observe the disassembled output contains nothing but endb64/ret, no jmp. I also received an ICE at one point when trying to create a minimal reproduction, but could not reproduce. It's included below, but as I can't reproduce I don't know how useful it will be. Ubuntu package: Using built-in specs. COLLECT_GCC=3Dgcc COLLECT_LTO_WRAPPER=3D/usr/lib/gcc/x86_64-linux-gnu/11/lto-wrapper OFFLOAD_TARGET_NAMES=3Dnvptx-none:amdgcn-amdhsa OFFLOAD_TARGET_DEFAULT=3D1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion=3D'Ubuntu 11.2.0-7ub= untu2' --with-bugurl=3Dfile:///usr/share/doc/gcc-11/README.Bugs --enable-languages= =3Dc, ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=3D/usr --with-gcc-major-version-only --program-suffix=3D-11 --program-prefix=3Dx86_64-linux-gnu- --enable-share d --enable-linker-build-id --libexecdir=3D/usr/lib --without-included-gette= xt --enable-threads=3Dposix --libdir=3D/usr/lib --enable-nls --enable-bootstrap --enabl e-clocale=3Dgnu --enable-libstdcxx-debug --enable-libstdcxx-time=3Dyes --with-default-libstdcxx-abi=3Dnew --enable-gnu-unique-object --disable-vtable-verify --ena ble-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=3Drelease --with-target-system-zlib=3Dauto --enable-objc-gc=3Dauto --enable-multiar ch --disable-werror --enable-cet --with-arch-32=3Di686 --with-abi=3Dm64 --with-multilib-list=3Dm32,m64,mx32 --enable-multilib --with-tune=3Dgeneric --enable-offload -targets=3Dnvptx-none=3D/build/gcc-11-ZPT0kp/gcc-11-11.2.0/debian/tmp-nvptx= /usr,amdgcn-amdhsa=3D/build/gcc-11-ZPT0kp/gcc-11-11.2.0/debian/tmp-gcn/usr --without-cu da-driver --enable-checking=3Drelease --build=3Dx86_64-linux-gnu --host=3Dx86_64-linux-gnu --target=3Dx86_64-linux-gnu --with-build-config=3Dbootstrap-lto-lean --enab le-link-serialization=3D2 Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 11.2.0 (Ubuntu 11.2.0-7ubuntu2)=20 Myy own build: Using built-in specs. COLLECT_GCC=3Dx86_64-elf-gcc COLLECT_LTO_WRAPPER=3D/home/gwebb/opt/cross/libexec/gcc/x86_64-elf/11.2.0/l= to-wrapper Target: x86_64-elf Configured with: ../gcc/configure --target=3Dx86_64-elf --prefix=3D/home/gwebb/opt/cross --disable-nls --enable-languages=3Dc --without-headers Thread model: single Supported LTO compression algorithms: zlib gcc version 11.2.0 (GCC) Possibly related ICE? during RTL pass: fwprop1 gdt.c: In function 'flush_gdt': gdt.c:66:1: internal compiler error: in purge_dead_edges, at cfgrtl.c:3346 66 | } | ^ 0x5d253d purge_dead_edges(basic_block_def*) ../../gcc/gcc/cfgrtl.c:3346 0x143dc1f delete_trivially_dead_insns(rtx_insn*, int) ../../gcc/gcc/cse.c:7178 0x145baa9 fwprop_done ../../gcc/gcc/fwprop.c:917 0x145baa9 fwprop ../../gcc/gcc/fwprop.c:1001 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See for instructions.=