LLVM: lib/FuzzMutate/IRMutator.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
24#include "llvm/IR/IntrinsicsAMDGPU.h"
33#include
34#include
35
36using namespace llvm;
37
41 if (.isDeclaration())
42 RS.sample(&F, 1);
43
44 while (RS.totalWeight() < IB.MinFunctionNum) {
45 Function *F = IB.createFunctionDefinition(M);
46 RS.sample(F, 1);
47 }
48 mutate(*RS.getSelection(), IB);
49}
50
61
63 return M.getInstructionCount() + M.size() + M.global_size() + M.alias_size();
64}
65
67 std::vector<Type *> Types;
68 for (const auto &Getter : AllowedTypes)
69 Types.push_back(Getter(M.getContext()));
71
74 for (const auto &Strategy : Strategies)
75 RS.sample(Strategy.get(),
76 Strategy->getWeight(CurSize, MaxSize, RS.totalWeight()));
77 if (RS.totalWeight() == 0)
78 return;
79 auto Strategy = RS.getSelection();
80
81 Strategy->mutate(M, IB);
82}
83
92
97
99 std::vectorfuzzerop::OpDescriptor Ops;
106 return Ops;
107}
108
109std::optionalfuzzerop::OpDescriptor
112 return Op.SourcePreds[0].matches({}, Src);
113 };
115 if (RS.isEmpty())
116 return std::nullopt;
117 return *RS;
118}
119
122 return I;
123 } else {
124
125
128 return II;
129 }
130 }
131 }
132
134}
135
137 auto End = BB.end();
138
139 if (BB.empty()) {
140 return End;
141 }
142
145
146 End = std::prev(BB.end());
147 }
148
149 return End;
150}
151
157
161 if (Insts.size() < 1)
162 return;
163
164
166
167 auto InstsBefore = ArrayRef(Insts).slice(0, IP);
168 auto InstsAfter = ArrayRef(Insts).slice(IP);
169
170
172 Srcs.push_back(IB.findOrCreateSource(BB, InstsBefore));
173
174
175
176 auto OpDesc = chooseOperation(Srcs[0], IB);
177
178 if (!OpDesc)
179 return;
180
181 for (const auto &Pred : ArrayRef(OpDesc->SourcePreds).slice(1))
182 Srcs.push_back(IB.findOrCreateSource(BB, InstsBefore, Srcs, Pred));
183
184 if (Value *Op = OpDesc->BuilderFunc(Srcs, Insts[IP]->getIterator())) {
185
186 IB.connectToSink(BB, InstsAfter, Op);
187 }
188}
189
192
193 if (CurrentSize > MaxSize - 200)
194 return CurrentWeight ? CurrentWeight * 100 : 1;
195
196
197 int64_t Line = (-2 * static_cast<int64_t>(CurrentWeight)) *
198 (static_cast<int64_t>(MaxSize) -
199 static_cast<int64_t>(CurrentSize) - 1000) /
200 1000;
201
202 if (Line < 0)
203 return 0;
204 return Line;
205}
206
210
211 if (Inst.isTerminator() || Inst.isEHPad() || Inst.isSwiftError() ||
213 continue;
214
215 RS.sample(&Inst, 1);
216 }
217 if (RS.isEmpty())
218 return;
219
220
221 mutate(*RS.getSelection(), IB);
222
224}
225
227 assert(!Inst.isTerminator() && "Deleting terminators invalidates CFG");
228
230
231
233 return;
234 }
235
236
237
243 ++I) {
244 if (Pred.matches({}, &*I))
245 RS.sample(&*I, 1);
247 }
248 if (!RS)
249 RS.sample(IB.newSource(*BB, InstsBefore, {}, Pred), 1);
250
253}
254
257 SmallVector<std::function<void()>, 8> Modifications;
261 default:
262 break;
263
264 case Instruction::Add:
265 case Instruction::Mul:
266 case Instruction::Sub:
267 case Instruction::Shl:
268 Modifications.push_back(
270 Modifications.push_back(
272 break;
273 case Instruction::ICmp:
277 Modifications.push_back(
279 }
280 break;
281
282 case Instruction::GetElementPtr:
284 Modifications.push_back(
285 [GEP]() { GEP->setIsInBounds(->isInBounds()); });
286 break;
287
288 case Instruction::UDiv:
289 case Instruction::SDiv:
290 case Instruction::LShr:
291 case Instruction::AShr:
292 Modifications.push_back([&Inst] { Inst.setIsExact(!Inst.isExact()); });
293 break;
294
295 case Instruction::FCmp:
299 Modifications.push_back(
301 }
302 break;
303 }
304
305
307
308 Modifications.push_back(
310
311 Modifications.push_back(
313
314 Modifications.push_back(
318 Modifications.push_back(
320 Modifications.push_back(
322 Modifications.push_back(
324 Modifications.push_back(
326 }
327
328
329 std::pair<int, int> NoneItem({-1, -1}), ShuffleItems(NoneItem);
331 case Instruction::SDiv:
332 case Instruction::UDiv:
333 case Instruction::SRem:
334 case Instruction::URem:
335 case Instruction::FDiv:
336 case Instruction::FRem: {
337
338
341 if (->isZeroValue()) {
342 ShuffleItems = {0, 1};
343 }
344 }
345 break;
346 }
347 case Instruction::Select:
348 ShuffleItems = {1, 2};
349 break;
350 case Instruction::Add:
351 case Instruction::Sub:
352 case Instruction::Mul:
353 case Instruction::Shl:
354 case Instruction::LShr:
355 case Instruction::AShr:
356 case Instruction::And:
357 case Instruction::Or:
358 case Instruction::Xor:
359 case Instruction::FAdd:
360 case Instruction::FSub:
361 case Instruction::FMul:
362 case Instruction::ICmp:
363 case Instruction::FCmp:
364 case Instruction::ShuffleVector:
365 ShuffleItems = {0, 1};
366 break;
367 }
368 if (ShuffleItems != NoneItem) {
369 Modifications.push_back([&Inst, &ShuffleItems]() {
372 Inst.setOperand(ShuffleItems.second, Op0);
373 });
374 }
375
376 auto RS = makeSampler(IB.Rand, Modifications);
377 if (RS)
378 RS.getSelection()();
379}
380
381
382
386 do {
388 } while (CasesTaken.count(tmp) != 0);
389 CasesTaken.insert(tmp);
390 return tmp;
391}
392
393
394
395
396
397
398
400
401
402
403
404 auto IsUnsupportedTy = [](Type *T) {
405 return T->isMetadataTy() || T->isTokenTy();
406 };
407
408 if (IsUnsupportedTy(F->getReturnType()) ||
409 any_of(F->getFunctionType()->params(), IsUnsupportedTy)) {
410 return true;
411 }
412
413
414
415
416
419 Attribute::StructRet, Attribute::ByVal,
420 Attribute::InAlloca, Attribute::InReg,
421 Attribute::StackAlignment, Attribute::SwiftSelf,
422 Attribute::SwiftAsync, Attribute::SwiftError,
423 Attribute::Preallocated, Attribute::ByRef,
424 Attribute::ZExt, Attribute::SExt};
425
427 return A.hasAttribute(kind);
428 });
429 };
430
431 auto FuncAttrs = F->getAttributes();
432 if (IsABIAttribute(FuncAttrs.getRetAttrs())) {
433 return true;
434 }
435 for (size_t i = 0; i < F->arg_size(); i++) {
436 if (IsABIAttribute(FuncAttrs.getParamAttrs(i))) {
437 return true;
438 }
439 }
440
441
443 return true;
444 }
445
446
447
448 if (F->isIntrinsic() && F->getIntrinsicID() == Intrinsic::amdgcn_cs_chain) {
449 return true;
450 }
451
452 return false;
453}
454
457
459 for (Function &F : M->functions()) {
460 Functions.push_back(&F);
461 }
462
463 auto RS = makeSampler(IB.Rand, Functions);
465
467 F = IB.createFunctionDeclaration(*M);
468 }
469
472 if (->arg_empty()) {
475 }
476 }
477 bool isRetVoid = (F->getReturnType() == Type::getVoidTy(M->getContext()));
480 StringRef Name = isRetVoid ? nullptr : "C";
482 Call->setCallingConv(F->getCallingConv());
483
484 return isRetVoid ? nullptr : Call;
485 };
486
489 if (Insts.size() < 1)
490 return;
491
492
494
495 auto InstsBefore = ArrayRef(Insts).slice(0, IP);
496 auto InstsAfter = ArrayRef(Insts).slice(IP);
497
498
500
501 for (const auto &Pred : ArrayRef(SourcePreds)) {
502 Srcs.push_back(IB.findOrCreateSource(BB, InstsBefore, Srcs, Pred));
503 }
504
505 if (Value *Op = BuilderFunc(Srcs, Insts[IP]->getIterator())) {
506
507 IB.connectToSink(BB, InstsAfter, Op);
508 }
509}
510
514 if (Insts.size() < 1)
515 return;
516
517
519 auto InstsBeforeSplit = ArrayRef(Insts).slice(0, IP);
520
521
522
523
526 BasicBlock *Sink = Block->splitBasicBlock(Insts[IP], "BB");
527
530
532
536 IB.findOrCreateSource(*Source, InstsBeforeSplit, {},
539
541
542 connectBlocksToSink({IfTrue, IfFalse}, Sink, IB);
543 } else {
544
545
546 auto RS =
548 return Ty->isIntegerTy();
549 }));
550 assert(RS && "There is no integer type in all allowed types, is the "
551 "setting correct?");
552 Type *Ty = RS.getSelection();
554
555 uint64_t BitSize = IntTy->getBitWidth();
557 (BitSize >= 64) ? (uint64_t)-1 : ((uint64_t)1 << BitSize) - 1;
558
559 Value *Cond = IB.findOrCreateSource(*Source, InstsBeforeSplit, {},
563 NumCases = (NumCases > MaxCaseVal) ? MaxCaseVal + 1 : NumCases;
565
567
568
571 for (uint64_t i = 0; i < NumCases; i++) {
574 ConstantInt *OnValue = ConstantInt::get(IntTy, CaseVal);
575 Switch->addCase(OnValue, CaseBlock);
576 Blocks.push_back(CaseBlock);
577 }
578
579
580 connectBlocksToSink(Blocks, Sink, IB);
581 }
582}
583
584
585
590 for (uint64_t i = 0; i < Blocks.size(); i++) {
591
592 CFGToSink ToSink = (i == DirectSinkIdx)
593 ? CFGToSink::DirectSink
595 IB.Rand, 0, CFGToSink::EndOfCFGToLink - 1));
599 switch (ToSink) {
600 case CFGToSink::Return: {
601 Type *RetTy = F->getReturnType();
602 Value *RetValue = nullptr;
604 RetValue =
607 break;
608 }
609 case CFGToSink::DirectSink: {
611 break;
612 }
613 case CFGToSink::SinkOrSelfLoop: {
615
620 break;
621 }
622 case CFGToSink::EndOfCFGToLink:
623 llvm_unreachable("EndOfCFGToLink executed, something's wrong.");
624 }
625 }
626}
627
629
631 return;
632 Type *Ty = IB.randomType();
634
635
638 Value *Src = IncomingValues[Pred];
639
640 if (!Src) {
642 for (auto I = Pred->begin(); I != Pred->end(); ++I)
644
645
646 Src = IB.findOrCreateSource(*Pred, Insts, {}, fuzzerop::onlyType(Ty));
647 IncomingValues[Pred] = Src;
648 }
649 PHI->addIncoming(Src, Pred);
650 }
653 IB.connectToSink(BB, InstsAfter, PHI);
654}
655
658 this->mutate(BB, IB);
659 }
660}
664 if (Insts.size() < 1)
665 return;
666
669
670 auto InstsAfter = ArrayRef(Insts).slice(Idx + 1);
672
673 if (!Ty->isVoidTy() && !Ty->isTokenTy())
674
675 IB.connectToSink(BB, InstsAfter, Inst);
676}
677
679
680
681 std::map<size_t, Instruction *> AliveInsts;
682 std::map<Instruction *, size_t> AliveInstsLookup;
683 size_t InsertIdx = 0;
687
688
689 AliveInsts.insert({InsertIdx, &I});
690 AliveInstsLookup.insert({&I, InsertIdx++});
691
692 I.removeFromParent();
693 }
694
695
696
697
698 auto hasAliveParent = [&AliveInsts, &AliveInstsLookup](size_t Index) {
699 for (Value *O : AliveInsts[Index]->operands()) {
701 if (P && AliveInstsLookup.count(P))
702 return true;
703 }
704 return false;
705 };
706
707
708
709 auto getAliveChildren = [&AliveInstsLookup](Instruction *I) {
711 for (Value *U : I->users()) {
713 auto It = AliveInstsLookup.find(P);
714 if (It != AliveInstsLookup.end())
715 Children.insert(It->second);
716 }
717 }
718 return Children;
719 };
722 for (const auto &[Index, Inst] : AliveInsts) {
723 if (!hasAliveParent(Index))
724 RootIndices.insert(Index);
725 }
726
727 while (!RootIndices.empty()) {
729 for (size_t RootIdx : RootIndices)
730 RS.sample(RootIdx, 1);
731 size_t RootIdx = RS.getSelection();
732
733 RootIndices.erase(RootIdx);
735 AliveInsts.erase(RootIdx);
736 AliveInstsLookup.erase(Root);
738
739 for (size_t Child : getAliveChildren(Root)) {
740 if (!hasAliveParent(Child)) {
741 RootIndices.insert(Child);
742 }
743 }
744 }
745
747
749 I->insertBefore(Terminator->getIterator());
750 }
751}
752
755
756 if (Size <= 1)
757
758 return std::make_unique("M", Context);
759
761 StringRef(reinterpret_cast<const char *>(Data), Size), "Fuzzer input",
762 false);
763
765 auto M = parseBitcodeFile(Buffer->getMemBufferRef(), Context);
766 if (Error E = M.takeError()) {
768 return nullptr;
769 }
770 return std::move(M.get());
771}
772
774 std::string Buf;
775 {
778 }
779 if (Buf.size() > MaxSize)
780 return 0;
781 memcpy(Dest, Buf.data(), Buf.size());
782 return Buf.size();
783}
784
789 return nullptr;
790
791 return M;
792}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Expand Atomic instructions
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static Instruction * getEffectiveTerminator(BasicBlock &BB)
Definition IRMutator.cpp:120
static bool isUnsupportedFunction(Function *F)
Determines whether a function is unsupported by the current mutator's implementation.
Definition IRMutator.cpp:399
static void eliminateDeadCode(Function &F)
Definition IRMutator.cpp:84
static iterator_range< BasicBlock::iterator > getInsertionRange(BasicBlock &BB)
Definition IRMutator.cpp:153
static BasicBlock::iterator getEndIterator(BasicBlock &BB)
Definition IRMutator.cpp:136
static uint64_t getUniqueCaseValue(SmallSet< uint64_t, 4 > &CasesTaken, uint64_t MaxValue, RandomIRBuilder &IB)
Return a case value that is not already taken to make sure we don't have two cases with same value.
Definition IRMutator.cpp:383
Module.h This file contains the declarations for the Module class.
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
uint64_t IntrinsicInst * II
FunctionAnalysisManager FAM
This file defines the Pass Instrumentation classes that provide instrumentation points into the pass ...
const SmallVectorImpl< MachineOperand > & Cond
static ManagedStatic< cl::opt< uint64_t >, CreateSeed > Seed
This file defines the SmallSet class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
This class holds the attributes for a particular argument, parameter, function, or return value.
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
LLVM Basic Block Representation.
iterator begin()
Instruction iterator methods.
LLVM_ABI const_iterator getFirstInsertionPt() const
Returns an iterator to the first instruction in this block that is suitable for inserting a non-PHI i...
const Function * getParent() const
Return the enclosing method, or null if none.
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
InstListType::iterator iterator
Instruction iterators...
bool isEHPad() const
Return true if this basic block is an exception handling block.
LLVM_ABI const CallInst * getTerminatingMustTailCall() const
Returns the call instruction marked 'musttail' prior to the terminating return instruction of this ba...
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
Conditional or Unconditional Branch instruction.
static BranchInst * Create(BasicBlock *IfTrue, InsertPosition InsertBefore=nullptr)
This class represents a function call, abstracting a target machine's calling convention.
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
This class is the base class for the comparison instructions.
void setPredicate(Predicate P)
Set the predicate for this instruction to the specified value.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
This is the shared class of boolean and integer constants.
This is an important base class in LLVM.
Basic Dead Code Elimination pass.
Lightweight error class with error context and mandatory checking.
Class to represent function types.
ArrayRef< Type * > params() const
const BasicBlock & getEntryBlock() const
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
Module * getParent()
Get the module that this global value is contained inside of...
virtual void mutate(Module &M, RandomIRBuilder &IB)
Definition IRMutator.cpp:38
LLVM_ABI void mutateModule(Module &M, int Seed, size_t MaxSize)
Mutate given module.
Definition IRMutator.cpp:66
static LLVM_ABI size_t getModuleSize(const Module &M)
Calculate the size of module as the number of objects in it, i.e.
Definition IRMutator.cpp:62
static std::vector< fuzzerop::OpDescriptor > getDefaultOps()
Definition IRMutator.cpp:98
void mutate(Function &F, RandomIRBuilder &IB) override
Definition IRMutator.cpp:93
void mutate(BasicBlock &BB, RandomIRBuilder &IB) override
Definition IRMutator.cpp:511
void mutate(BasicBlock &BB, RandomIRBuilder &IB) override
Definition IRMutator.cpp:455
void mutate(BasicBlock &BB, RandomIRBuilder &IB) override
Definition IRMutator.cpp:628
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.
Definition IRMutator.cpp:190
void mutate(Function &F, RandomIRBuilder &IB) override
Definition IRMutator.cpp:207
void mutate(Instruction &Inst, RandomIRBuilder &IB) override
Definition IRMutator.cpp:255
LLVM_ABI void setHasNoUnsignedWrap(bool b=true)
Set or clear the nuw flag on this instruction, which must be an operator which supports this flag.
LLVM_ABI bool hasNoNaNs() const LLVM_READONLY
Determine whether the no-NaNs flag is set.
LLVM_ABI bool hasNoUnsignedWrap() const LLVM_READONLY
Determine whether the no unsigned wrap flag is set.
LLVM_ABI bool hasNoInfs() const LLVM_READONLY
Determine whether the no-infs flag is set.
LLVM_ABI void setHasNoSignedZeros(bool B)
Set or clear the no-signed-zeros flag on this instruction, which must be an operator which supports t...
LLVM_ABI bool hasNoSignedZeros() const LLVM_READONLY
Determine whether the no-signed-zeros flag is set.
LLVM_ABI bool hasNoSignedWrap() const LLVM_READONLY
Determine whether the no signed wrap flag is set.
LLVM_ABI void setHasAllowContract(bool B)
Set or clear the allow-contract flag on this instruction, which must be an operator which supports th...
LLVM_ABI void setHasNoSignedWrap(bool b=true)
Set or clear the nsw flag on this instruction, which must be an operator which supports this flag.
LLVM_ABI void setHasNoNaNs(bool B)
Set or clear the no-nans flag on this instruction, which must be an operator which supports this flag...
LLVM_ABI void setHasApproxFunc(bool B)
Set or clear the approximate-math-functions flag on this instruction, which must be an operator which...
LLVM_ABI void setHasAllowReassoc(bool B)
Set or clear the reassociation flag on this instruction, which must be an operator which supports thi...
LLVM_ABI InstListType::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
LLVM_ABI bool isExact() const LLVM_READONLY
Determine whether the exact flag is set.
bool isTerminator() const
LLVM_ABI bool hasAllowReciprocal() const LLVM_READONLY
Determine whether the allow-reciprocal flag is set.
LLVM_ABI void setHasNoInfs(bool B)
Set or clear the no-infs flag on this instruction, which must be an operator which supports this flag...
LLVM_ABI FastMathFlags getFastMathFlags() const LLVM_READONLY
Convenience function for getting all the fast-math flags, which must be an operator which supports th...
LLVM_ABI bool hasApproxFunc() const LLVM_READONLY
Determine whether the approximate-math-functions flag is set.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
LLVM_ABI void setIsExact(bool b=true)
Set or clear the exact flag on this instruction, which must be an operator which supports this flag.
LLVM_ABI void setHasAllowReciprocal(bool B)
Set or clear the allow-reciprocal flag on this instruction, which must be an operator which supports ...
LLVM_ABI bool hasAllowContract() const LLVM_READONLY
Determine whether the allow-contract flag is set.
LLVM_ABI void setFast(bool B)
Set or clear all fast-math-flags on this instruction, which must be an operator which supports this f...
LLVM_ABI bool hasAllowReassoc() const LLVM_READONLY
Determine whether the allow-reassociation flag is set.
Class to represent integer types.
A wrapper class for inspecting calls to intrinsic functions.
This is an important class for using LLVM in a threaded context.
static std::unique_ptr< MemoryBuffer > getMemBuffer(StringRef InputData, StringRef BufferName="", bool RequiresNullTerminator=true)
Open the specified memory range as a MemoryBuffer.
A Module instance is used to store all the information related to an LLVM module.
static PHINode * Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructors - NumReservedValues is a hint for the number of incoming edges that this phi node will h...
Pseudo-analysis pass that exposes the PassInstrumentation to pass managers.
LLVM_ATTRIBUTE_MINSIZE std::enable_if_t<!std::is_same_v< PassT, PassManager > > addPass(PassT &&Pass)
PreservedAnalyses run(IRUnitT &IR, AnalysisManagerT &AM, ExtraArgTs... ExtraArgs)
Run all of the passes in this manager over the given unit of IR.
static ReturnInst * Create(LLVMContext &C, Value *retVal=nullptr, InsertPosition InsertBefore=nullptr)
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
void mutate(BasicBlock &BB, RandomIRBuilder &IB) override
Definition IRMutator.cpp:678
void mutate(Function &F, RandomIRBuilder &IB) override
Definition IRMutator.cpp:656
A SetVector that performs no allocations if smaller than a certain size.
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
size_type count(const T &V) const
count - Return 1 if the element is in the set, 0 otherwise.
std::pair< const_iterator, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
static SwitchInst * Create(Value *Value, BasicBlock *Default, unsigned NumCases, InsertPosition InsertBefore=nullptr)
Analysis pass providing the TargetLibraryInfo.
The instances of the Type class are immutable: once they are created, they are never changed.
static LLVM_ABI Type * getVoidTy(LLVMContext &C)
static LLVM_ABI IntegerType * getInt1Ty(LLVMContext &C)
bool isVoidTy() const
Return true if this is 'void'.
This function has undefined behavior.
void setOperand(unsigned i, Value *Val)
Value * getOperand(unsigned i) const
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
LLVM_ABI void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
const ParentTy * getParent() const
self_iterator getIterator()
A range adaptor for a pair of iterators.
A raw_ostream that writes to an std::string.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
static SourcePred onlyType(Type *Only)
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI void ReplaceInstWithInst(BasicBlock *BB, BasicBlock::iterator &BI, Instruction *I)
Replace the instruction specified by BI with the instruction specified by I.
FunctionAddr VTableAddr Value
LLVM_ABI void describeFuzzerIntOps(std::vector< fuzzerop::OpDescriptor > &Ops)
Getters for the default sets of operations, per general category.
LLVM_ABI Expected< std::unique_ptr< Module > > parseBitcodeFile(MemoryBufferRef Buffer, LLVMContext &Context, ParserCallbacks Callbacks={})
Read the specified bitcode file, returning the module.
LLVM_ABI void WriteBitcodeToFile(const Module &M, raw_ostream &Out, bool ShouldPreserveUseListOrder=false, const ModuleSummaryIndex *Index=nullptr, bool GenerateHash=false, ModuleHash *ModHash=nullptr)
Write the specified module to the specified raw output stream.
LLVM_ABI std::unique_ptr< Module > parseAndVerify(const uint8_t *Data, size_t Size, LLVMContext &Context)
Try to parse module and verify it.
Definition IRMutator.cpp:785
decltype(auto) dyn_cast(const From &Val)
dyn_cast - Return the argument parameter cast to the specified type.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
LLVM_ABI std::unique_ptr< Module > parseModule(const uint8_t *Data, size_t Size, LLVMContext &Context)
Fuzzer friendly interface for the llvm bitcode parser.
Definition IRMutator.cpp:753
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
auto pred_size(const MachineBasicBlock *BB)
LLVM_ABI void describeFuzzerAggregateOps(std::vector< fuzzerop::OpDescriptor > &Ops)
LLVM_ABI size_t writeModule(const Module &M, uint8_t *Dest, size_t MaxSize)
Fuzzer friendly interface for the llvm bitcode printer.
Definition IRMutator.cpp:773
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
ReservoirSampler< ElT, GenT > makeSampler(GenT &RandGen, RangeT &&Items)
LLVM_ABI void describeFuzzerVectorOps(std::vector< fuzzerop::OpDescriptor > &Ops)
iterator_range< filter_iterator< detail::IterOfRange< RangeT >, PredicateT > > make_filter_range(RangeT &&Range, PredicateT Pred)
Convenience function that takes a range of elements and a predicate, and return a new filter_iterator...
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
bool isa(const From &Val)
isa - Return true if the parameter to the template is an instance of one of the template type argu...
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
FunctionAddr VTableAddr uintptr_t uintptr_t Data
DWARFExpression::Operation Op
LLVM_ABI void describeFuzzerFloatOps(std::vector< fuzzerop::OpDescriptor > &Ops)
PassManager< Function > FunctionPassManager
Convenience typedef for a pass manager over functions.
ArrayRef(const T &OneElt) -> ArrayRef< T >
std::string toString(const APInt &I, unsigned Radix, bool Signed, bool formatAsCLiteral=false, bool UpperCase=true, bool InsertSeparators=false)
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)
auto predecessors(const MachineBasicBlock *BB)
iterator_range< pointer_iterator< WrappedIteratorT > > make_pointer_range(RangeT &&Range)
LLVM_ABI void describeFuzzerPointerOps(std::vector< fuzzerop::OpDescriptor > &Ops)
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
T uniform(GenT &Gen, T Min, T Max)
Return a uniformly distributed random value between Min and Max.
constexpr bool isCallableCC(CallingConv::ID CC)
LLVM_ABI bool verifyModule(const Module &M, raw_ostream *OS=nullptr, bool *BrokenDebugInfo=nullptr)
Check a module for errors.
A description of some operation we can build while fuzzing IR.