diff options
Diffstat (limited to 'gcc/tree-cfg.cc')
-rw-r--r-- | gcc/tree-cfg.cc | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc index c388344..39aeb16 100644 --- a/gcc/tree-cfg.cc +++ b/gcc/tree-cfg.cc @@ -1132,8 +1132,8 @@ assign_discriminators (void) { 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)) { @@ -1149,8 +1149,8 @@ assign_discriminators (void) 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. */ @@ -1160,16 +1160,27 @@ assign_discriminators (void) 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++; } |