// Start stmt duplication on marked function parameters static struct interesting_stmts *search_interesting_calls(struct interesting_stmts *head, gcall *call_stmt) { tree decl; unsigned int i, len; len = gimple_call_num_args(call_stmt); if (len == 0) return head; decl = get_fn_or_fnptr_decl(call_stmt); if (decl == NULL_TREE) return head; for (i = 0; i < len; i++) { tree arg; arg = gimple_call_arg(call_stmt, i); if (is_gimple_constant(arg)) continue; if (skip_types(arg)) continue; if (is_interesting_function(decl, i + 1)) head = search_interesting_stmt(head, call_stmt, arg, i + 1); } return head; }
unsigned int find_arg_number_tree(const_tree arg, const_tree func) { tree var; unsigned int argnum = 1; if (DECL_ARGUMENTS(func) == NULL_TREE) return CANNOT_FIND_ARG; if (TREE_CODE(arg) == SSA_NAME) arg = SSA_NAME_VAR(arg); for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) { if (!operand_equal_p(arg, var, 0) && strcmp(DECL_NAME_POINTER(var), DECL_NAME_POINTER(arg))) continue; if (!skip_types(var)) return argnum; } return CANNOT_FIND_ARG; }
/* This function calls the main recursion function (expand) that duplicates the stmts. Before that it checks the intentional_overflow attribute, * it decides whether the duplication is necessary or not. After expand() it changes the orig node to the duplicated node * in the original stmt (first stmt) and it inserts the overflow check for the arg of the callee or for the return value. */ static struct interesting_stmts *search_interesting_stmt(struct interesting_stmts *head, gimple first_stmt, tree orig_node, unsigned int num) { enum tree_code orig_code; gcc_assert(orig_node != NULL_TREE); if (is_gimple_constant(orig_node)) return head; orig_code = TREE_CODE(orig_node); gcc_assert(orig_code != FIELD_DECL && orig_code != FUNCTION_DECL); gcc_assert(!skip_types(orig_node)); if (check_intentional_asm(first_stmt, num) != MARK_NO) return head; if (SSA_NAME_IS_DEFAULT_DEF(orig_node)) return head; if (skip_asm_cast(orig_node)) return head; return create_interesting_stmts(head, orig_node, first_stmt, num); }