Calling ReassociateExpression recursively is extremely dangerous since it will
authorDuncan Sands <baldrick@free.fr>
Tue, 8 May 2012 12:16:05 +0000 (12:16 +0000)
committerDuncan Sands <baldrick@free.fr>
Tue, 8 May 2012 12:16:05 +0000 (12:16 +0000)
commita33701098936ffba12326d96e98d388357f3e098
treecff3195892a74d216f1bdeff1d08179567796517
parent1f9838347fdcc75cead228ec1758063074b89c6a
Calling ReassociateExpression recursively is extremely dangerous since it will
replace the operands of expressions with only one use with undef and generate
a new expression for the original without using RAUW to update the original.
Thus any copies of the original expression held in a vector may end up
referring to some bogus value - and using a ValueHandle won't help since there
is no RAUW.  There is already a mechanism for getting the effect of recursion
non-recursively: adding the value to be recursed on to RedoInsts.  But it wasn't
being used systematically.  Have various places where recursion had snuck in at
some point use the RedoInsts mechanism instead.  Fixes PR12169.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156379 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Scalar/Reassociate.cpp
test/Transforms/Reassociate/2012-05-08-UndefLeak.ll [new file with mode: 0644]
test/Transforms/Reassociate/multistep.ll [new file with mode: 0644]