auto RS = makeSampler(IB.Rand, Functions);
Function *F = RS.getSelection();
- if (!F) {
+ auto IsUnsupportedTy = [](Type *T) {
+ return T->isMetadataTy() || T->isTokenTy();
+ };
+ if (!F || IsUnsupportedTy(F->getReturnType()) ||
+ any_of(F->getFunctionType()->params(), IsUnsupportedTy)) {
F = IB.createFunctionDeclaration(*M);
}
VerfyDivDidntShuffle(Source);
}
-TEST(FunctionIRStrategy, Func) {
+TEST(InsertFunctionStrategy, Func) {
LLVMContext Ctx;
const char *Source = "";
auto Mutator = createMutator<InsertFunctionStrategy>();
}
}
+TEST(InsertFunctionStrategy, AvoidCallingFunctionWithSpecialParam) {
+ LLVMContext Ctx;
+ StringRef Source = "\n\
+ declare void @llvm.dbg.value(metadata %0, metadata %1, metadata %2)\n\
+ declare i1 @llvm.experimental.gc.result.i1(token %0)\n\
+ define i32 @test(i32 %0) gc \"statepoint-example\" {\n\
+ ret i32 %0 \n\
+ }";
+ auto Mutator = createMutator<InsertFunctionStrategy>();
+ auto M = parseAssembly(Source.data(), Ctx);
+ srand(Seed);
+ for (int i = 0; i < 100; i++) {
+ Mutator->mutateModule(*M, rand(), 1024);
+ EXPECT_TRUE(!verifyModule(*M, &errs()));
+ }
+}
+
TEST(InstModificationIRStrategy, Exact) {
LLVMContext Ctx;
StringRef Source = "\n\