diff options
author | Igor Laevsky <igmyrj@gmail.com> | 2017-11-30 15:41:58 +0000 |
---|---|---|
committer | Igor Laevsky <igmyrj@gmail.com> | 2017-11-30 15:41:58 +0000 |
commit | 0cdf7fdc48fd024a55df2afd773d0f7359a79736 (patch) | |
tree | 859d51b6370cddf5e687deb747a404fe3c9e8280 /llvm/lib/FuzzMutate | |
parent | 6b75fab1fb16a505ffbfc59ef68b645e6c7c4fae (diff) | |
download | bcm5719-llvm-0cdf7fdc48fd024a55df2afd773d0f7359a79736.tar.gz bcm5719-llvm-0cdf7fdc48fd024a55df2afd773d0f7359a79736.zip |
[FuzzMutate] Bailout from injecting into empty basic blocks.
In rare cases we can receive request to inject into completelly empty basic block. In the normal case
all basic blocks contain at least terminator instruction, but it is possible that the only instruction is
catchpad instruction which is not part of the instruction iterator. This case seems rare enough to not care
about it.
Submiting without review, since it seems almost NFC. I couldn't come up with any reasonable way to test this.
llvm-svn: 319444
Diffstat (limited to 'llvm/lib/FuzzMutate')
-rw-r--r-- | llvm/lib/FuzzMutate/IRMutator.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/llvm/lib/FuzzMutate/IRMutator.cpp b/llvm/lib/FuzzMutate/IRMutator.cpp index 59f94716caa..15e7f86d1cd 100644 --- a/llvm/lib/FuzzMutate/IRMutator.cpp +++ b/llvm/lib/FuzzMutate/IRMutator.cpp @@ -105,6 +105,8 @@ void InjectorIRStrategy::mutate(BasicBlock &BB, RandomIRBuilder &IB) { SmallVector<Instruction *, 32> Insts; for (auto I = BB.getFirstInsertionPt(), E = BB.end(); I != E; ++I) Insts.push_back(&*I); + if (Insts.size() < 1) + return; // Choose an insertion point for our new instruction. size_t IP = uniform<size_t>(IB.Rand, 0, Insts.size() - 1); |