Hi,
> I'm trying to add a simple statement to GIMPLE code adding a new pass,
> that I put in pass_tree_loop.sub as last pass just before
> pass_tree_loop_done pass. Just as test I'd like to add a call like:
>
> .palp = shmalloc (16);
>
> This is the code I'm using:
>
> t = build_function_type_list (ptr_type_node,
> integer_type_node, NULL_TREE);
> decl = build_fn_decl ("shmalloc", t);
> t = build_int_cst (integer_type_node, 16);
> args = tree_cons (NULL, t, NULL);
> t = build_function_call_expr (decl, args);
> TREE_SIDE_EFFECTS (t) = 1;
>
> palpstruct = create_tmp_var (ptr_type_node, ".palp");
> add_referenced_var (palpstruct);
> t1 = build2 (MODIFY_EXPR, ptr_type_node, palpstruct, t);
depending on what version of gcc you use, you might need to use
t1 = build_gimple_modify_stmt (palpstruct, t);
> t2 = make_ssa_name (palpstruct, NULL);
t2 = make_ssa_name (palpstruct, t1);
> DECL_ARTIFICIAL (t1) = 1;
> TREE_SIDE_EFFECTS (t1) = 1;
> DECL_EXTERNAL (t1) = 1;
remove these three statements (t1 is not decl, and setting
TREE_SIDE_EFFECTS of t1 is not necessary).
> TREE_OPERAND (t1, 0) = t2;
> bsi_insert_after (&si, t1, BSI_CONTINUE_LINKING);
>
> If I try to add just the shmalloc(16); statement it works, but if I
> add the code to assign the result to a temporary variable, gcc
> segfaults while executing the vrp2 pass in tree-vrp.c. Could someone
> point me to the right direction? What am I doing wrong?
It may also turn out to be necessary to ensure that virtual operands
are updated,
Zdenek