[llvm] [KeyInstr][LoopUnroll] Remap atoms while unrolling (PR #133489)
Orlando Cazalet-Hyams via llvm-commits
llvm-commits at lists.llvm.org
Wed May 7 08:29:34 PDT 2025
================
@@ -752,6 +752,14 @@ llvm::UnrollLoop(Loop *L, UnrollLoopOptions ULO, LoopInfo *LI,
}
}
+ // Remap source location atom instance. Do this now, rather than
+ // when we remap instructions, because remap is called once we've
+ // cloned all blocks (all the clones would get the same atom
+ // number).
----------------
OCHyams wrote:
`CloneBasicBlock` maps the atoms from the cloned block so new ones can be remapped in the duplicated block (the next unroll iteration). It stores that info in `VMap`. We need to update those instructions now using that info.
`remapInstructionsInBlocks` (which does also call `RemapSourceAtom`) which is called later for all cloned is passed `LastValueMap`. That map just has the "running map" of new cloned instructions, i.e., values are overwritten after each unrolled iteration. If we used that infra to remap source atoms, we'd just remap all atoms x to y, in all the unrolled blocks. But what we want is x -> y`1, x->y`2, with a unique value in each unrolled iteration.
Does that make any sense? I fear I'm mincing this explanation.
https://github.com/llvm/llvm-project/pull/133489
More information about the llvm-commits
mailing list