Hi Alexander/Richard/Jeff, Thanks for the insightful comments! on 2023/11/10 22:41, Alexander Monakov wrote: > > On Fri, 10 Nov 2023, Richard Biener wrote: > >> On Fri, Nov 10, 2023 at 3:18 PM Alexander Monakov wrote: >>> >>> >>> On Fri, 10 Nov 2023, Richard Biener wrote: >>> >>>>> I'm afraid ignoring debug-only BBs goes contrary to overall var-tracking design: >>>>> DEBUG_INSNs participate in dependency graph so that schedulers can remove or >>>>> mutate them as needed when moving real insns across them. >>>> >>>> Note that debug-only BBs do not exist - the BB would be there even without debug >>>> insns! >>> >>> Yep, sorry, I misspoke when I earlier said >>> >>>>> and cause divergence when passing through a debug-only BB which would not be >>>>> present at all without -g. >>> >>> They are present in the region, but skipped via no_real_insns_p. >>> >>>> So instead you have to handle BBs with just debug insns the same you >>>> handle a completely empty BB. >>> >>> Yeah. There would be no problem if the scheduler never used no_real_insns_p >>> and handled empty and non-empty BBs the same way. >> >> And I suppose it would be OK to do that. Empty BBs are usually removed by >> CFG cleanup so the situation should only happen in rare corner cases where >> the fix would be to actually run CFG cleanup ... > > Yeah, sel-sched invokes 'cfg_cleanup (0)' up front, and I suppose that > may be a preferable compromise for sched-rgn as well. > Inspired by this discussion, I tested the attached patch 1 which is to run cleanup_cfg (0) first in haifa_sched_init, it's bootstrapped and regress-tested on x86_64-redhat-linux and powerpc64{,le}-linux-gnu. Then I assumed some of the current uses of no_real_insns_p won't encounter empty blocks any more, so made a patch 2 with some explicit assertions, but unfortunately I got ICEs during bootstrapping happens in function compute_priorities. I'm going to investigate it further and post more findings, but just heads-up to ensure if this is on the right track. BR, Kewen