This commit fixes an error in the RemoveDeadValues pass that is
associated with its incorrect usage of the cloneInto() function.
The setOperands() function that is used by the cloneInto() function
requires all operands to not be null. But, that is not possible in this
pass because we drop uses of dead values, thus making them null. It is
only at the end of the pass that we are assured that such null values
won't exist but during the execution of the pass, there could be null
values.
To fix this, we replace the usage of the cloneInto() function to copy
a region with moveBlock() to move each block of the region one by one.
This function does not require the presence of non-null values and is
thus the right choice here. This implementation is also more opttimized
because we are moving things instead of copying them. The goal was
always moving.
Signed-off-by: Srishti Srivastava <srishtisrivastava.ai@gmail.com>
The temp block is a cute trick, but it clobbered the intent here, this is not the kind of idiom you will find in MLIR.
The right API here should be, I believe, newOp->getRegion(index).takeBody(region);