Adding a conditional statement in GCC

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello experts,
I have added a pass in GCC.
Here I am adding a conditional statement
Initially my code had both operands of the conditional statement as
local variables and it worked fine.
Then I replaced the local variable with a global variable and I get the error:
Internal compiler error in gimple_set_vuse: gimple.h 1504

Am using gcc4.7.0

My code is as follows:

tree var_decl = NULL;

static unsigned int gccwk_main(void)
{

   basic_block true_bb, join_bb;

   //COND WITH TEMP VAR
   tree tmp1, tmpv;
   gimple cond_stmt;
   tree int_assign;
   gimple assign;
   gimple cond_assign;
   edge e_cd, e_di, e_ci;

   basic_block bb_start = ENTRY_BLOCK_PTR->next_bb;
   gimple_stmt_iterator gsi = gsi_start_bb(bb_start);


   if (!var_decl) {
       var_decl = build_decl(input_location, VAR_DECL,
get_identifier("aa_glob"),integer_type_node);
  }
   TREE_STATIC(var_decl) = 1;
   rest_of_decl_compilation(var_decl,1,0);
   DECL_INITIAL(var_decl) = build_int_cst(integer_type_node, 1);

   tmp1 = build_int_cst(integer_type_node,1);
   cond_stmt = gimple_build_cond (EQ_EXPR,var_decl,tmp1,NULL_TREE, NULL_TREE);
   gsi_insert_before_without_update(&gsi,cond_stmt, GSI_SAME_STMT);

   cond_assign = gimple_build_assign(var_decl, tmp1);
   gsi_insert_before(&gsi,cond_assign,GSI_SAME_STMT);


   // Fix CFG
   e_cd = split_block(bb_start,cond_stmt);
   true_bb = e_cd->dest;

   e_di = split_block(true_bb,cond_assign);
   join_bb = e_di->dest;

   e_cd->flags = (e_cd->flags & ~EDGE_FALLTHRU) | EDGE_TRUE_VALUE;
   e_di->flags = e_di->flags & EDGE_FALLTHRU;

   e_ci = make_edge(bb_start,join_bb, EDGE_FALSE_VALUE);
}

When I just add the assignment statement, it builds fine.
But with the global variable as an operand in the conditional
statement, I am getting the error.  I am not very familliar with the
SSA passes which is where I think vdef and vuse come into the picture.
Is there something I am missing?

Thanks



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux