public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jeremy-gcc-bugzilla at sawicki dot us" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/102150] New: Speculative execution of inline assembly causes divide error Date: Wed, 01 Sep 2021 00:56:26 +0000 [thread overview] Message-ID: <bug-102150-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102150 Bug ID: 102150 Summary: Speculative execution of inline assembly causes divide error Product: gcc Version: 11.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: jeremy-gcc-bugzilla at sawicki dot us Target Milestone: --- Created attachment 51391 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51391&action=edit Reproducible test case The attached test case uses inline assembly to wrap the x86_64 DIV instruction. GCC speculatively executes the inline assembly on inputs that the source program does not, resulting in a divide error. The GCC documentation says that non-volatile inline assembly may be discarded or moved out of loops. It is not obvious whether speculative execution is also permitted. I asked on gcc-help and was asked to file a report. A related report points out that many projects currently wrap the DIV instruction without using volatile: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82677 Another related report considers the similar issue of whether pure/const functions must be non-trapping for inputs they don't actually receive: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93491 If it is determined that volatile is required, it would helpful to clarify in the documentation that speculative execution may occur without volatile: https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#Volatile gcc version 11.2.0 (GCC) Target: x86_64-pc-linux-gnu Configured with: /home/jeremys/gcc-11.2.0/configure --prefix=/home/jeremys/gcc-11.2.0-install --disable-multilib Command line: g++ -O3 -o divasm divasm.cpp No compiler errors/warnings are produced When executed, a divide error occurs
next reply other threads:[~2021-09-01 0:56 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-09-01 0:56 jeremy-gcc-bugzilla at sawicki dot us [this message] 2021-09-01 8:41 ` [Bug inline-asm/102150] " rguenth at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-102150-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).