[PATCH] D23464: [PR28367][Reassociation] Avoid iterator invalidation when negating value.

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 16 14:02:56 PDT 2016


efriedma accepted this revision.
efriedma added a reviewer: efriedma.
efriedma added a comment.
This revision is now accepted and ready to land.

In https://reviews.llvm.org/D23464#517145, @mcrosier wrote:

> My gut tells me r258830 only exposed the problem and that it would still exist after a revert (but much less likely to happen).


Without r258830, the only live basic block iterator points at the current instruction itself, which will never be moved.  (A pointer to the instruction itself won't be invalidated by moving it.)

In terms of coming up with a safe patch to merge into 3.9, this seems like the right patch.  I still think it's ugly. :)

----

On a sort of related note, it might be worth experimenting with the iteration order of Reassociate at some point... it's possible that it would improve the generated code to iterate backwards over basic blocks.


https://reviews.llvm.org/D23464





More information about the llvm-commits mailing list