This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Reject pre/post inc/decrement in "m" input operands (PR middle-end/43690)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 4 Nov 2010 21:12:37 +0100
- Subject: [PATCH] Reject pre/post inc/decrement in "m" input operands (PR middle-end/43690)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
We currently ICE in various ways when "m" operand has pre or post
increment/decrement. We reject "m" (x + 1) and & which is roughly
what "m" does doesn't accept x++ or ++x either, so I think rejecting
it is the best thing to do. The ICEs are because the FEs
don't mark the operand addressable, so we get invalid gimple.
In theory for POST increment/decrement we could instead just
mark their operand addressable, but for PRE increment/decrement
we still ICE with that badly.
What do you think about this?
Bootstrapped/regtested on x86_64-linux and i686-linux as usual.
2010-11-04 Jakub Jelinek <jakub@redhat.com>
PR middle-end/43690
* gimplify.c (gimplify_asm_expr): If a "m" input is a
{pre,post}{in,de}crement, fail.
* c-c++-common/pr43690.c: New test.
--- gcc/gimplify.c.jj 2010-03-26 17:13:37.000000000 +0100
+++ gcc/gimplify.c 2010-04-12 11:35:52.000000000 +0200
@@ -4989,6 +4989,13 @@ gimplify_asm_expr (tree *expr_p, gimple_
/* If the operand is a memory input, it should be an lvalue. */
if (!allows_reg && allows_mem)
{
+ tree inputv = TREE_VALUE (link);
+ STRIP_NOPS (inputv);
+ if (TREE_CODE (inputv) == PREDECREMENT_EXPR
+ || TREE_CODE (inputv) == PREINCREMENT_EXPR
+ || TREE_CODE (inputv) == POSTDECREMENT_EXPR
+ || TREE_CODE (inputv) == POSTINCREMENT_EXPR)
+ TREE_VALUE (link) = error_mark_node;
tret = gimplify_expr (&TREE_VALUE (link), pre_p, post_p,
is_gimple_lvalue, fb_lvalue | fb_mayfail);
mark_addressable (TREE_VALUE (link));
--- gcc/testsuite/c-c++-common/pr43690.c.jj 2010-04-12 11:14:44.000000000 +0200
+++ gcc/testsuite/c-c++-common/pr43690.c 2010-04-12 11:37:33.000000000 +0200
@@ -0,0 +1,13 @@
+/* PR middle-end/43690 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+void
+foo (char *x)
+{
+ asm ("" : : "m" (x++)); /* { dg-error "is not directly addressable" } */
+ asm ("" : : "m" (++x)); /* { dg-error "is not directly addressable" } */
+ asm ("" : : "m" (x--)); /* { dg-error "is not directly addressable" } */
+ asm ("" : : "m" (--x)); /* { dg-error "is not directly addressable" } */
+ asm ("" : : "m" (x + 1)); /* { dg-error "is not directly addressable" } */
+}
Jakub