return true;
}
-/* Return true if the stringop CALL with FNDECL shall be profiled. */
+/* Return true if the stringop CALL with FNDECL shall be profiled.
+ SIZE_ARG be set to the argument index for the size of the string
+ operation.
+*/
static bool
-interesting_stringop_to_profile_p (tree fndecl, gimple call)
+interesting_stringop_to_profile_p (tree fndecl, gimple call, int *size_arg)
{
enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl);
{
case BUILT_IN_MEMCPY:
case BUILT_IN_MEMPCPY:
+ *size_arg = 2;
return validate_gimple_arglist (call, POINTER_TYPE, POINTER_TYPE,
INTEGER_TYPE, VOID_TYPE);
case BUILT_IN_MEMSET:
+ *size_arg = 2;
return validate_gimple_arglist (call, POINTER_TYPE, INTEGER_TYPE,
INTEGER_TYPE, VOID_TYPE);
case BUILT_IN_BZERO:
+ *size_arg = 1;
return validate_gimple_arglist (call, POINTER_TYPE, INTEGER_TYPE,
VOID_TYPE);
default:
basic_block cond_bb, icall_bb, vcall_bb, join_bb;
edge e_ci, e_cv, e_iv, e_ij, e_vj;
gimple_stmt_iterator gsi;
+ tree fndecl;
+ int size_arg;
+
+ fndecl = gimple_call_fndecl (vcall_stmt);
+ if (!interesting_stringop_to_profile_p (fndecl, vcall_stmt, &size_arg))
+ gcc_unreachable();
cond_bb = gimple_bb (vcall_stmt);
gsi = gsi_for_stmt (vcall_stmt);
- vcall_size = gimple_call_arg (vcall_stmt, 2);
+ vcall_size = gimple_call_arg (vcall_stmt, size_arg);
optype = TREE_TYPE (vcall_size);
tmpv = create_tmp_var (optype, "PROF");
gsi_insert_before (&gsi, cond_stmt, GSI_SAME_STMT);
icall_stmt = gimple_copy (vcall_stmt);
- gimple_call_set_arg (icall_stmt, 2, icall_size);
+ gimple_call_set_arg (icall_stmt, size_arg, icall_size);
gsi_insert_before (&gsi, icall_stmt, GSI_SAME_STMT);
/* Fix CFG. */
unsigned int dest_align, src_align;
gcov_type prob;
tree tree_val;
+ int size_arg;
if (gimple_code (stmt) != GIMPLE_CALL)
return false;
if (!fndecl)
return false;
fcode = DECL_FUNCTION_CODE (fndecl);
- if (!interesting_stringop_to_profile_p (fndecl, stmt))
+ if (!interesting_stringop_to_profile_p (fndecl, stmt, &size_arg))
return false;
- if (fcode == BUILT_IN_BZERO)
- blck_size = gimple_call_arg (stmt, 1);
- else
- blck_size = gimple_call_arg (stmt, 2);
+ blck_size = gimple_call_arg (stmt, size_arg);
if (TREE_CODE (blck_size) == INTEGER_CST)
return false;
tree blck_size;
tree dest;
enum built_in_function fcode;
+ int size_arg;
if (gimple_code (stmt) != GIMPLE_CALL)
return;
return;
fcode = DECL_FUNCTION_CODE (fndecl);
- if (!interesting_stringop_to_profile_p (fndecl, stmt))
+ if (!interesting_stringop_to_profile_p (fndecl, stmt, &size_arg))
return;
dest = gimple_call_arg (stmt, 0);
- if (fcode == BUILT_IN_BZERO)
- blck_size = gimple_call_arg (stmt, 1);
- else
- blck_size = gimple_call_arg (stmt, 2);
+ blck_size = gimple_call_arg (stmt, size_arg);
if (TREE_CODE (blck_size) != INTEGER_CST)
{