I have to do some GIMPLE_CALL Statement manipulations. This GIMPLE_CALL will have two arguments, e.g: foo(a,b). My goal is change this method to a different method having THREE arguments e.g. zoo(a,b,c)
In my current approach, GCC crashes during while compiling a sample source program.
My code works when all I do is replace the method name (i.e. not changing the argument numbers).
Also, I was not able to find any methods dedicated to adding/removing argument numbers for a GIMPLE_CALL. Which leads me to believe that it might not be the right approach.
Code:
//Getting the current number of Call Arguments from target GIMPLE
//statememt
unsigned num_of_ops = gimple_call_num_args(stmt);
//Replace the method name to a new Method
gimple_call_set_fndecl(stmt, new_method);
//We need to increment total number of call arguments by 1
//Total numer of arguments are, Number of CALL Arguments + 3
//You can confirm this in definitions of gimple_call_num_args() and
//gimple_call_set_arg()
gimple_set_num_ops(stmt,num_of_ops+3+1);
//Add the new argument
gimple_call_set_arg(stmt, num_of_ops, third_argument);
update_stmt (stmt);