[PATCH] D148972: [FuzzMutate] Correct type cast and add unit test for FCmp
Peter Rong via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 21 16:37:49 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1a3f158add60: [FuzzMutate] Correct type cast and add unit test for FCmp (authored by Peter).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D148972/new/
https://reviews.llvm.org/D148972
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
@@ -245,6 +245,31 @@
EXPECT_TRUE(FoundNE);
}
+TEST(InstModificationIRStrategyTest, FCmp) {
+ LLVMContext Ctx;
+ StringRef Source = "\n\
+ define i1 @test(float %x) {\n\
+ %a = fcmp oeq float %x, 10.0\n\
+ ret i1 %a\n\
+ }";
+
+ auto Mutator = createMutator<InstModificationIRStrategy>();
+ ASSERT_TRUE(Mutator);
+
+ auto M = parseAssembly(Source.data(), Ctx);
+ auto &F = *M->begin();
+ CmpInst *CI = cast<CmpInst>(&*F.begin()->begin());
+ ASSERT_TRUE(M && !verifyModule(*M, &errs()));
+ bool FoundONE = false;
+ for (int i = 0; i < 100; ++i) {
+ Mutator->mutateModule(*M, Seed + i, Source.size(), Source.size() + 100);
+ EXPECT_TRUE(!verifyModule(*M, &errs()));
+ FoundONE |= CI->getPredicate() == CmpInst::FCMP_ONE;
+ }
+
+ EXPECT_TRUE(FoundONE);
+}
+
TEST(InstModificationIRStrategyTest, GEP) {
LLVMContext Ctx;
StringRef Source = "\n\
Index: llvm/lib/FuzzMutate/IRMutator.cpp
===================================================================
--- llvm/lib/FuzzMutate/IRMutator.cpp
+++ llvm/lib/FuzzMutate/IRMutator.cpp
@@ -243,7 +243,7 @@
break;
case Instruction::FCmp:
- CI = cast<ICmpInst>(&Inst);
+ CI = cast<FCmpInst>(&Inst);
for (unsigned p = CmpInst::FIRST_FCMP_PREDICATE;
p <= CmpInst::LAST_FCMP_PREDICATE; p++) {
Modifications.push_back(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148972.515955.patch
Type: text/x-patch
Size: 1565 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230421/e85502c3/attachment.bin>
More information about the llvm-commits
mailing list