[PATCH] D150627: [FuzzMutate] Avoid calling function with metadata/token parameter/return type for `InsertFunctionStrategy`
Henry Yu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 18 14:20:00 PDT 2023
HazyFish updated this revision to Diff 523559.
HazyFish retitled this revision from "[FuzzMutate] Avoid calling function with metadata parameter for `InsertFunctionStrategy`" to "[FuzzMutate] Avoid calling function with metadata/token parameter/return type for `InsertFunctionStrategy`".
HazyFish edited the summary of this revision.
HazyFish added a comment.
Handle token type and add check for return type as well
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D150627/new/
https://reviews.llvm.org/D150627
Files:
llvm/lib/FuzzMutate/IRMutator.cpp
llvm/unittests/FuzzMutate/StrategiesTest.cpp
Index: llvm/unittests/FuzzMutate/StrategiesTest.cpp
===================================================================
--- llvm/unittests/FuzzMutate/StrategiesTest.cpp
+++ llvm/unittests/FuzzMutate/StrategiesTest.cpp
@@ -374,7 +374,7 @@
VerfyDivDidntShuffle(Source);
}
-TEST(FunctionIRStrategy, Func) {
+TEST(InsertFunctionStrategy, Func) {
LLVMContext Ctx;
const char *Source = "";
auto Mutator = createMutator<InsertFunctionStrategy>();
@@ -388,6 +388,23 @@
}
}
+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\
Index: llvm/lib/FuzzMutate/IRMutator.cpp
===================================================================
--- llvm/lib/FuzzMutate/IRMutator.cpp
+++ llvm/lib/FuzzMutate/IRMutator.cpp
@@ -360,7 +360,11 @@
auto RS = makeSampler(IB.Rand, Functions);
Function *F = RS.getSelection();
- if (!F) {
+ auto IsUnsupportedTy = [](Type *T) {
+ return T->isMetadataTy() || T->isTokenTy();
+ };
+ if (!F || any_of(F->getFunctionType()->params(), IsUnsupportedTy) ||
+ IsUnsupportedTy(F->getReturnType())) {
F = IB.createFunctionDeclaration(*M);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150627.523559.patch
Type: text/x-patch
Size: 1757 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230518/f4ef943b/attachment.bin>
More information about the llvm-commits
mailing list