This is an archive of the discontinued LLVM Phabricator instance.

[GuardWidening] Preserve MemorySSA
ClosedPublic

Authored by nikic on Aug 19 2021, 9:49 AM.

Details

Summary

As reported on https://bugs.llvm.org/show_bug.cgi?id=51020, the guard widening loop pass doesn't preserve MemorySSA, so it can no longer be scheduled in the same loop pass manager as LICM. However, the loop-schedule.ll test indicates that this is supposed to work.

Fix this by preserving MemorySSA if available, as this seems to be trivial in this case (we only need to drop the memory access for the guards).

Diff Detail

Event Timeline

nikic created this revision.Aug 19 2021, 9:49 AM
nikic requested review of this revision.Aug 19 2021, 9:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 19 2021, 9:49 AM
nikic updated this revision to Diff 367535.Aug 19 2021, 9:55 AM

Mark as preserved in NPM (it's not part of getLoopPassPreservedAnalyses).

asbirlea added inline comments.Aug 19 2021, 10:20 AM
llvm/lib/Transforms/Scalar/GuardWidening.cpp
772–773

Does it make sense to get the cached analysis in the Function pass if it exists and preserve it too in that case?

823–824

Why not also preserve in the Function pass if MemorySSA is available?

reames accepted this revision.Aug 19 2021, 10:24 AM

LGTM for the loop passes. As with Alina, I'd encourage you to do the function passes too for completeness. Feel free to either do a separate change for that, or roll it into this commit.

This revision is now accepted and ready to land.Aug 19 2021, 10:24 AM
nikic updated this revision to Diff 367553.Aug 19 2021, 10:56 AM

Preserve MSSA in function pass as well.

asbirlea accepted this revision.Aug 19 2021, 11:02 AM

Thanks, LG with one comment to address.

llvm/lib/Transforms/Scalar/GuardWidening.cpp
783–784

PA.preserve<MemorySSAAnalysis>();

This revision was landed with ongoing or failed builds.Aug 19 2021, 11:25 AM
This revision was automatically updated to reflect the committed changes.
nikic marked an inline comment as done.