aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
diff options
context:
space:
mode:
authorAlan Zhao <ayzhao@google.com>2023-06-16 10:35:52 -0700
committerAlan Zhao <ayzhao@google.com>2023-06-16 10:36:49 -0700
commit00264eac4d0938ae8a0826da38e4777be269124c (patch)
tree5b5b6adaa78ab86d06bce97782b739dbc2ec79f7 /llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
parent100cb5bacce1dfe4e74df769ac545c89200e362f (diff)
downloadllvm-00264eac4d0938ae8a0826da38e4777be269124c.zip
llvm-00264eac4d0938ae8a0826da38e4777be269124c.tar.gz
llvm-00264eac4d0938ae8a0826da38e4777be269124c.tar.bz2
Revert "InstSimplify: Require instruction be parented"
This reverts commit 1536e299e63d7788f38117b0212ca50eb76d7a3b. Reason: causes a regression in the inliner (see https://crbug.com/1454531 and https://reviews.llvm.org/rG1536e299e63d7788f38117b0212ca50eb76d7a3b#1217141)
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopRotationUtils.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/LoopRotationUtils.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp b/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
index d81db56..1a9eaf24 100644
--- a/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
+++ b/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
@@ -435,8 +435,6 @@ bool LoopRotate::rotateLoop(Loop *L, bool SimplifiedLatch) {
// Otherwise, create a duplicate of the instruction.
Instruction *C = Inst->clone();
- C->insertBefore(LoopEntryBranch);
-
++NumInstrsDuplicated;
// Eagerly remap the operands of the instruction.
@@ -446,7 +444,7 @@ bool LoopRotate::rotateLoop(Loop *L, bool SimplifiedLatch) {
// Avoid inserting the same intrinsic twice.
if (auto *DII = dyn_cast<DbgVariableIntrinsic>(C))
if (DbgIntrinsics.count(makeHash(DII))) {
- C->eraseFromParent();
+ C->deleteValue();
continue;
}
@@ -459,7 +457,7 @@ bool LoopRotate::rotateLoop(Loop *L, bool SimplifiedLatch) {
// in the map.
InsertNewValueIntoMap(ValueMap, Inst, V);
if (!C->mayHaveSideEffects()) {
- C->eraseFromParent();
+ C->deleteValue();
C = nullptr;
}
} else {
@@ -468,6 +466,7 @@ bool LoopRotate::rotateLoop(Loop *L, bool SimplifiedLatch) {
if (C) {
// Otherwise, stick the new instruction into the new block!
C->setName(Inst->getName());
+ C->insertBefore(LoopEntryBranch);
if (auto *II = dyn_cast<AssumeInst>(C))
AC->registerAssumption(II);