LLVM: llvm::RandomIRBuilder Struct Reference (original) (raw)

#include "[llvm/FuzzMutate/RandomIRBuilder.h](RandomIRBuilder%5F8h%5Fsource.html)"

Public Types
enum SourceType { SrcFromInstInCurBlock, FunctionArgument, InstInDominator, SrcFromGlobalVariable, NewConstOrStack, EndOfValueSource }
enum SinkType { SinkToInstInCurBlock, PointersInDominator, InstInDominatee, NewStore, SinkToGlobalVariable, EndOfValueSink }
Public Member Functions
RandomIRBuilder (int Seed, ArrayRef< Type * > AllowedTypes)
LLVM_ABI AllocaInst * createStackMemory (Function *F, Type *Ty, Value *Init=nullptr)
Create a stack memory at the head of the function, store Init to the memory if provided.
LLVM_ABI std::pair< GlobalVariable *, bool > findOrCreateGlobalVariable (Module *M, ArrayRef< Value * > Srcs, fuzzerop::SourcePred Pred)
Find or create a global variable.
LLVM_ABI Value * findOrCreateSource (BasicBlock &BB, ArrayRef< Instruction * > Insts)
Find a "source" for some operation, which will be used in one of the operation's operands.
LLVM_ABI Value * findOrCreateSource (BasicBlock &BB, ArrayRef< Instruction * > Insts, ArrayRef< Value * > Srcs, fuzzerop::SourcePred Pred, bool allowConstant=true)
Find a "source" for some operation, which will be used in one of the operation's operands.
LLVM_ABI Value * newSource (BasicBlock &BB, ArrayRef< Instruction * > Insts, ArrayRef< Value * > Srcs, fuzzerop::SourcePred Pred, bool allowConstant=true)
Create some Value suitable as a source for some operation.
LLVM_ABI Instruction * connectToSink (BasicBlock &BB, ArrayRef< Instruction * > Insts, Value *V)
Find a viable user for V in Insts, which should all be contained in BB.
LLVM_ABI Instruction * newSink (BasicBlock &BB, ArrayRef< Instruction * > Insts, Value *V)
Create a user for V in BB.
LLVM_ABI Value * findPointer (BasicBlock &BB, ArrayRef< Instruction * > Insts)
LLVM_ABI Type * randomType ()
Return a uniformly choosen type from AllowedTypes.
LLVM_ABI Function * createFunctionDeclaration (Module &M, uint64_t ArgNum)
LLVM_ABI Function * createFunctionDeclaration (Module &M)
LLVM_ABI Function * createFunctionDefinition (Module &M, uint64_t ArgNum)
LLVM_ABI Function * createFunctionDefinition (Module &M)
Public Attributes
RandomEngine Rand
SmallVector< Type *, 16 > KnownTypes
uint64_t MinArgNum = 0
uint64_t MaxArgNum = 5
uint64_t MinFunctionNum = 1

Definition at line 38 of file RandomIRBuilder.h.

SinkType

Enumerator
SinkToInstInCurBlock TODO: Also consider pointers in function argument.
PointersInDominator
InstInDominatee
NewStore
SinkToGlobalVariable
EndOfValueSink

Definition at line 89 of file RandomIRBuilder.h.

SourceType

Enumerator
SrcFromInstInCurBlock
FunctionArgument
InstInDominator
SrcFromGlobalVariable
NewConstOrStack
EndOfValueSource

Definition at line 61 of file RandomIRBuilder.h.

llvm::RandomIRBuilder::RandomIRBuilder ( int Seed, ArrayRef< Type * > AllowedTypes ) inline

connectToSink()

Find a viable user for V in Insts, which should all be contained in BB.

This may also create some new instruction in BB and use that.

TODO: allocate a new stack memory.

Definition at line 341 of file RandomIRBuilder.cpp.

References llvm::ArrayRef< T >::back(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), buildTargetLegalStore(), llvm::cast(), llvm::SmallVectorTemplateCommon< T, typename >::end(), EndOfValueSink, findOrCreateGlobalVariable(), getDominatees(), getDominators(), llvm::BasicBlock::getModule(), I, InstInDominatee, llvm::isa(), isCompatibleReplacement(), llvm_unreachable, llvm::makeSampler(), newSink(), NewStore, llvm::fuzzerop::onlyType(), PointersInDominator, llvm::SmallVectorTemplateBase< T, bool >::push_back(), Rand, SinkToGlobalVariable, and SinkToInstInCurBlock.

createFunctionDeclaration() [1/2]

createFunctionDeclaration() [2/2]

createFunctionDefinition() [1/2]

createFunctionDefinition() [2/2]

createStackMemory()

findOrCreateGlobalVariable()

findOrCreateSource() [1/2]

findOrCreateSource() [2/2]

Find a "source" for some operation, which will be used in one of the operation's operands.

This either selects an instruction in Insts that matches Pred, or returns some new Value that matches Pred. The values in Srcs should be source operands that have already been selected.

Definition at line 160 of file RandomIRBuilder.cpp.

References llvm::SmallVectorTemplateCommon< T, typename >::begin(), buildTargetLegalLoad(), llvm::SmallVectorTemplateCommon< T, typename >::end(), EndOfValueSource, eraseNewInstructions(), F, findOrCreateGlobalVariable(), FunctionArgument, getDominators(), llvm::BasicBlock::getFirstInsertionPt(), llvm::BasicBlock::getParent(), llvm::GlobalValue::getParent(), llvm::BasicBlock::getTerminator(), InstInDominator, llvm_unreachable, llvm::make_filter_range(), llvm::make_pointer_range(), llvm::makeSampler(), NewConstOrStack, newSource(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), Rand, SrcFromGlobalVariable, and SrcFromInstInCurBlock.

findPointer()

newSink()

newSource()

Create some Value suitable as a source for some operation.

Definition at line 243 of file RandomIRBuilder.cpp.

References assert(), buildTargetLegalLoad(), createStackMemory(), llvm::dyn_cast(), llvm::BasicBlock::end(), eraseNewInstructions(), F, findPointer(), llvm::BasicBlock::getFirstInsertionPt(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::BasicBlock::getModule(), llvm::BasicBlock::getParent(), llvm::BasicBlock::getTerminator(), llvm::Value::getType(), I, llvm::isa(), KnownTypes, llvm::makeSampler(), and Rand.

Referenced by findOrCreateSource().

randomType()

Type * RandomIRBuilder::randomType ( )

KnownTypes

MaxArgNum

uint64_t llvm::RandomIRBuilder::MaxArgNum = 5

MinArgNum

uint64_t llvm::RandomIRBuilder::MinArgNum = 0

MinFunctionNum

uint64_t llvm::RandomIRBuilder::MinFunctionNum = 1

Rand


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