Hi,
I am new to gcc and was trying to implement a gimple pass today. One thing
I tried to do was to make a call_stat that originally calls malloc call
another function like new_malloc. I used gimple_call_set_fndecl and also
did update_stmt (although I don't know exactly what it does). But the final
assembly code still calls the old function. The relevant code is as follows:
------------------------------------
tree malloc_fn_type
= build_function_type_list (void_type_node, size_type_node,
NULL_TREE);
tree new_malloc = build_fn_decl("new_malloc", malloc_fn_type);
struct cgraph_node *alloc_node = my_get_malloc_node();
struct cgraph_edge *edge = NULL;
struct cgraph_node *caller = NULL;
for (edge = alloc_node->callers; edge; edge = edge->next_caller)
{
gimple callStmt = edge->call_stmt;
gimple_call_set_fndecl(callStmt, new_malloc);
update_stmt (callStmt);
}
------------------------------------
The callee was indeed the new_malloc when I use debug_gimple_stmt to print
the call_stmt out, but the generated assembly code or dumped gimble file
still use the old malloc. Thanks in advance!
Thanks,
Tong