[FuzzMutate] Fix a bug in `connectToSink` which might invalidate the whole module.
authorPeter Rong <PeterRong96@gmail.com>
Tue, 29 Nov 2022 03:50:59 +0000 (19:50 -0800)
committerPeter Rong <PeterRong96@gmail.com>
Tue, 29 Nov 2022 21:07:26 +0000 (13:07 -0800)
commit50921a2174405fbac04a4c9aaeb6993153f05703
tree9c19dd8cc59894d0d11c9bea5b17a107594a1f46
parent21d9f725df8ba177dfa8a6a719618d5078dbb7a8
[FuzzMutate] Fix a bug in `connectToSink` which might invalidate the whole module.

`connectToSink` uses a value by putting it in a future instruction.
It will replace the operand of a future instruction with the current value.

However, if current value is an `Instruction` and put into a switch case, the module is invalid.
We fix that by only connecting to Br/Switch's condition, and don't touch other operands.

Will have other strategies to mutate other Br/Switch operands to be patched once this patch is passed

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D138890
llvm/lib/FuzzMutate/RandomIRBuilder.cpp
llvm/unittests/FuzzMutate/RandomIRBuilderTest.cpp