https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66279
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot
gnu.org
Status|NEW |ASSIGNED
--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
The issue is that copy_tree_r does not copy ASM_EXPR constraints
and gimplification de-structively rewrites those.
<asm_expr 0x7ffff69d4e80
type <void_type 0x7ffff6828f18 void VOID
align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff6828f18
pointer_to_this <pointer_type 0x7ffff682f000>>
side-effects public
arg:0 <string_cst 0x7ffff69cf8a0
type <array_type 0x7ffff69dc930 type <integer_type 0x7ffff6833690 char>
type_6 QI
size <integer_cst 0x7ffff6820360 constant 8>
unit-size <integer_cst 0x7ffff6820378 constant 1>
align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff69dc930 domain <integer_type 0x7ffff6832dc8>>
readonly constant static "\000">
arg:1 <tree_list 0x7ffff69dd460
purpose <tree_list 0x7ffff69dd208
value <string_cst 0x7ffff69cf8b8 type <array_type 0x7ffff69dcbd0>
readonly constant static "+r\000">>
value <var_decl 0x7ffff69d0428 x type <integer_type 0x7ffff6828690
unsigned int>
used tree_1 tree_2 tree_6 unsigned read decl_5 SI t.C:10:18
size <integer_cst 0x7ffff68204b0 constant 32>
unit-size <integer_cst 0x7ffff68204c8 constant 4>
align:32 warn_if_not_align:0 context <function_decl 0x7ffff69c1d00
__ct_base > abstract_origin <var_decl 0x7ffff69d0390 x>>>
t.C:12:5 start: t.C:12:5 finish: t.C:12:11>
it's TREE_PURPOSE that's not covered by walk_tree_1 and thus not copied:
case TREE_LIST:
WALK_SUBTREE (TREE_VALUE (t));
WALK_SUBTREE_TAIL (TREE_CHAIN (t));
the following fixes that:
diff --git a/gcc/tree.cc b/gcc/tree.cc
index 0743ed71c78..7fd58abb099 100644
--- a/gcc/tree.cc
+++ b/gcc/tree.cc
@@ -11635,6 +11635,7 @@ walk_tree_1 (tree *tp, walk_tree_fn func, void *data,
case TREE_LIST:
WALK_SUBTREE (TREE_VALUE (t));
+ WALK_SUBTREE (TREE_PURPOSE (t));
WALK_SUBTREE_TAIL (TREE_CHAIN (t));
case TREE_VEC:
another fix would be to make gimplification aware of this and unshare
the constraint first like it does for TREE_VALUE already.
diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index 756cdea173f..160e7fc9df6 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -7810,6 +7810,7 @@ gimplify_asm_expr (tree *expr_p, gimple_seq *pre_p,
gimple_seq *post_p)
/* Turn the in/out constraint into an output constraint. */
char *p = xstrdup (constraint);
p[0] = '=';
+ TREE_PURPOSE (link) = unshare_expr (TREE_PURPOSE (link));
TREE_VALUE (TREE_PURPOSE (link)) = build_string (constraint_len, p);
/* And add a matching input constraint. */
I'm testing that.