This fixes an old glitch in the gimplification of asm, present initially for
clobbers and duplicated later for labels as well. The line:
asm ("nop" : : : "eax", "ebx");
is gimplified into:
__asm__ __volatile__("nop" : : : "ebx", "eax", "eax");
in the .gimple file because the TREE_CHAIN of clobbers isn't reset to
NULL_TREE, unlike for the outputs and the inputs.
Tested on x86_64-suse-linux, applied on the mainline as obvious.
2013-09-22 Eric Botcazou <ebotca...@adacore.com>
* gimplify.c (gimplify_asm_expr): Reset the TREE_CHAIN of clobbers to
NULL_TREE before pushing them onto the vector. Likewise for labels.
--
Eric Botcazou
Index: gimplify.c
===================================================================
--- gimplify.c (revision 202812)
+++ gimplify.c (working copy)
@@ -5419,11 +5419,21 @@ gimplify_asm_expr (tree *expr_p, gimple_
vec_safe_push (inputs, link);
}
- for (link = ASM_CLOBBERS (expr); link; ++i, link = TREE_CHAIN (link))
- vec_safe_push (clobbers, link);
+ link_next = NULL_TREE;
+ for (link = ASM_CLOBBERS (expr); link; ++i, link = link_next)
+ {
+ link_next = TREE_CHAIN (link);
+ TREE_CHAIN (link) = NULL_TREE;
+ vec_safe_push (clobbers, link);
+ }
- for (link = ASM_LABELS (expr); link; ++i, link = TREE_CHAIN (link))
- vec_safe_push (labels, link);
+ link_next = NULL_TREE;
+ for (link = ASM_LABELS (expr); link; ++i, link = link_next)
+ {
+ link_next = TREE_CHAIN (link);
+ TREE_CHAIN (link) = NULL_TREE;
+ vec_safe_push (labels, link);
+ }
/* Do not add ASMs with errors to the gimple IL stream. */
if (ret != GS_ERROR)