[IRMutator] Handle module with only declarations

There was a mismatch here, with one check checking whether there
are any functions, and the other collecting only non-declaration
functions.
This commit is contained in:
Nikita Popov 2022-03-11 14:14:16 +01:00
parent 806450805d
commit a3aac5693d
1 changed files with 5 additions and 4 deletions

View File

@ -33,14 +33,15 @@ static void createEmptyFunction(Module &M) {
}
void IRMutationStrategy::mutate(Module &M, RandomIRBuilder &IB) {
if (M.empty())
createEmptyFunction(M);
auto RS = makeSampler<Function *>(IB.Rand);
for (Function &F : M)
if (!F.isDeclaration())
RS.sample(&F, /*Weight=*/1);
mutate(*RS.getSelection(), IB);
if (RS.isEmpty())
createEmptyFunction(M);
else
mutate(*RS.getSelection(), IB);
}
void IRMutationStrategy::mutate(Function &F, RandomIRBuilder &IB) {