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);
             t2 = make_ssa_name (palpstruct, NULL);
             DECL_ARTIFICIAL (t1) = 1;
             TREE_SIDE_EFFECTS (t1) = 1;
             DECL_EXTERNAL (t1) = 1;
             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?

Regards,
Mario Fanelli

Reply via email to