[PATCH] D138262: [FuzzMutate] Update InstModifierStrategy
Peter Rong via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 17 23:50:00 PST 2022
Peter updated this revision to Diff 476357.
Peter edited the summary of this revision.
Peter added a comment.
format
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D138262/new/
https://reviews.llvm.org/D138262
Files:
llvm/include/llvm/FuzzMutate/IRMutator.h
llvm/unittests/FuzzMutate/StrategiesTest.cpp
Index: llvm/unittests/FuzzMutate/StrategiesTest.cpp
===================================================================
--- llvm/unittests/FuzzMutate/StrategiesTest.cpp
+++ llvm/unittests/FuzzMutate/StrategiesTest.cpp
@@ -31,15 +31,13 @@
Type::getInt64Ty, Type::getFloatTy, Type::getDoubleTy};
std::vector<std::unique_ptr<IRMutationStrategy>> Strategies;
- Strategies.push_back(
- std::make_unique<InjectorIRStrategy>(
- InjectorIRStrategy::getDefaultOps()));
+ Strategies.push_back(std::make_unique<InjectorIRStrategy>(
+ InjectorIRStrategy::getDefaultOps()));
return std::make_unique<IRMutator>(std::move(Types), std::move(Strategies));
}
-template <class Strategy>
-std::unique_ptr<IRMutator> createMutator() {
+template <class Strategy> std::unique_ptr<IRMutator> createMutator() {
std::vector<TypeGetter> Types{
Type::getInt1Ty, Type::getInt8Ty, Type::getInt16Ty, Type::getInt32Ty,
Type::getInt64Ty, Type::getFloatTy, Type::getDoubleTy};
@@ -50,8 +48,8 @@
return std::make_unique<IRMutator>(std::move(Types), std::move(Strategies));
}
-std::unique_ptr<Module> parseAssembly(
- const char *Assembly, LLVMContext &Context) {
+std::unique_ptr<Module> parseAssembly(const char *Assembly,
+ LLVMContext &Context) {
SMDiagnostic Error;
std::unique_ptr<Module> M = parseAssemblyString(Assembly, Error, Context);
@@ -94,15 +92,15 @@
// Test that we don't crash even if we can't remove from one of the functions.
StringRef Source = ""
- "define <8 x i32> @func1() {\n"
- "ret <8 x i32> undef\n"
- "}\n"
- "\n"
- "define i32 @func2() {\n"
- "%A9 = alloca i32\n"
- "%L6 = load i32, i32* %A9\n"
- "ret i32 %L6\n"
- "}\n";
+ "define <8 x i32> @func1() {\n"
+ "ret <8 x i32> undef\n"
+ "}\n"
+ "\n"
+ "define i32 @func2() {\n"
+ "%A9 = alloca i32\n"
+ "%L6 = load i32, i32* %A9\n"
+ "ret i32 %L6\n"
+ "}\n";
auto Mutator = createMutator<InstDeleterIRStrategy>();
ASSERT_TRUE(Mutator);
@@ -319,4 +317,4 @@
}";
VerfyDivDidntShuffle(Source);
}
-}
+} // namespace
Index: llvm/include/llvm/FuzzMutate/IRMutator.h
===================================================================
--- llvm/include/llvm/FuzzMutate/IRMutator.h
+++ llvm/include/llvm/FuzzMutate/IRMutator.h
@@ -95,6 +95,7 @@
void mutate(BasicBlock &BB, RandomIRBuilder &IB) override;
};
+/// Strategy that deletes instructions when the Module is too large.
class InstDeleterIRStrategy : public IRMutationStrategy {
public:
uint64_t getWeight(size_t CurrentSize, size_t MaxSize,
@@ -105,6 +106,7 @@
void mutate(Instruction &Inst, RandomIRBuilder &IB) override;
};
+/// Strategy that modifies instruction attributes and operands.
class InstModificationIRStrategy : public IRMutationStrategy {
public:
uint64_t getWeight(size_t CurrentSize, size_t MaxSize,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138262.476357.patch
Type: text/x-patch
Size: 3100 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221118/7b78f9bd/attachment.bin>
More information about the llvm-commits
mailing list