15 #ifndef LLVM_FUZZMUTATE_IRMUTATOR_H 16 #define LLVM_FUZZMUTATE_IRMUTATOR_H 28 struct RandomIRBuilder;
42 virtual uint64_t
getWeight(
size_t CurrentSize,
size_t MaxSize,
43 uint64_t CurrentWeight) = 0;
61 std::vector<TypeGetter> AllowedTypes;
62 std::vector<std::unique_ptr<IRMutationStrategy>> Strategies;
66 std::vector<std::unique_ptr<IRMutationStrategy>> &&Strategies)
67 : AllowedTypes(
std::move(AllowedTypes)),
68 Strategies(
std::move(Strategies)) {}
70 void mutateModule(
Module &M,
int Seed,
size_t CurSize,
size_t MaxSize);
75 std::vector<fuzzerop::OpDescriptor> Operations;
82 : Operations(
std::move(Operations)) {}
83 static std::vector<fuzzerop::OpDescriptor> getDefaultOps();
85 uint64_t
getWeight(
size_t CurrentSize,
size_t MaxSize,
86 uint64_t CurrentWeight)
override {
87 return Operations.size();
97 uint64_t
getWeight(
size_t CurrentSize,
size_t MaxSize,
98 uint64_t CurrentWeight)
override;
107 #endif // LLVM_FUZZMUTATE_IRMUTATOR_H This class represents lattice values for constants.
static cl::opt< uint64_t > Seed("rng-seed", cl::value_desc("seed"), cl::Hidden, cl::desc("Seed for the random number generator"), cl::init(0))
virtual ~IRMutationStrategy()=default
A Module instance is used to store all the information related to an LLVM module. ...
Base class for describing how to mutate a module.
Entry point for configuring and running IR mutations.
IRMutator(std::vector< TypeGetter > &&AllowedTypes, std::vector< std::unique_ptr< IRMutationStrategy >> &&Strategies)
InjectorIRStrategy(std::vector< fuzzerop::OpDescriptor > &&Operations)
LLVM Basic Block Representation.
uint64_t getWeight(size_t CurrentSize, size_t MaxSize, uint64_t CurrentWeight) override
Provide a weight to bias towards choosing this strategy for a mutation.
virtual void mutate(Instruction &I, RandomIRBuilder &IB)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
virtual void mutate(Module &M, RandomIRBuilder &IB)
Strategy that injects operations into the function.
LLVM Value Representation.
virtual uint64_t getWeight(size_t CurrentSize, size_t MaxSize, uint64_t CurrentWeight)=0
Provide a weight to bias towards choosing this strategy for a mutation.
std::function< Type *(LLVMContext &)> TypeGetter