Redo the fix Benjamin Kramer committed in r178793 about iterator invalidation in...
authorShuxin Yang <shuxin.llvm@gmail.com>
Mon, 8 Apr 2013 22:00:43 +0000 (22:00 +0000)
committerShuxin Yang <shuxin.llvm@gmail.com>
Mon, 8 Apr 2013 22:00:43 +0000 (22:00 +0000)
commit331f01dcb45159b8dee5a99cf1ae29ae7dd10f39
tree3a1022d5afc6feb178ddbe6c71204beb4976d7d2
parent0d9b3191f6956db648140b649eea79f0a5271aa1
Redo the fix Benjamin Kramer committed in r178793 about iterator invalidation in Reassociate.

I brazenly think this change is slightly simpler than r178793 because:
  - no "state" in functor
  - "OpndPtrs[i]" looks simpler than "&Opnds[OpndIndices[i]]"

  While I can reproduce the probelm in Valgrind, it is rather difficult to come up
a standalone testing case. The reason is that when an iterator is invalidated,
the stale invalidated elements are not yet clobbered by nonsense data, so the
optimizer can still proceed successfully.

  Thank Benjamin for fixing this bug and generously providing the test case.

llvm-svn: 179062
llvm/lib/Transforms/Scalar/Reassociate.cpp