Elements in indices_of_replaced_params are not sorted.
|
for (auto it = indices_of_replaced_params.rbegin(); |
|
it != indices_of_replaced_params.rend(); ++it) { |
|
// +1 since the first in operand to OpFunctionCall is the result id of |
|
// the function. |
|
inst->RemoveInOperand(*it + 1); |
|
} |
The elements in the vector are shifted to the left when some element is removed. This means that if we remove an element with index i, every element with index j >= i previously had an index j + 1. Thus, the transformation might remove incorrect operands from OpFunctionCall instruction.