[PATCH] D90328: Eliminates dead store of an exisiting value
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 6 12:59:45 PST 2020
fhahn added a comment.
In D90328#2379727 <https://reviews.llvm.org/D90328#2379727>, @dmccrevan wrote:
>
> The line it is throwing the error on is ` MemoryAccess *UseAccess = dyn_cast_or_null<MemoryAccess>(U.getUser());` I tried debugging this, but got no luck, should I stick with the worklist idea? I think it doesn't break because of the visited set, but is this something that i could adapt to the other impl?
By deleting a memory access, you are modifying the use list you are iterating over, which can invalidate the iterator. Yo need to increment the iterator before removing the memory access, e.g.
for (auto UI = DefAccess->use_begin(), IE = DefAccess->use_end(); UI != IE;) {
MemoryAccess *UseAccess = cast<MemoryAccess>((UI++)->getUser());
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D90328/new/
https://reviews.llvm.org/D90328
More information about the llvm-commits
mailing list