[PATCH] D80958: SROA: Remove pointer from visited along with instruction
Stanislav Mekhanoshin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 1 15:11:39 PDT 2020
rampitec created this revision.
rampitec added a reviewer: arsenm.
Herald added subscribers: hiraditya, wdng.
Herald added a project: LLVM.
If an instruction is erased we also need to remove it from
Visited set. There is a very small chance that an another
newly created instruction will be created with the same
pointer value in place of an erased one.
https://reviews.llvm.org/D80958
Files:
llvm/lib/Transforms/Scalar/SROA.cpp
Index: llvm/lib/Transforms/Scalar/SROA.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/SROA.cpp
+++ llvm/lib/Transforms/Scalar/SROA.cpp
@@ -3381,6 +3381,7 @@
getAdjustedAlignment(&LI, 0), DL);
Value *V = UndefValue::get(LI.getType());
Splitter.emitSplitOps(LI.getType(), V, LI.getName() + ".fca");
+ Visited.erase(&LI);
LI.replaceAllUsesWith(V);
LI.eraseFromParent();
return true;
@@ -3427,6 +3428,7 @@
StoreOpSplitter Splitter(&SI, *U, V->getType(), AATags,
getAdjustedAlignment(&SI, 0), DL);
Splitter.emitSplitOps(V->getType(), V, V->getName() + ".fca");
+ Visited.erase(&SI);
SI.eraseFromParent();
return true;
}
@@ -3473,6 +3475,7 @@
Value *NSel = Builder.CreateSelect(Sel->getCondition(), NTrue, NFalse,
Sel->getName() + ".sroa.sel");
+ Visited.erase(&GEPI);
GEPI.replaceAllUsesWith(NSel);
GEPI.eraseFromParent();
Instruction *NSelI = cast<Instruction>(NSel);
@@ -3521,6 +3524,7 @@
NewPN->addIncoming(NewVal, PHI->getIncomingBlock(I));
}
+ Visited.erase(&GEPI);
GEPI.replaceAllUsesWith(NewPN);
GEPI.eraseFromParent();
Visited.insert(NewPN);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80958.267745.patch
Type: text/x-patch
Size: 1311 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200601/c4b777d6/attachment.bin>
More information about the llvm-commits
mailing list