https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61776
--- Comment #7 from davidxl <xinliangli at gmail dot com> --- (In reply to wmi from comment #6) > (In reply to davidxl from comment #5) > > (In reply to wmi from comment #4) > > > Can we move the pure/const resetting loop to an earlier place: inside > > > branch_prob , after instrument_edges and before gsi_commit_edge_inserts > > > (where stmt_ends_bb_p is checked), so that gsi_commit_edge_inserts() > > > which > > > changes cfg could take reset const/pure flags into consideration? > > > > Sounds plausible. Have you tried it? > > > > David > > I just tried but found it was not very easy. > > FOR_EACH_DEFINED_FUNCTION (node) { > execute_fixup_cfg() and cleanup_tree_cfg() > branch_prob() > } > > For the above loop, branch_prob is called one by one for each defined func. > Because a func could possibly call any other funcs on the cgraph, we need to > reset the const/pure flags for every defined func before any branch_prob() > is called, so we cannot put the const/pure reset code inside branch_prob(). > As you noted below, resetting the flag before branch_prob will lead to cfg mismatch between instr and profile-use build. David > We also cannot move the const/pure reset loop before the branch_prob() loop, > because execute_fixup_cfg will use const/pure flags to generate different > cfg. If we put the const/pure reset code before the branch_prob() loop, the > const/pure reset code should only be executed in intrumentation phase, not > in annotation phase, so that we may get different cfg between intrumentation > and annotation. > > Wei.