我必须做一些 GIMPLE_CALL 语句操作。这个 GIMPLE_CALL 将有两个参数,例如:foo(a,b)。我的目标是将此方法更改为具有三个参数的不同方法,例如 zoo(a,b,c)
在我目前的方法中,GCC 在编译示例源程序时崩溃。
当我所做的只是替换方法名称(即不更改参数编号)时,我的代码就可以工作。
此外,我找不到任何专用于为 GIMPLE_CALL 添加/删除参数编号的方法。这让我相信这可能不是正确的方法。
代码:
//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);