LoopFlatten does preserve loop analyses (DT, LI and SCEV), but currently doesn't mark them as preserved in the NewPM (the are marked as preserved in the LegacyPM). I think this doesn't really have an effect in the end because the loop pass adaptor will just assume they're preserved anyway, but let's be explicit about this for the sake of clarity.
Details
Diff Detail
Event Timeline
llvm/lib/Transforms/Scalar/LoopFlatten.cpp | ||
---|---|---|
665 | separately, this looks like it's not telling LPMUpdater that a loop has been deleted which is an issue |
llvm/lib/Transforms/Scalar/LoopFlatten.cpp | ||
---|---|---|
665 | I think this is actually fine, because this is a LoopNest pass, in which case LPMUpdater only has to be informed about the removal of top-level loops. |
llvm/lib/Transforms/Scalar/LoopFlatten.cpp | ||
---|---|---|
665 | If we delete a Loop, then allocate another Loop at the same address, we may fetch an invalid cached analysis later on. LPMUpdater::markLoopAsDeleted() clears cached analyses for that Loop. |
llvm/lib/Transforms/Scalar/LoopFlatten.cpp | ||
---|---|---|
665 | After looking a bit more closely, here's the problem:
However, as the pass doesn't control whether it gets used in LoopNestMode or not, this means that either you are forbidden from invalidating other loops (only LoopNest passes scheduled) or you are required to invalidate other loops (non-LoopNest passes scheduled as well). Something seems broken here. Here's my test patch: https://gist.github.com/nikic/1a65b8cb384bb7e00084279255b93e65 It will currently assert for standalone uses of -loop-flatten because those use LoopNestMode. |
separately, this looks like it's not telling LPMUpdater that a loop has been deleted which is an issue