https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118581
Bug ID: 118581
Summary: auto_profile can't annotate bb with all debug_stmt
which assigned value with constant
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: gcov-profile
Assignee: unassigned at gcc dot gnu.org
Reporter: liuhongt at gcc dot gnu.org
Target Milestone: ---
The source code is like
if( TEST_FLAG_SWEEP( srcGrid, ACCEL )) {
ux = 0.005;
uy = 0.002;
uz = 0.000;
}
The afdo gimple ir is like
<bb 6> [count: 0]:
# DEBUG BEGIN_STMT
# DEBUG ux => 5.00000000000000010408340855860842566471546888351440429688e-3
# DEBUG BEGIN_STMT
# DEBUG uy => 2.00000000000000004163336342344337026588618755340576171875e-3
# DEBUG BEGIN_STMT
# DEBUG uz => 0.0
according to autofdo profiling, the bb is executed.
gcov_dump:
...
68: 1103467
69: 17189: the corresponding source code level count
70: 17189: Ditto.
71: 17189: Ditto.
74: 1086389
76: 1103571
...
But afdo_set_bb_count ignore all debug stmts
/* For a given BB, set its execution count. Attach value profile if a stmt
is not in PROMOTED, because we only want to promote an indirect call once.
Return TRUE if BB is annotated. */
static bool
afdo_set_bb_count (basic_block bb, const stmt_set &promoted)
{
gimple_stmt_iterator gsi;
edge e;
edge_iterator ei;
gcov_type max_count = 0;
bool has_annotated = false;
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
{
count_info info;
gimple *stmt = gsi_stmt (gsi);
if (gimple_clobber_p (stmt) || is_gimple_debug (stmt))
continue;
if (afdo_source_profile->get_count_info (stmt, &info))
{
if (info.count > max_count)
max_count = info.count;
has_annotated = true;
if (info.targets.size () > 0
&& promoted.find (stmt) == promoted.end ())
afdo_vpt (&gsi, info.targets, false);
}
}
if (!has_annotated)
return false;