You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Loop opts should not be recomputing pred lists from scratch #49030
Several loop opts end up calling fgUpdateChangedFlowGraph when done, and this calls fgComputePreds, leaking previous pred lists and losing the profile weights carefully calculated earlier.
This seems wrong-headed; I think those optimizations should maintain pred lists and not rebuild them.
Removing the call to fgComputePreds shows a number of places in loop opts where pred lists are not properly updated, and more downstream failures from places unknown where BBF_JMP_TARGET is not properly set, so cleaning this up may be nontrivial.
We used to always need to rebuild pred lists after renumbering blocks due to pred list ordering being dependent on block number, so presumably phases knew they could be sloppy and things would get cleaned up later. But with the new ensurePredListOrder()/reorderPredList(), that's no longer required, as renumbering also keeps preds lists properly ordered.
Maybe we need a pred list checker that runs fgComputePreds but doesn't update the IR, and compares the results against the existing flowgraph (does such a thing exist already?), then fgUpdateChangedFlowGraph can call the checker to verify that no preds need to be updated, and if that check fails, we know which phase caused the problem.
I get post-phase check failures about missing preds if I remove the call to fgComputePreds so I think the current checking may be sufficient?
The missing jump target flags might be harder to track down; it's not clear if we have agreement about when the jump target bit needs to be set, and we don't seem to check this post phase. It is checked in codegen.
I'm thinking we should get rid of BBF_JMP_TARGET entirely and replace its use by BBF_HAS_LABEL for marking blocks that need labels. Then, add a pass over the blocks just before codegen that sets BBF_HAS_LABEL on all necessary blocks, like genPrepForEHCodegen does for EH constructs. Then, we wouldn't need to set and maintain the BBF_JMP_TARGET throughout compilation. We may lose a couple uninteresting asserts but would greatly simplify block maintenance.
Activity
AndyAyersMS commentedon Mar 2, 2021
See notes in #48850 for some context.
AndyAyersMS commentedon Mar 2, 2021
cc @BruceForstall
BruceForstall commentedon Mar 3, 2021
We used to always need to rebuild pred lists after renumbering blocks due to pred list ordering being dependent on block number, so presumably phases knew they could be sloppy and things would get cleaned up later. But with the new
ensurePredListOrder()/reorderPredList(), that's no longer required, as renumbering also keeps preds lists properly ordered.Maybe we need a pred list checker that runs
fgComputePredsbut doesn't update the IR, and compares the results against the existing flowgraph (does such a thing exist already?), thenfgUpdateChangedFlowGraphcan call the checker to verify that no preds need to be updated, and if that check fails, we know which phase caused the problem.AndyAyersMS commentedon Mar 3, 2021
I get post-phase check failures about missing preds if I remove the call to
fgComputePredsso I think the current checking may be sufficient?The missing jump target flags might be harder to track down; it's not clear if we have agreement about when the jump target bit needs to be set, and we don't seem to check this post phase. It is checked in codegen.
BruceForstall commentedon Apr 13, 2021
I'm thinking we should get rid of
BBF_JMP_TARGETentirely and replace its use byBBF_HAS_LABELfor marking blocks that need labels. Then, add a pass over the blocks just before codegen that setsBBF_HAS_LABELon all necessary blocks, likegenPrepForEHCodegendoes for EH constructs. Then, we wouldn't need to set and maintain theBBF_JMP_TARGETthroughout compilation. We may lose a couple uninteresting asserts but would greatly simplify block maintenance.AndyAyersMS commentedon Apr 13, 2021
Sounds good to me.
BruceForstall commentedon Apr 20, 2021
BBF_JMP_TARGETwas removed with #51208Don't recompute preds lists during loop cloning
7 remaining items
JIT: maintain pred lists during loop unrolling
JIT: maintain pred lists during loop unrolling (#80625)
JIT: fix remaining phases that were rebuilding pred edges
JIT: fix remaining phases that were rebuilding pred edges (#80769)
JIT: fix remaining phases that were rebuilding pred edges (dotnet#80769)