When run under valgrind, or with a malloc that poisons freed memory,
this can lead to segfaults or other problems.
To avoid modifying the AdditionalUsers DenseMap while still iterating,
save the instructions to be notified in a separate SmallPtrSet, and use
this to later call OperandChangedState on each instruction.
Fixes PR49582.
It would be great if you could add a brief explanation to the test. E.g. say something like: This test checks for an iterator invalidation issue, which only gets exposed on a large-enough test case. We intentionally do not check the output.