diff options
author | Orlando Cazalet-Hyams <orlando.hyams@sony.com> | 2025-05-07 09:56:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-07 09:56:30 +0100 |
commit | 74c3025dd518aae01db5fbbd06b81c8ad272f959 (patch) | |
tree | a064c38f55bccec962bd95ef59d020af7ded0a6a /llvm/lib/Transforms/Utils/SimplifyCFG.cpp | |
parent | 0d0eed419fa362e1932b694e01534f4012dcea97 (diff) | |
download | llvm-74c3025dd518aae01db5fbbd06b81c8ad272f959.zip llvm-74c3025dd518aae01db5fbbd06b81c8ad272f959.tar.gz llvm-74c3025dd518aae01db5fbbd06b81c8ad272f959.tar.bz2 |
[KeyInstr][SimplifyCFG] Remap atoms after duplication for threading (#133484)
Given the same branch condition in `a` and `c` SimplifyCFG converts:
+> b -+
| v
--> a --> c --> e -->
| ^
+> d -+
into:
+--> bcd ---+
| v
--> a --> c --> e -->
Remap source atoms on instructions duplicated from `c` into `bcd`.
RFC:
https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index 89709e1..0f7e15b 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -3590,7 +3590,7 @@ foldCondBranchOnValueKnownInPredecessorImpl(BranchInst *BI, DomTreeUpdater *DTU, // instructions into EdgeBB. We know that there will be no uses of the // cloned instructions outside of EdgeBB. BasicBlock::iterator InsertPt = EdgeBB->getFirstInsertionPt(); - DenseMap<Value *, Value *> TranslateMap; // Track translated values. + ValueToValueMapTy TranslateMap; // Track translated values. TranslateMap[Cond] = CB; // RemoveDIs: track instructions that we optimise away while folding, so @@ -3610,11 +3610,11 @@ foldCondBranchOnValueKnownInPredecessorImpl(BranchInst *BI, DomTreeUpdater *DTU, N->setName(BBI->getName() + ".c"); // Update operands due to translation. - for (Use &Op : N->operands()) { - DenseMap<Value *, Value *>::iterator PI = TranslateMap.find(Op); - if (PI != TranslateMap.end()) - Op = PI->second; - } + // Key Instructions: Remap all the atom groups. + if (const DebugLoc &DL = BBI->getDebugLoc()) + mapAtomInstance(DL, TranslateMap); + RemapInstruction(N, TranslateMap, + RF_IgnoreMissingLocals | RF_NoModuleLevelChanges); // Check for trivial simplification. if (Value *V = simplifyInstruction(N, {DL, nullptr, nullptr, AC})) { |