public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/113921] Output register of an "asm volatile goto" is incorrectly clobbered/discarded Date: Thu, 15 Feb 2024 15:17:51 +0000 [thread overview] Message-ID: <bug-113921-4-AxdRpZ5PDN@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-113921-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113921 --- Comment #13 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-12 branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>: https://gcc.gnu.org/g:ba09da9787e8db8903b2b0f7c647c0d7af68bb74 commit r12-10158-gba09da9787e8db8903b2b0f7c647c0d7af68bb74 Author: Jakub Jelinek <jakub@redhat.com> Date: Thu Feb 15 15:53:01 2024 +0100 expand: Fix handling of asm goto outputs vs. PHI argument adjustments [PR113921] The Linux kernel and the following testcase distilled from it is miscompiled, because tree-outof-ssa.cc (eliminate_phi) emits some fixups on some of the edges (but doesn't commit edge insertions). Later expand_asm_stmt emits further instructions on the same edge. Now the problem is that expand_asm_stmt uses insert_insn_on_edge to add its own fixups, but that function appends to the existing sequence on the edge if any. And the bug triggers when the fixup sequence emitted by eliminate_phi uses a pseudo which the fixup sequence emitted by expand_asm_stmt later on sets. So, we end up with (set (reg A) (asm_operands ...)) and on one of the edges queued sequence (set (reg C) (reg B)) // added by eliminate_phi (set (reg B) (reg A)) // added by expand_asm_stmt That is wrong, what we emit by expand_asm_stmt needs to be as close to the asm_operands as possible (they aren't known until expand_asm_stmt is called, the PHI fixup code assumes it is reg B which holds the right value) and the PHI adjustments need to be done after it. So, the following patch introduces a prepend_insn_to_edge function and uses it from expand_asm_stmt, so that we queue (set (reg B) (reg A)) // added by expand_asm_stmt (set (reg C) (reg B)) // added by eliminate_phi instead and so the value from the asm_operands output propagates correctly to the PHI result. 2024-02-15 Jakub Jelinek <jakub@redhat.com> PR middle-end/113921 * cfgrtl.h (prepend_insn_to_edge): New declaration. * cfgrtl.cc (insert_insn_on_edge): Clarify behavior in function comment. (prepend_insn_to_edge): New function. * cfgexpand.cc (expand_asm_stmt): Use prepend_insn_to_edge instead of insert_insn_on_edge. * gcc.target/i386/pr113921.c: New test. (cherry picked from commit 2b4efc5db2aedb59196987300e14951d08cd7106)
next prev parent reply other threads:[~2024-02-15 15:17 UTC|newest] Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-02-14 17:19 [Bug c/113921] New: " seanjc at google dot com 2024-02-14 18:00 ` [Bug middle-end/113921] " jakub at gcc dot gnu.org 2024-02-14 18:13 ` torvalds@linux-foundation.org 2024-02-14 18:16 ` torvalds@linux-foundation.org 2024-02-14 18:21 ` jakub at gcc dot gnu.org 2024-02-14 18:25 ` torvalds@linux-foundation.org 2024-02-14 18:40 ` jakub at gcc dot gnu.org 2024-02-14 19:07 ` jakub at gcc dot gnu.org 2024-02-14 20:31 ` jakub at gcc dot gnu.org 2024-02-15 8:00 ` rguenth at gcc dot gnu.org 2024-02-15 8:21 ` jakub at gcc dot gnu.org 2024-02-15 14:56 ` cvs-commit at gcc dot gnu.org 2024-02-15 15:14 ` cvs-commit at gcc dot gnu.org 2024-02-15 15:17 ` cvs-commit at gcc dot gnu.org [this message] 2024-02-15 15:20 ` cvs-commit at gcc dot gnu.org 2024-02-15 15:22 ` jakub 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-113921-4-AxdRpZ5PDN@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).