This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix alias.c ICE on inline-asm "=m" incomplete operand (PR inline-asm/85022)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Richard Biener <rguenther at suse dot de>, Jeff Law <law at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 22 Mar 2018 22:34:06 +0100
- Subject: [PATCH] Fix alias.c ICE on inline-asm "=m" incomplete operand (PR inline-asm/85022)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
Something I wasn't really aware, apparently we allow extern vars with
incomplete types in "m" and "=m" constrained asm. The problem is that
incomplete vars have VOIDmode mode and so their MEMs do as well, apparently
everything works with it except a 2013-ish assert in alias.c.
The following patch just makes sure x_mode is not VOIDmode if x doesn't have
VOIDmode, if x has VOIDmode, then it is fine for x_mode to be VOIDmode too.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
2018-03-22 Jakub Jelinek <jakub@redhat.com>
PR inline-asm/85022
* alias.c (write_dependence_p): Don't require for x_canonicalized
non-VOIDmode if x has VOIDmode.
* c-c++-common/torture/pr85022.c: New test.
--- gcc/alias.c.jj 2018-03-01 11:29:06.725104754 +0100
+++ gcc/alias.c 2018-03-22 10:35:15.649546027 +0100
@@ -2999,7 +2999,8 @@ write_dependence_p (const_rtx mem,
int ret;
gcc_checking_assert (x_canonicalized
- ? (x_addr != NULL_RTX && x_mode != VOIDmode)
+ ? (x_addr != NULL_RTX
+ && (x_mode != VOIDmode || GET_MODE (x) == VOIDmode))
: (x_addr == NULL_RTX && x_mode == VOIDmode));
if (MEM_VOLATILE_P (x) && MEM_VOLATILE_P (mem))
--- gcc/testsuite/c-c++-common/torture/pr85022.c.jj 2018-03-22 10:44:40.520679173 +0100
+++ gcc/testsuite/c-c++-common/torture/pr85022.c 2018-03-22 10:44:29.550675460 +0100
@@ -0,0 +1,9 @@
+/* PR inline-asm/85022 */
+
+extern struct B b;
+
+void
+foo ()
+{
+ __asm ("" : "+m" (b));
+}
Jakub