- tree stmt = value->hvalue.tree.stmt;
- block_stmt_iterator bsi = bsi_for_stmt (stmt);
- tree ref = tree_coverage_counter_ref (tag, base), ref_ptr;
- tree args, call, val;
-
- ref_ptr = force_gimple_operand_bsi (&bsi,
- build_addr (ref, current_function_decl),
- true, NULL_TREE);
- val = prepare_instrumented_value (&bsi, value);
- args = tree_cons (NULL_TREE, ref_ptr,
- tree_cons (NULL_TREE, val,
- NULL_TREE));
- call = build_function_call_expr (tree_one_value_profiler_fn, args);
- bsi_insert_before (&bsi, call, BSI_SAME_STMT);
+ gimple stmt = value->hvalue.stmt;
+ gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
+ tree ref_ptr = tree_coverage_counter_addr (tag, base);
+ gimple call;
+ tree val;
+
+ ref_ptr = force_gimple_operand_gsi (&gsi, ref_ptr,
+ true, NULL_TREE, true, GSI_SAME_STMT);
+ val = prepare_instrumented_value (&gsi, value);
+ call = gimple_build_call (tree_one_value_profiler_fn, 2, ref_ptr, val);
+ gsi_insert_before (&gsi, call, GSI_NEW_STMT);
+ add_abnormal_goto_call_edges (gsi);
+}
+
+
+/* Output instructions as GIMPLE trees for code to find the most
+ common called function in indirect call.
+ VALUE is the call expression whose indirect callee is profiled.
+ TAG is the tag of the section for counters, BASE is offset of the
+ counter position. */
+
+static void
+tree_gen_ic_profiler (histogram_value value, unsigned tag, unsigned base)
+{
+ tree tmp1;
+ gimple stmt1, stmt2, stmt3;
+ gimple stmt = value->hvalue.stmt;
+ gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
+ tree ref_ptr = tree_coverage_counter_addr (tag, base);
+
+ ref_ptr = force_gimple_operand_gsi (&gsi, ref_ptr,
+ true, NULL_TREE, true, GSI_SAME_STMT);
+
+ /* Insert code:
+
+ __gcov_indirect_call_counters = get_relevant_counter_ptr ();
+ __gcov_indirect_call_callee = (void *) indirect call argument;
+ */
+
+ tmp1 = create_tmp_var (ptr_void, "PROF");
+ stmt1 = gimple_build_assign (ic_gcov_type_ptr_var, ref_ptr);
+ stmt2 = gimple_build_assign (tmp1, unshare_expr (value->hvalue.value));
+ stmt3 = gimple_build_assign (ic_void_ptr_var, tmp1);
+
+ gsi_insert_before (&gsi, stmt1, GSI_SAME_STMT);
+ gsi_insert_before (&gsi, stmt2, GSI_SAME_STMT);
+ gsi_insert_before (&gsi, stmt3, GSI_SAME_STMT);