LLVM: lib/FuzzMutate/Operations.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
14
15using namespace llvm;
17
44
69
71 std::vectorfuzzerop::OpDescriptor &Ops) {
73}
74
76 std::vectorfuzzerop::OpDescriptor &Ops) {
78}
79
83
87
89 std::vectorfuzzerop::OpDescriptor &Ops) {
92}
93
99
103 };
104 return {Weight,
106 buildOp};
107}
108
115
120 };
121 switch (Op) {
122 case Instruction::Add:
123 case Instruction::Sub:
124 case Instruction::Mul:
125 case Instruction::SDiv:
126 case Instruction::UDiv:
127 case Instruction::SRem:
128 case Instruction::URem:
129 case Instruction::Shl:
130 case Instruction::LShr:
131 case Instruction::AShr:
132 case Instruction::And:
133 case Instruction::Or:
134 case Instruction::Xor:
136 case Instruction::FAdd:
137 case Instruction::FSub:
138 case Instruction::FMul:
139 case Instruction::FDiv:
140 case Instruction::FRem:
142 case Instruction::BinaryOpsEnd:
144 }
146}
147
153 return CmpInst::Create(CmpOp, Pred, Srcs[0], Srcs[1], "C", InsertPt);
154 };
155
156 switch (CmpOp) {
157 case Instruction::ICmp:
159 case Instruction::FCmp:
161 default:
163 }
164}
165
171
172
173 if (Block->isEHPad())
174 return nullptr;
175
176
177
178 if (Block != &Block->getParent()->getEntryBlock()) {
180 Block->getTerminator()->getIterator());
181 Block->getTerminator()->eraseFromParent();
182
183
184
185
188 }
189 return nullptr;
190 };
192 return V->getType()->isIntegerTy(1);
193 },
194 std::nullopt};
195 return {Weight, {isInt1Ty}, buildSplitBlock};
196}
197
200
201
202 Type *Ty = Srcs[1]->getType();
205 };
206
207
208
211 std::nullopt);
213}
214
216 assert(T->isAggregateType() && "Not a struct or array");
218 return T->getStructNumElements();
219 return T->getArrayNumElements();
220}
221
226 return true;
227 return false;
228 };
230 std::vector<Constant *> Result;
233
234 Result.push_back(ConstantInt::get(Int32Ty, 0));
235 if (N > 1)
236 Result.push_back(ConstantInt::get(Int32Ty, N - 1));
237 if (N > 2)
238 Result.push_back(ConstantInt::get(Int32Ty, N / 2));
239 return Result;
240 };
241 return {Pred, Make};
242}
243
254
258 return V->getType() == ArrayT->getElementType();
259
261 for (int I = 0, E = STy->getNumElements(); I < E; ++I)
262 if (STy->getTypeAtIndex(I) == V->getType())
263 return true;
264 return false;
265 };
269
270 std::vector<Constant *> Result;
272 for (int I = 0, E = STy->getNumElements(); I < E; ++I)
274 return Result;
275 };
276 return {Pred, Make};
277}
278
282 if (CI->getBitWidth() == 32) {
284 CI->getZExtValue());
285 return Indexed == Cur[1]->getType();
286 }
287 return false;
288 };
290 std::vector<Constant *> Result;
292 auto *BaseTy = Cur[0]->getType();
293 int I = 0;
296 Result.push_back(ConstantInt::get(Int32Ty, I));
297 ++I;
298 }
299 return Result;
300 };
301 return {Pred, Make};
302}
303
306
309 };
310 return {
311 Weight,
313 buildInsert};
314}
315
324
328 };
329
330 return {Weight,
332 buildInsert};
333}
334
338 };
342
343
344 return std::vector<Constant *>{
346 };
347 return {Pred, Make};
348}
349
353 return new ShuffleVectorInst(Srcs[0], Srcs[1], Srcs[2], "S", InsertPt);
354 };
355 return {Weight,
357 buildShuffle};
358}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
static SourcePred validShuffleVectorIndex()
Definition Operations.cpp:335
static uint64_t getAggregateNumElements(Type *T)
Definition Operations.cpp:215
static SourcePred validExtractValueIndex()
Definition Operations.cpp:222
static SourcePred matchScalarInAggregate()
Definition Operations.cpp:255
static SourcePred validInsertValueIndex()
Definition Operations.cpp:279
static SymbolRef::Type getType(const Symbol *Sym)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
ArrayRef< T > drop_front(size_t N=1) const
Drop the first N elements of the array.
LLVM Basic Block Representation.
InstListType::iterator iterator
Instruction iterators...
static LLVM_ABI BinaryOperator * Create(BinaryOps Op, Value *S1, Value *S2, const Twine &Name=Twine(), InsertPosition InsertBefore=nullptr)
Construct a binary instruction, given the opcode and the two operands.
static BranchInst * Create(BasicBlock *IfTrue, InsertPosition InsertBefore=nullptr)
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
@ FCMP_OEQ
0 0 0 1 True if ordered and equal
@ FCMP_TRUE
1 1 1 1 Always true (always folded)
@ ICMP_SLT
signed less than
@ ICMP_SLE
signed less or equal
@ FCMP_OLT
0 1 0 0 True if ordered and less than
@ FCMP_ULE
1 1 0 1 True if unordered, less than, or equal
@ FCMP_OGT
0 0 1 0 True if ordered and greater than
@ FCMP_OGE
0 0 1 1 True if ordered and greater than or equal
@ ICMP_UGE
unsigned greater or equal
@ ICMP_UGT
unsigned greater than
@ ICMP_SGT
signed greater than
@ FCMP_ULT
1 1 0 0 True if unordered or less than
@ FCMP_ONE
0 1 1 0 True if ordered and operands are unequal
@ FCMP_UEQ
1 0 0 1 True if unordered or equal
@ ICMP_ULT
unsigned less than
@ FCMP_UGT
1 0 1 0 True if unordered or greater than
@ FCMP_OLE
0 1 0 1 True if ordered and less than or equal
@ FCMP_ORD
0 1 1 1 True if ordered (no nans)
@ ICMP_SGE
signed greater or equal
@ FCMP_UNE
1 1 1 0 True if unordered or not equal
@ ICMP_ULE
unsigned less or equal
@ FCMP_UGE
1 0 1 1 True if unordered, greater than, or equal
@ FCMP_FALSE
0 0 0 0 Always false (always folded)
@ FCMP_UNO
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
static LLVM_ABI CmpInst * Create(OtherOps Op, Predicate Pred, Value *S1, Value *S2, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Construct a compare instruction, given the opcode, the predicate and the two operands.
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
static InsertElementInst * Create(Value *Vec, Value *NewElt, Value *Idx, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
static InsertValueInst * Create(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
static SelectInst * Create(Value *C, Value *S1, Value *S2, const Twine &NameStr="", InsertPosition InsertBefore=nullptr, const Instruction *MDFrom=nullptr)
This instruction constructs a fixed permutation of two input vectors.
static LLVM_ABI bool isValidOperands(const Value *V1, const Value *V2, const Value *Mask)
Return true if a shufflevector instruction can be formed with the specified operands.
The instances of the Type class are immutable: once they are created, they are never changed.
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
static LLVM_ABI UnaryOperator * Create(UnaryOps Op, Value *S, const Twine &Name=Twine(), InsertPosition InsertBefore=nullptr)
Construct a unary instruction, given the opcode and an operand.
LLVM Value Representation.
static LLVM_ABI VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
A matcher/generator for finding suitable values for the next source in an operation's partially compl...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static SourcePred matchFirstLengthWAnyType()
LLVM_ABI OpDescriptor extractValueDescriptor(unsigned Weight)
Definition Operations.cpp:244
LLVM_ABI OpDescriptor splitBlockDescriptor(unsigned Weight)
Definition Operations.cpp:166
static SourcePred anyFloatOrVecFloatType()
static SourcePred sizedPtrType()
LLVM_ABI OpDescriptor fnegDescriptor(unsigned Weight)
Definition Operations.cpp:109
LLVM_ABI void makeConstantsWithType(Type *T, std::vector< Constant * > &Cs)
LLVM_ABI OpDescriptor cmpOpDescriptor(unsigned Weight, Instruction::OtherOps CmpOp, CmpInst::Predicate Pred)
Definition Operations.cpp:148
static SourcePred anyAggregateType()
LLVM_ABI OpDescriptor extractElementDescriptor(unsigned Weight)
Definition Operations.cpp:316
LLVM_ABI OpDescriptor insertValueDescriptor(unsigned Weight)
Definition Operations.cpp:304
LLVM_ABI OpDescriptor shuffleVectorDescriptor(unsigned Weight)
Definition Operations.cpp:350
static SourcePred anyIntType()
static SourcePred matchScalarOfFirstType()
Match values that have the first source's scalar type.
LLVM_ABI OpDescriptor selectDescriptor(unsigned Weight)
Descriptors for individual operations.
Definition Operations.cpp:100
static SourcePred anyIntOrVecIntType()
static SourcePred anyVectorType()
static SourcePred boolOrVecBoolType()
LLVM_ABI OpDescriptor insertElementDescriptor(unsigned Weight)
Definition Operations.cpp:325
static SourcePred matchFirstType()
Match values that have the same type as the first source.
LLVM_ABI OpDescriptor binOpDescriptor(unsigned Weight, Instruction::BinaryOps Op)
Definition Operations.cpp:116
LLVM_ABI OpDescriptor gepDescriptor(unsigned Weight)
Definition Operations.cpp:198
static SourcePred matchSecondType()
Match values that have the same type as the first source.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI void describeFuzzerIntOps(std::vector< fuzzerop::OpDescriptor > &Ops)
Getters for the default sets of operations, per general category.
Definition Operations.cpp:18
decltype(auto) dyn_cast(const From &Val)
dyn_cast - Return the argument parameter cast to the specified type.
FunctionAddr VTableAddr uintptr_t uintptr_t Int32Ty
LLVM_ABI void describeFuzzerOtherOps(std::vector< fuzzerop::OpDescriptor > &Ops)
Definition Operations.cpp:80
LLVM_ABI void describeFuzzerAggregateOps(std::vector< fuzzerop::OpDescriptor > &Ops)
Definition Operations.cpp:88
LLVM_ABI void describeFuzzerUnaryOperations(std::vector< fuzzerop::OpDescriptor > &Ops)
Definition Operations.cpp:70
LLVM_ABI void describeFuzzerVectorOps(std::vector< fuzzerop::OpDescriptor > &Ops)
Definition Operations.cpp:94
bool isa(const From &Val)
isa - Return true if the parameter to the template is an instance of one of the template type argu...
FunctionAddr VTableAddr Next
DWARFExpression::Operation Op
LLVM_ABI void describeFuzzerFloatOps(std::vector< fuzzerop::OpDescriptor > &Ops)
Definition Operations.cpp:45
ArrayRef(const T &OneElt) -> ArrayRef< T >
decltype(auto) cast(const From &Val)
cast - Return the argument parameter cast to the specified type.
LLVM_ABI void describeFuzzerControlFlowOps(std::vector< fuzzerop::OpDescriptor > &Ops)
Definition Operations.cpp:75
LLVM_ABI void describeFuzzerPointerOps(std::vector< fuzzerop::OpDescriptor > &Ops)
Definition Operations.cpp:84
A description of some operation we can build while fuzzing IR.