From 4a8c2b625b7ed7d95e349cdd45ff6a3df0771bc5 Mon Sep 17 00:00:00 2001 From: Igor Laevsky Date: Thu, 30 Nov 2017 15:41:58 +0000 Subject: [PATCH] [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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319444 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/FuzzMutate/IRMutator.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/FuzzMutate/IRMutator.cpp b/lib/FuzzMutate/IRMutator.cpp index 59f94716caa..15e7f86d1cd 100644 --- a/lib/FuzzMutate/IRMutator.cpp +++ b/lib/FuzzMutate/IRMutator.cpp @@ -105,6 +105,8 @@ void InjectorIRStrategy::mutate(BasicBlock &BB, RandomIRBuilder &IB) { SmallVector 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(IB.Rand, 0, Insts.size() - 1); -- 2.50.1