Teach LoopRotate to preserve MemorySSA.
Enable tests for correctness, dependency disabled by default.
Details
Diff Detail
- Repository
- rL LLVM
- Build Status
Buildable 22345 Build 22345: arc lint + arc unit
Event Timeline
Moving the MSSA after cloning earlier to avoid the ValueMap invalidation.
Adding another test.
And ping.
lib/Transforms/Scalar/LoopRotation.cpp | ||
---|---|---|
49 | I'm inclined to prefer using the pointer just due to consistency with the other passes + the hope that this won't be Optional forever :). If you or other reviewers strongly prefer passing the Optional, please let me know and I'll update here and in all other passes. |
lib/Transforms/Scalar/LoopRotation.cpp | ||
---|---|---|
49 | I don't have a strong position on this, just throwing it out as an idea. Using an optional does eliminate the ternary operations and would make the code a bit cleaner. How expensive is MemorySSA? I'm not sure we can guarantee it will be available so it might always have to be optional. |
lib/Transforms/Scalar/LoopRotation.cpp | ||
---|---|---|
49 | It can be expensive if not used but it should be cheaper than MemoryDependenceAnalysis the AliasSetTracker. I tried to go ahead and make the change to Optional, but I end up moving the ternary somewhere else: either in the constructor for LoopRotate, or in each call to a BasicBlockUtil (e.g. MergeBlockIntoPredecessor or CriticalEdgeSplittingOptions). In utils, it seems the norm is to use pointers and check for null. Not saying using an Optional wouldn't be better, but it will require having all passes changed to pass Optional as well in the same patch. |
LGTM, but I don't know if I should be the one to sign off on this since I've never touched LoopRotate.
lib/Transforms/Scalar/LoopRotation.cpp | ||
---|---|---|
49 | Yeah, that sounds fine to me. I'm fine with the way this is. Was just wondering if Optional might make it cleaner, but it sounds like that would overly complicate this patch and is better left for a later change. Thanks! |
Minor comments on test case, otherwise this LGTM. Feel free to submit with a minimized test case.
test/Transforms/LoopRotate/preserve-mssa.ll | ||
---|---|---|
131–137 | Can this test case be minimized some to remove all these atributes and other unnecessary IR boilerplate? |
llvm/trunk/lib/Transforms/Utils/LoopRotationUtils.cpp | ||
---|---|---|
682–687 ↗ | (On Diff #171013) | Is this actually correct? { if (MSSAU && VerifyMemorySSA) MSSAU->getMemorySSA()->verifyMemorySSA(); LoopRotate LR(Threshold, LI, TTI, AC, DT, SE, MSSAU, SQ, RotationOnly, IsUtilMode); bool Changed = LR.processLoop(L); if (MSSAU && VerifyMemorySSA) MSSAU->getMemorySSA()->verifyMemorySSA(); return Changed; } |
llvm/trunk/lib/Transforms/Utils/LoopRotationUtils.cpp | ||
---|---|---|
682–687 ↗ | (On Diff #171013) | Yeah the code in the patch doesn't look right, given that the actual modifications happen in processLoop. |
llvm/trunk/lib/Transforms/Utils/LoopRotationUtils.cpp | ||
---|---|---|
682–687 ↗ | (On Diff #171013) | It's correct, but unnecessary. Thank you for noticing! |
llvm/trunk/lib/Transforms/Utils/LoopRotationUtils.cpp | ||
---|---|---|
682–687 ↗ | (On Diff #171013) | I dropped the verify calls there in 9ea0d8c38fc5 |
Why not just pass the Optional?