Page MenuHomePhabricator

[LoopPassManager + MemorySSA] Only enable use of MemorySSA for LPMs known to preserve it.
ClosedPublic

Authored by asbirlea on Aug 16 2019, 5:48 PM.

Details

Summary

Add a flag to the FunctionToLoopAdaptor that allows enabling MemorySSA only for the loop pass managers that are known to preserve it.

If an LPM is known to have only loop transforms that *all* preserve MemorySSA, then use MemorySSA if EnableMSSALoopDependency is set.
If an LPM has loop passes that do not preserve MemorySSA, then the flag passed is false, regardless of the value of EnableMSSALoopDependency.

When using a custom loop pass pipeline via passes=..., use keyword loop vs loop-mssa to use MemorySSA in that LPM. If a loop that does not preserve MemorySSA is added while using the loop-mssa keyword, that's an error.

Add the new loop-mssa keyword to a few tests where a difference occurs when enabling MemorySSA.

Diff Detail

Repository
rL LLVM

Event Timeline

asbirlea created this revision.Aug 16 2019, 5:48 PM
chandlerc accepted this revision.Tue, Aug 20, 4:12 PM

Some nits below. LGTM with those fixed!

include/llvm/Analysis/LoopAnalysisManager.h
117 ↗(On Diff #215725)

self is MSSA -> self if MSSA.

include/llvm/Transforms/Scalar/LoopPassManager.h
316 ↗(On Diff #215725)

I would cache the result of AM.getResult<LoopAnalysisManagerFunctionProxy>(F) in a variable -- it's cheap but not free to lookup.

lib/Passes/PassBuilder.cpp
484 ↗(On Diff #215725)

Maybe comment explaining that the second LPM does unrolling and so doesn't preserve MemorySSA?

2002 ↗(On Diff #215725)

Maybe: = (Name == "loop-mssa");?

This revision is now accepted and ready to land.Tue, Aug 20, 4:12 PM
asbirlea updated this revision to Diff 216287.Tue, Aug 20, 4:32 PM
asbirlea marked 4 inline comments as done.

Address comments.

This revision was automatically updated to reflect the committed changes.