LLVM 22.0.0git
llvm::IRMutationStrategy Class Referenceabstract

Base class for describing how to mutate a module. More...

#include "llvm/FuzzMutate/IRMutator.h"

Inheritance diagram for llvm::IRMutationStrategy:
[legend]

Public Member Functions

virtual ~IRMutationStrategy ()=default
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.
virtual void mutate (Module &M, RandomIRBuilder &IB)
virtual void mutate (Function &F, RandomIRBuilder &IB)
virtual void mutate (BasicBlock &BB, RandomIRBuilder &IB)
virtual void mutate (Instruction &I, RandomIRBuilder &IB)

Detailed Description

Base class for describing how to mutate a module.

mutation functions for each IR unit forward to the contained unit.

Definition at line 36 of file IRMutator.h.

Constructor & Destructor Documentation

◆ ~IRMutationStrategy()

virtual llvm::IRMutationStrategy::~IRMutationStrategy ( )
virtualdefault

Member Function Documentation

◆ getWeight()

virtual uint64_t llvm::IRMutationStrategy::getWeight ( size_t CurrentSize,
size_t MaxSize,
uint64_t CurrentWeight )
pure virtual

Provide a weight to bias towards choosing this strategy for a mutation.

The value of the weight is arbitrary, but a good default is "the number of distinct ways in which this strategy can mutate a unit". This can also be used to prefer strategies that shrink the overall size of the result when we start getting close to MaxSize.

Implemented in llvm::InjectorIRStrategy, llvm::InsertCFGStrategy, llvm::InsertFunctionStrategy, llvm::InsertPHIStrategy, llvm::InstDeleterIRStrategy, llvm::InstModificationIRStrategy, llvm::ShuffleBlockStrategy, and llvm::SinkInstructionStrategy.

References F, and mutate().

◆ mutate() [1/4]

◆ mutate() [2/4]

void IRMutationStrategy::mutate ( Function & F,
RandomIRBuilder & IB )
virtual

◆ mutate() [3/4]

virtual void llvm::IRMutationStrategy::mutate ( Instruction & I,
RandomIRBuilder & IB )
inlinevirtual

◆ mutate() [4/4]

void IRMutationStrategy::mutate ( Module & M,
RandomIRBuilder & IB )
virtual

Mutators for each IR unit. By default these forward to a contained instance of the next smaller unit.

Reimplemented in llvm::InjectorIRStrategy, llvm::InsertFunctionStrategy, llvm::InstDeleterIRStrategy, and llvm::InstModificationIRStrategy.

Definition at line 38 of file IRMutator.cpp.

References F, llvm::makeSampler(), and mutate().

Referenced by getWeight(), llvm::InjectorIRStrategy::mutate(), mutate(), and mutate().


The documentation for this class was generated from the following files: