Hi Honza, > On 13 Jan 2026, at 7:29 pm, Jan Hubička <[email protected]> wrote: > > When doing PGO or autofdo we should first read the FDO info and create > speculative edges based on it. > > Later speculation is made by ipa-devirt and ipa-prop. If profile feedback is > available (i.e. edge->speculative is true) we do not want to add another > speculation. First we do not know how to redistribute probabilities and > profile info should be more accurate. > > ipa-devirt already has check > if (e->speculative) > { > if (dump_file) > fprintf (dump_file, "Call is already speculated\n\n"); > stats.nspeculated++; > > /* When dumping see if we agree with speculation. */ > if (!dump_file) > continue; > } > ... > /* This is reached only when dumping; check if we agree or > disagree > with the speculation. */ > if (e->speculative) > { > bool found = false; > for (cgraph_node * likely_target: likely_targets) > if (e->speculative_call_for_target (likely_target)) > { > found = true; > break; > } > if (found) > { > fprintf (dump_file, "We agree with speculation\n\n"); > stats.nok++; > } > else > { > fprintf (dump_file, "We disagree with speculation\n\n"); > stats.nwrong++; > } > continue; > } > > Similarly ipa-prop avoids double-speculation > /* If the edge is already speculated. */ > if (speculative && ie->speculative) > { > if (dump_file) > { > cgraph_edge *e2 = ie->speculative_call_for_target (callee); > if (!e2) > { > if (dump_file) > fprintf (dump_file, "ipa-prop: Discovered call to a " > "speculative target (%s -> %s) but the call is " > "already speculated to different target. " > "Giving up.\n", > ie->caller->dump_name (), callee->dump_name ()); > } > else > { > if (dump_file) > fprintf (dump_file, > "ipa-prop: Discovered call to a speculative target " > "(%s -> %s) this agree with previous speculation.\n", > ie->caller->dump_name (), callee->dump_name ()); > } > } > return NULL; > } > > So I wonder how the additional speculation is created at the first place? > Is it via ipa_merge_profiles?
it's happening in ipa_merge_profiles() during LTO. Thanks, Kugan > > Honza
