diff options
author | Yingwei Zheng <dtcxzyw2333@gmail.com> | 2025-06-06 12:56:28 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-06 12:56:28 +0800 |
commit | 4eac8daa38990871e50b804c0cc19a3ad9c98db2 (patch) | |
tree | 1f181c005b1569d4e223d1338af51c82a1c51447 /llvm/lib/Transforms/Utils/LoopPeel.cpp | |
parent | d5d6f60632c6c6ef5a4342439f767e10880784e1 (diff) | |
download | llvm-4eac8daa38990871e50b804c0cc19a3ad9c98db2.zip llvm-4eac8daa38990871e50b804c0cc19a3ad9c98db2.tar.gz llvm-4eac8daa38990871e50b804c0cc19a3ad9c98db2.tar.bz2 |
[LoopPeel] Handle non-local instructions/arguments when updating exiting values (#142993)
Similar to
https://github.com/llvm/llvm-project/commit/7e14161f49b32387988cf9d937bbfaa27d0fbdd5,
the exiting value may be a non-local instruction or an argument.
Closes https://github.com/llvm/llvm-project/issues/142895.
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopPeel.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/LoopPeel.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopPeel.cpp b/llvm/lib/Transforms/Utils/LoopPeel.cpp index bd025fd..9149f71 100644 --- a/llvm/lib/Transforms/Utils/LoopPeel.cpp +++ b/llvm/lib/Transforms/Utils/LoopPeel.cpp @@ -1257,7 +1257,11 @@ bool llvm::peelLoop(Loop *L, unsigned PeelCount, bool PeelLast, LoopInfo *LI, // Now adjust users of the original exit values by replacing them with the // exit value from the peeled iteration and remove them. for (const auto &[P, E] : ExitValues) { - P->replaceAllUsesWith(isa<Constant>(E) ? E : &*VMap.lookup(E)); + Instruction *ExitInst = dyn_cast<Instruction>(E); + if (ExitInst && L->contains(ExitInst)) + P->replaceAllUsesWith(&*VMap[ExitInst]); + else + P->replaceAllUsesWith(E); P->eraseFromParent(); } formLCSSA(*L, DT, LI, SE); |