Try to harden the recursive simplification still further. This is again
authorChandler Carruth <chandlerc@gmail.com>
Sat, 24 Mar 2012 22:34:26 +0000 (22:34 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Sat, 24 Mar 2012 22:34:26 +0000 (22:34 +0000)
commit6231d5be410e2d7967352b29ad01522fda15680d
tree4f10d5257838c1af8a0c7fa385a5171b3b259dbc
parentc5b785b91c922bbb3d5adb4b042c976bebe00e4d
Try to harden the recursive simplification still further. This is again
spotted by inspection, and I've crafted no test case that triggers it on
my machine, but some of the windows builders are hitting what looks like
memory corruption, so *something* is amiss here.

This patch takes a more generalized approach to eliminating
double-visits. Imagine code such as:

  %x = ...
  %y = add %x, 1
  %z = add %x, %y

You can imagine that if we simplify %x, we would add %y and %z to the
list. If the use-chain order happens to cause us to add them in reverse
order, we could pull %y off first, and simplify it, adding %z to the
list. We now have %z on the list twice, and will reference it after it
is deleted.

Currently, all my test cases happen to not trigger this, likely due to
the use-chain ordering, but there seems no guarantee that such
a situation could not occur, so we should handle it correctly.

Again, if anyone knows how to craft a testcase that actually triggers
this, please let me know.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153397 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Analysis/InstructionSimplify.cpp