gphi *phi = gpi.phi ();
inline_stack stack;
+ /* We do not assign discriminators to PHI nodes.
+ In case we every start using them, we wil need to
+ update tree-cfg.cc::assign_discriminators. */
+ gcc_assert (gimple_location (phi) == UNKNOWN_LOCATION);
get_inline_stack_in_node (gimple_location (phi), &stack, node);
count_info *info = lookup_count (gimple_location (phi), stack, node);
- if (info)
- counts.add (info);
+ gcc_assert (!info);
dump_stmt (phi, info, NULL, stack);
counts.add (info);
for (edge e : bb->succs)
{
location_t prev_loc = UNKNOWN_LOCATION, prev_replacement = UNKNOWN_LOCATION;
/* Traverse the basic block, if two function calls within a basic block
- are mapped to the same line, assign a new discriminator because a call
- stmt could be a split point of a basic block. */
+ are mapped to the same line, assign a new discriminator because a call
+ stmt could be a split point of a basic block. */
for (gimple_stmt_iterator gsi = gsi_start_bb (bb);
!gsi_end_p (gsi); gsi_next (&gsi))
{
prev_replacement = assign_discriminator (loc, bb_id, map);
gimple_set_location (stmt, prev_replacement);
}
- /* Break basic blocks after each call. This is requires so each
- call site has unque discriminator.
+ /* Break basic blocks after each call. This is required so each
+ call site has unique discriminator.
More correctly, we can break after each statement that can possibly
terinate execution of the basic block, but for auto-profile this
precision is probably not useful. */
bb_id++;
}
}
- /* IF basic block has multiple sucessors, consdier every edge as a separate
- block. */
+ /* If basic block has multiple sucessors, consdier every edge as a
+ separate block. */
if (!single_succ_p (bb))
bb_id++;
for (edge e : bb->succs)
- if (e->goto_locus != UNKNOWN_LOCATION)
- {
+ {
+ if (e->goto_locus != UNKNOWN_LOCATION)
e->goto_locus = assign_discriminator (e->goto_locus, bb_id, map);
- bb_id++;
- }
+ for (gphi_iterator gpi = gsi_start_phis (bb);
+ !gsi_end_p (gpi); gsi_next (&gpi))
+ {
+ gphi *phi = gpi.phi ();
+ location_t phi_loc
+ = gimple_phi_arg_location_from_edge (phi, e);
+ if (phi_loc == UNKNOWN_LOCATION)
+ continue;
+ gimple_phi_arg_set_location
+ (phi, e->dest_idx, assign_discriminator (phi_loc, bb_id, map));
+ }
+ bb_id++;
+ }
bb_id++;
}