Hi Honza,

> On 2 Feb 2026, at 9:22 pm, Jan Hubicka <[email protected]> wrote:
> 
> External email: Use caution opening links or attachments
> 
> 
>>> Double checked this. Here is the gdb trace for speculative edges are not 
>>> adjacent
>>> We do check e->speculative but in cgraph_edge::make_speculative we do 
>>> create_edge . So isn’t the original edge is still there?
>>> AFIK this can happen even without AutoFDO too.
> 
> If the call is speculated, we should have all edges with speculative
> flag, so I am still bit puzzled how ipa-profile can speculate on
> something that already has speculative call.
> Can you send node->debug() output so we can see if there is a duplicate
> non-speculative edge (which should be caught by the verifier)
> 
> For profile merging I see how we can add speculation to already
> speculative call, so for that the logic should be correct (also
> probabilities should be correctly rescaled by the code), so we likely
> need to fix to keep edges incremental, but still we should understand
> what is going on here.
> 

Here it is:


3944 {
(gdb) p debug ()
balance_nonroot/7 (balance_nonroot)
  Type: function definition analyzed
  Visibility: externally_visible public
  References: decodeFlags_pPage_0/5 (read) decodeFlags_pPage/4 (write) 
cellSizePtrNoPayload/3 (addr) decodeFlags_pPage/4 (write) 
decodeFlags_flagByte/6 (read) btreeParseCellPtr/1 (addr) 
btreeParseCellPtrNoPayload/11 (addr) decodeFlags_pPage/4 (write) 
btreeParseCellPtrIndex/2 (addr) btreeParseCellPtr/1 (addr) (speculative) 
cellSizePtrNoPayload/3 (addr) (speculative) btreeParseCellPtrIndex/2 (addr) 
(speculative)    Referring:    Availability: available
  Profile id: 2029414804
  Function flags: count:6838663652 (auto FDO) first_run:1 body hot
  Called by: sqlite3_step/9 (1073741824 (estimated locally, globally 0 auto 
FDO),1.00 per call)    Calls: btreeParseCellPtrIndex.constprop.0/12 
(speculative) (0 (auto FDO),0.00 per call) cellSizePtrNoPayload/3 (speculative) 
(8017743590 (guessed),1.17 per call) btreeParseCellPtr/1 (speculative) 
(20044358980 (auto FDO),2.93 per call)         indirect simple callsite, not 
calling a known parameter, flags 0, num speculative call targets: 1
       indirect simple callsite, not calling a known parameter, flags 0, num 
speculative call targets: 2



Breakpoint 1, cgraph_node::verify_node (this=0xfffff5a40ff0) at 
/mnt/scratch.grco_devs3/kvivekananda/hierarchical/gcc/gcc/cgraph.cc:3944
3944 {
(gdb) p debug ()
balance_nonroot/7 (balance_nonroot)
  Type: function definition analyzed
  Visibility: externally_visible public
  References: balance_nonroot_pParent/2 (read) balance_nonroot_pParent/2 (addr) 
decodeFlags_pPage/1 (write) cellSizePtrNoPayload/6 (addr) decodeFlags_pPage/1 
(write) btreeParseCellPtrIndex/5 (addr) balance_nonroot_pNew/3 (read) 
balance_nonroot_pNew/3 (addr) balance_nonroot_info/4 (addr) 
balance_nonroot_pParent/2 (addr) cellSizePtrNoPayload/6 (addr) (speculative) 
balance_nonroot_pNew/3 (addr) balance_nonroot_info/4 (addr) 
btreeParseCellPtrIndex/5 (addr) (speculative) balance_nonroot_pParent/2 (addr) 
cellSizePtrNoPayload/6 (addr) (speculative)    Referring:    Availability: 
available
  Profile id: 2029414804
  Function flags: count:6838663652 (auto FDO) first_run:1 body hot
  Called by: sqlite3_step/8 (1073741824 (estimated locally, globally 0 auto 
FDO),1.00 per call)    Calls: cellSizePtrNoPayload.constprop.0/9 (speculative) 
(0 (auto FDO),0.00 per call) btreeParseCellPtrIndex.constprop.0/10 
(speculative) (1179834551162 (auto FDO),172.52 per call) 
cellSizePtrNoPayload.constprop.0/9 (speculative) (29359090506 (auto FDO),4.29 
per call)         indirect simple callsite, not calling a known parameter, 
flags 0, num speculative call targets: 1
       indirect simple callsite, not calling a known parameter, flags 0, num 
speculative call targets: 2


(gdb) p debug ()
balance_nonroot/7 (balance_nonroot)
  Type: function definition analyzed
  Visibility: externally_visible public
  References: decodeFlags_pPage_0/5 (read) decodeFlags_pPage/4 (write) 
cellSizePtrNoPayload/3 (addr) decodeFlags_pPage/4 (write) 
decodeFlags_flagByte/6 (read) btreeParseCellPtr/1 (addr) 
btreeParseCellPtrNoPayload/11 (addr) decodeFlags_pPage/4 (write) 
btreeParseCellPtrIndex/2 (addr) btreeParseCellPtr/1 (addr) (speculative) 
cellSizePtrNoPayload/3 (addr) (speculative) btreeParseCellPtrIndex/2 (addr) 
(speculative)    Referring:    Availability: available
  Profile id: 2029414804
  Function flags: count:6838663652 (auto FDO) first_run:1 body hot
  Called by: sqlite3_step/9 (1073741824 (estimated locally, globally 0 auto 
FDO),1.00 per call)    Calls: btreeParseCellPtrIndex.constprop.0/12 
(speculative) (0 (auto FDO),0.00 per call) cellSizePtrNoPayload/3 (speculative) 
(8017743590 (guessed),1.17 per call) btreeParseCellPtr/1 (speculative) 
(20044358980 (auto FDO),2.93 per call)         indirect simple callsite, not 
calling a known parameter, flags 0, num speculative call targets: 1
       indirect simple callsite, not calling a known parameter, flags 0, num 
speculative call targets: 2
$1 = void


Thanks,
Kugan

Reply via email to