https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94421

--- Comment #3 from otcmaf <xuemaosheng at huawei dot com> ---
(In reply to Andrew Pinski from comment #1)
> change_spec_dep_to_hard is called from two places:
> * in sched_analyze_insn, it is conditionalized on (current_sched_info->flags
> & DO_SPECULATION) already.
> * in update_dep, it is conditionalized on if was_spec was true and if no
> longer dep_spec_p (dep) is true.
> 
> dep_spec_p is true when current_sched_info->flags & DO_SPECULATION is true
> (or when a few other cases.
> 
> But DEP_STATUS (dep) can only be SPECULATIVE when current_sched_info->flags
> & DO_SPECULATION is true.
> 
> So If anything you could in theory put an assert there for
> current_sched_info->flags & DO_SPECULATION and get the same effect if I read
> the code correctly.


In our case, the compile bug is called from function update_dep.  Variable
was_spec is true, dep_spec_p (dep) is false, current_sched_info->flags &
DO_SPECULATION is zero, DEP_STATUS (dep) & SPECULATIVE is zero.  So in this
case, we should avoid to free the memory of spec_dependency_cache.

1191      if (was_spec && !dep_spec_p (dep))
1192        /* The old dep was speculative, but now it isn't.  */
1193        change_spec_dep_to_hard (sd_it);
1194    

(gdb) p was_spec
$11 = true
(gdb) p dep_spec_p (dep)
$12 = false
(gdb) p current_sched_info->flags & DO_SPECULATION
$13 = 0
(gdb) p DEP_STATUS (dep) & SPECULATIVE
$14 = 0
(gdb) p !dep_spec_p (dep)
$15 = true

Reply via email to