aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Scalar/JumpThreading.cpp
diff options
context:
space:
mode:
authorOrlando Cazalet-Hyams <orlando.hyams@sony.com>2025-05-07 14:54:04 +0100
committerGitHub <noreply@github.com>2025-05-07 14:54:04 +0100
commita061998a14a0ff16b633d6cf48c250d50c6acad2 (patch)
tree875089d6437fe0aa478b3603068670cb20f377aa /llvm/lib/Transforms/Scalar/JumpThreading.cpp
parent1ee9576ee7b80fe9b965e597041c6b197a333275 (diff)
downloadllvm-a061998a14a0ff16b633d6cf48c250d50c6acad2.zip
llvm-a061998a14a0ff16b633d6cf48c250d50c6acad2.tar.gz
llvm-a061998a14a0ff16b633d6cf48c250d50c6acad2.tar.bz2
[KeyInstr][JumpThreading] Remap atoms in blocks duplicated for threading (#133486)
Diffstat (limited to 'llvm/lib/Transforms/Scalar/JumpThreading.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/JumpThreading.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
index ba598d8..31f6f38 100644
--- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp
+++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
@@ -2011,6 +2011,14 @@ void JumpThreadingPass::updateSSA(BasicBlock *BB, BasicBlock *NewBB,
}
}
+static void remapSourceAtoms(ValueToValueMapTy &VM, BasicBlock::iterator Begin,
+ BasicBlock::iterator End) {
+ if (VM.AtomMap.empty())
+ return;
+ for (auto It = Begin; It != End; ++It)
+ RemapSourceAtom(&*It, VM);
+}
+
/// Clone instructions in range [BI, BE) to NewBB. For PHI nodes, we only clone
/// arguments that come from PredBB. Return the map from the variables in the
/// source basic block to the variables in the newly created basic block.
@@ -2075,6 +2083,8 @@ void JumpThreadingPass::cloneInstructions(ValueToValueMapTy &ValueMapping,
PHINode *NewPN = PHINode::Create(PN->getType(), 1, PN->getName(), NewBB);
NewPN->addIncoming(PN->getIncomingValueForBlock(PredBB), PredBB);
ValueMapping[PN] = NewPN;
+ if (const DebugLoc &DL = PN->getDebugLoc())
+ mapAtomInstance(DL, ValueMapping);
}
// Clone noalias scope declarations in the threaded block. When threading a
@@ -2103,6 +2113,8 @@ void JumpThreadingPass::cloneInstructions(ValueToValueMapTy &ValueMapping,
adaptNoAliasScopes(New, ClonedScopes, Context);
CloneAndRemapDbgInfo(New, &*BI);
+ if (const DebugLoc &DL = New->getDebugLoc())
+ mapAtomInstance(DL, ValueMapping);
if (RetargetDbgValueIfPossible(New))
continue;
@@ -2330,6 +2342,9 @@ void JumpThreadingPass::threadThroughTwoBasicBlocks(BasicBlock *PredPredBB,
{DominatorTree::Insert, PredPredBB, NewBB},
{DominatorTree::Delete, PredPredBB, PredBB}});
+ // Remap source location atoms beacuse we're duplicating control flow.
+ remapSourceAtoms(ValueMapping, NewBB->begin(), NewBB->end());
+
updateSSA(PredBB, NewBB, ValueMapping);
// Clean up things like PHI nodes with single operands, dead instructions,