This patch assigns discriminators for different callsites within the same BB. This is needed for accurate profile attribution in AutoFDO.
Testing on going. OK for google branches if test pass? Thanks, Dehao Index: gcc/tree-cfg.c =================================================================== --- gcc/tree-cfg.c (revision 201858) +++ gcc/tree-cfg.c (working copy) @@ -781,9 +781,25 @@ assign_discriminators (void) { edge e; edge_iterator ei; + gimple_stmt_iterator gsi; gimple last = last_stmt (bb); location_t locus = last ? gimple_location (last) : UNKNOWN_LOCATION; + location_t curr_locus = UNKNOWN_LOCATION; + for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + { + gimple stmt = gsi_stmt (gsi); + if (gimple_code (stmt) != GIMPLE_CALL) + continue; + if (curr_locus == UNKNOWN_LOCATION || + !same_line_p (curr_locus, gimple_location (stmt))) + curr_locus = gimple_location (stmt); + else + gimple_set_location (stmt, location_with_discriminator ( + gimple_location (stmt), + next_discriminator_for_locus (gimple_location (stmt)))); + } + if (locus == UNKNOWN_LOCATION) continue;