Optimizer: fix an ownership violation when duplicating loops

If a guaranteed value is used in a dead-end exit block and the enclosing value is _not_ destroyed in this block, we end up missing the enclosing value as phi-argument after duplicating the loop.
TODO: once we have complete lifetimes we can remove this check again.

rdar://159125605
This commit is contained in:
Erik Eckstein
2025-08-28 18:40:23 +02:00
parent 5f20a5b8b5
commit 9081edd4c2
5 changed files with 62 additions and 11 deletions

View File

@@ -28,6 +28,7 @@ class SILInstruction;
class SILLoop;
class DominanceInfo;
class SILLoopInfo;
class DeadEndBlocks;
/// Canonicalize the loop for rotation and downstream passes.
///
@@ -40,7 +41,7 @@ bool canonicalizeAllLoops(DominanceInfo *DT, SILLoopInfo *LI);
/// Check whether it is safe to duplicate this instruction when duplicating
/// this loop by unrolling or versioning.
bool canDuplicateLoopInstruction(SILLoop *L, SILInstruction *Inst);
bool canDuplicateLoopInstruction(SILLoop *L, SILInstruction *Inst, DeadEndBlocks *deb);
/// A visitor that visits loops in a function in a bottom up order. It only
/// performs the visit.