Hi all, I'm needed to create a plugin that analyse the variables in the input program and locks some variables as needed. For this to happen, i should be able to create and call a locking function dynamically during my inserted pass using the plugin that i'm creating. I'm inserting the plugin pass during optimization passes and using the basic block iterators and gimple statement iterators to traverse through the cfg created and trying to insert my function using gimple_insert_after function call. Inorder to use this function, i need to obtain the tree equivalent of the required function call. I'm struck at creating the equivalent tree node for creating a function call. Below is my code that creates a node for "fork()" function call. It is inserting the gimple statement using gimple_insert_after function, however compiler crashes after executing my pass saying "internal compiler error: in cgraph_create_edge, at cgraph.c:925" which is a gcc assertion. The code below shows my node creation and insertion for a function call. static unsigned int ctla_gcc_plugin(void) { basic_block bb; gimple_stmt_iterator gsi; int block_index = 0, stmt_index = 0, i; tree op; tree param_list; //param_list is of type tree. Similarly others. tree param_type_list; tree fntype; tree fndecl; // Consider it as a global value. param_list = NULL_TREE; param_type_list = tree_cons(NULL_TREE, void_type_node, NULL_TREE); fntype = build_function_type(integer_type_node, param_type_list); fndecl = build_decl(DECL_SOURCE_LOCATION(current_function_decl), FUNCTION_DECL, get_identifier("fork"), fntype); DECL_EXTERNAL(fndecl) = 1; TREE_PUBLIC(fndecl) = 1; TREE_STATIC(fndecl) = 0; DECL_ARGUMENTS(fndecl) = param_list; DECL_RESULT(fndecl) = build_decl(DECL_SOURCE_LOCATION(current_function_decl), RESULT_DECL, NULL_TREE, integer_type_node); DECL_CONTEXT( DECL_RESULT( fndecl)) = fndecl; DECL_INITIAL( fndecl) = error_mark_node; gimple fcall = gimple_build_call(fndecl, 0); FOR_EACH_BB (bb) { for(gsi = gsi_start_bb (bb); !gsi_end_p(gsi); gsi_next(&gsi)) { gimple stmt = gsi_stmt(gsi); if(!gsi_one_before_end_p(gsi)) gsi_insert_after(&gsi, fcall, GSI_NEW_STMT); } } return 1; } I'm inserting this pass after pass_build_cfg.. it's inserting fork() calls at respective places in the dump file created for this plugin pass. Please help me find out the mistake if anything i'm doing with this node creation for function call. Thanks, Ajay