mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
LoopRotate: don't rotate loops where the header block branches to a dead-end block.
Incomplete liveranges in the dead-end exit block can cause a missing adjacent phi-argument for a re-borrow if there is a borrow-scope is in the loop. But even when we have complete lifetimes, it's probably not worth rotating a loop where the header block branches to a dead-end block. Fixes a SIL verifier crash
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include "swift/SIL/SILBuilder.h"
|
||||
#include "swift/SIL/SILInstruction.h"
|
||||
#include "swift/SILOptimizer/Analysis/Analysis.h"
|
||||
#include "swift/SILOptimizer/Analysis/DeadEndBlocksAnalysis.h"
|
||||
#include "swift/SILOptimizer/Analysis/DominanceAnalysis.h"
|
||||
#include "swift/SILOptimizer/Analysis/LoopAnalysis.h"
|
||||
#include "swift/SILOptimizer/PassManager/Passes.h"
|
||||
@@ -374,6 +375,15 @@ static bool rotateLoop(SILLoop *loop, DominanceInfo *domInfo,
|
||||
return false;
|
||||
}
|
||||
|
||||
// Incomplete liveranges in the dead-end exit block can cause a missing adjacent
|
||||
// phi-argument for a re-borrow if there is a borrow-scope is in the loop.
|
||||
// But even when we have complete lifetimes, it's probably not worth rotating
|
||||
// a loop where the header block branches to a dead-end block.
|
||||
auto *deBlocks = pm->getAnalysis<DeadEndBlocksAnalysis>()->get(exit->getParent());
|
||||
if (deBlocks->isDeadEnd(exit)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// We don't want to rotate such that we merge two headers of separate loops
|
||||
// into one. This can be turned into an assert again once we have guaranteed
|
||||
// preheader insertions.
|
||||
|
||||
Reference in New Issue
Block a user