aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/LoopPeel.cpp
diff options
context:
space:
mode:
authorYingwei Zheng <dtcxzyw2333@gmail.com>2025-06-06 12:56:28 +0800
committerGitHub <noreply@github.com>2025-06-06 12:56:28 +0800
commit4eac8daa38990871e50b804c0cc19a3ad9c98db2 (patch)
tree1f181c005b1569d4e223d1338af51c82a1c51447 /llvm/lib/Transforms/Utils/LoopPeel.cpp
parentd5d6f60632c6c6ef5a4342439f767e10880784e1 (diff)
downloadllvm-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.cpp6
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);