diff options
author | Orlando Cazalet-Hyams <orlando.hyams@sony.com> | 2025-05-07 16:01:53 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-07 16:01:53 +0100 |
commit | 960221623f54b87c0ce786d551111573810c8ac8 (patch) | |
tree | 91f75510bf83f7e45cc9686d448417874ff4489a /llvm/lib/Transforms/Scalar/JumpThreading.cpp | |
parent | 461ba2db5d15793d18a5c18ce417c30e335602cc (diff) | |
download | llvm-960221623f54b87c0ce786d551111573810c8ac8.zip llvm-960221623f54b87c0ce786d551111573810c8ac8.tar.gz llvm-960221623f54b87c0ce786d551111573810c8ac8.tar.bz2 |
[KeyInstr][JumpThreading] Remap atoms duping bb with cond br on phi into pred (#133488)
See test for details.
Diffstat (limited to 'llvm/lib/Transforms/Scalar/JumpThreading.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/JumpThreading.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp index 31f6f38..1d5d7cc 100644 --- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp +++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp @@ -2699,6 +2699,9 @@ bool JumpThreadingPass::duplicateCondBranchOnPHIIntoPred( // PredBB block. Evaluate PHI nodes in BB. ValueToValueMapTy ValueMapping; + // Remember the position before the inserted instructions. + auto RItBeforeInsertPt = std::next(OldPredBranch->getReverseIterator()); + BasicBlock::iterator BI = BB->begin(); for (; PHINode *PN = dyn_cast<PHINode>(BI); ++BI) ValueMapping[PN] = PN->getIncomingValueForBlock(PredBB); @@ -2718,6 +2721,8 @@ bool JumpThreadingPass::duplicateCondBranchOnPHIIntoPred( // Remap debug variable operands. remapDebugVariable(ValueMapping, New); + if (const DebugLoc &DL = New->getDebugLoc()) + mapAtomInstance(DL, ValueMapping); // If this instruction can be simplified after the operands are updated, // just use the simplified value instead. This frequently happens due to @@ -2756,6 +2761,10 @@ bool JumpThreadingPass::duplicateCondBranchOnPHIIntoPred( addPHINodeEntriesForMappedBlock(BBBranch->getSuccessor(1), BB, PredBB, ValueMapping); + // KeyInstructions: Remap the cloned instructions' atoms only. + remapSourceAtoms(ValueMapping, std::prev(RItBeforeInsertPt)->getIterator(), + OldPredBranch->getIterator()); + updateSSA(BB, PredBB, ValueMapping); // PredBB no longer jumps to BB, remove entries in the PHI node for the edge |