This is an archive of the discontinued LLVM Phabricator instance.

[PassBuilder] Use loop-mssa for licm
ClosedPublic

Authored by nikic on Aug 16 2021, 12:07 PM.

Details

Summary

Currently specifying -licm or -passes=licm will implicitly create -passes=loop(licm). This does not match the intended default (used by the legacy PM and by the default pipeline) of using the MemorySSA-based licm implementation. As I plan to drop the non-MSSA implementation, this will stop working entirely...

This special-cases licm to create a loop-mssa manager instead. At this point it's still possible to use -passes='loop(licm)' to opt into the AST-based implementation.

Diff Detail

Event Timeline

nikic created this revision.Aug 16 2021, 12:07 PM
nikic requested review of this revision.Aug 16 2021, 12:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 16 2021, 12:07 PM
nikic added inline comments.Aug 16 2021, 12:08 PM
llvm/lib/Passes/PassBuilder.cpp
2422

I dropped this code because I found it confusing, and it's effectively dead: We call isFunctionPassName() first, which will already handle these.

aeubanks accepted this revision.Aug 17 2021, 9:32 AM

hmm, this is super hacky, but I can't think of a better way

at some point should we enable MSSA by default for loop passes?

This revision is now accepted and ready to land.Aug 17 2021, 9:32 AM

at some point should we enable MSSA by default for loop passes?

Not in general. There are basically three types of loop passes: Those that don't preserve MSSA (using them with loop-mssa is illegal), those that preserve but don't use MSSA (using them with loop-mssa only makes sense as part of a pipeline) and those that can use MSSA (those probably should use loop-mssa by default).

This revision was landed with ongoing or failed builds.Aug 17 2021, 12:23 PM
This revision was automatically updated to reflect the committed changes.

After some bisection, it appears this change broke llvm/test/Transforms/GuardWidening/loop-schedule.ll. The NewPM half of that test fails with:

Assertion failed: (AL->size() == ActualAccesses.size() && "We don't have the same number of accesses in the block as on the " "access list"), function verifyOrderingDominationAndDefUses, file MemorySSA.cpp, line 2018.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /Users/jroelofs/llvm-upstream/build/bin/opt -S -passes=licm,guard-widening,licm -debug-pass-manager
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  opt                      0x0000000108c3d587 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 39
1  opt                      0x0000000108c3c318 llvm::sys::RunSignalHandlers() + 248
2  opt                      0x0000000108c3dbd0 SignalHandler(int) + 288
3  libsystem_platform.dylib 0x00007fff204dfd7d _sigtramp + 29
4  libsystem_platform.dylib 000000000000000000 _sigtramp + 18446603339974181536
5  libsystem_c.dylib        0x00007fff203ef411 abort + 120
6  libsystem_c.dylib        0x00007fff203ee7e8 err + 0
7  opt                      0x0000000109809d13 llvm::MemorySSA::verifyOrderingDominationAndDefUses(llvm::Function&) const (.cold.8) + 35
8  opt                      0x0000000107c54da9 llvm::MemorySSA::verifyOrderingDominationAndDefUses(llvm::Function&) const + 2841
9  opt                      0x0000000107c54272 llvm::MemorySSA::verifyMemorySSA() const + 18
10 opt                      0x00000001089593e0 llvm::sinkRegion(llvm::DomTreeNodeBase<llvm::BasicBlock>*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::BlockFrequencyInfo*, llvm::TargetLibraryInfo*, llvm::TargetTransformInfo*, llvm::Loop*, llvm::AliasSetTracker*, llvm::MemorySSAUpdater*, llvm::ICFLoopSafetyInfo*, llvm::SinkAndHoistLICMFlags&, llvm::OptimizationRemarkEmitter*, llvm::Loop*) + 10640
11 opt                      0x0000000108956196 (anonymous namespace)::LoopInvariantCodeMotion::runOnLoop(llvm::Loop*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::BlockFrequencyInfo*, llvm::TargetLibraryInfo*, llvm::TargetTransformInfo*, llvm::ScalarEvolution*, llvm::MemorySSA*, llvm::OptimizationRemarkEmitter*, bool) + 5862
12 opt                      0x0000000108954968 llvm::LICMPass::run(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) + 152

https://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-expensive/20177/

Would you mind taking a look?

nikic added a comment.Aug 19 2021, 3:14 PM

@jroelofs This should be fixed by D108386.