Go to the documentation of this file.
38 #define DEBUG_TYPE "clone-function"
47 NewBB->
setName(
BB->getName() + NameSuffix);
49 bool hasCalls =
false, hasDynamicAllocas =
false;
50 Module *TheModule =
F ?
F->getParent() :
nullptr;
54 if (DIFinder && TheModule)
59 NewInst->
setName(
I.getName() + NameSuffix);
63 hasCalls |= (isa<CallInst>(
I) && !
I.isDebugOrPseudoInst());
64 if (
const AllocaInst *AI = dyn_cast<AllocaInst>(&
I)) {
65 if (!AI->isStaticAlloca()) {
66 hasDynamicAllocas =
true;
88 assert(NameSuffix &&
"NameSuffix cannot be null!");
92 assert(VMap.
count(&
I) &&
"No mapping from source argument specified!");
108 TypeMapper, Materializer));
115 if (
Argument *NewArg = dyn_cast<Argument>(VMap[&OldArg])) {
116 NewArgAttrs[NewArg->getArgNo()] =
143 "Expected NewFunc to have the same parent, or no parent");
149 if (SPClonedWithinModule)
154 "Expected NewFunc to have different parents, or no parent");
158 "Need parent of new function to maintain debug info invariants");
172 DIFinder ? &*DIFinder :
nullptr);
183 if (
BB.hasAddressTaken()) {
191 Returns.push_back(RI);
201 ModuleLevelChanges =
true;
203 auto mapToSelfIfNew = [&VMap](
MDNode *
N) {
210 if (ISP != SPClonedWithinModule)
217 mapToSelfIfNew(
Type);
219 assert(!SPClonedWithinModule &&
220 "Subprogram should be in DIFinder->subprogram_count()...");
228 OldFunc->getAllMetadata(MDs);
229 for (
auto MD : MDs) {
231 TypeMapper, Materializer));
237 BB = cast<BasicBlock>(VMap[&OldFunc->front()])->getIterator(),
264 for (
auto *Operand : NMD->operands())
269 if (Visited.
insert(MappedUnit).second)
270 NMD->addOperand(MappedUnit);
283 std::vector<Type *> ArgTypes;
290 ArgTypes.push_back(
I.getType());
295 F->getFunctionType()->isVarArg());
299 F->getName(),
F->getParent());
304 if (VMap.
count(&
I) == 0) {
306 VMap[&
I] = &*DestI++;
311 Returns,
"", CodeInfo);
318 struct PruningFunctionCloner {
322 bool ModuleLevelChanges;
323 const char *NameSuffix;
325 bool HostFuncIsStrictFP;
333 : NewFunc(newFunc), OldFunc(oldFunc), VMap(valueMap),
334 ModuleLevelChanges(moduleLevelChanges), NameSuffix(nameSuffix),
343 std::vector<const BasicBlock *> &ToClone);
349 #define INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC) \
350 case Intrinsic::INTRINSIC: \
351 return ROUND_MODE == 1;
352 #define FUNCTION INSTRUCTION
353 #include "llvm/IR/ConstrainedOps.def"
363 if (HostFuncIsStrictFP) {
375 for (
unsigned I = 0,
E = Descriptor.size();
I !=
E; ++
I) {
377 switch (Operand.
Kind) {
382 TParams.push_back(OldInst.
getType());
401 if (isa<CallInst>(OldInst))
403 for (
unsigned I = 0;
I < NumOperands; ++
I) {
407 if (
const auto *CmpI = dyn_cast<FCmpInst>(&OldInst)) {
426 NewInst = II->
clone();
432 void PruningFunctionCloner::CloneBlock(
434 std::vector<const BasicBlock *> &ToClone) {
445 NewBB->
setName(
BB->getName() + NameSuffix);
456 if (
BB->hasAddressTaken()) {
462 bool hasCalls =
false, hasDynamicAllocas =
false, hasStaticAllocas =
false;
471 if (HostFuncIsStrictFP) {
474 if (
auto *Call = dyn_cast<CallInst>(NewInst))
475 Call->addFnAttr(Attribute::StrictFP);
480 if (!isa<PHINode>(NewInst)) {
491 if (NewFunc != OldFunc)
504 NewInst->
setName(II->getName() + NameSuffix);
505 VMap[&*II] = NewInst;
507 hasCalls |= (isa<CallInst>(II) && !II->isDebugOrPseudoInst());
511 if (
auto *CB = dyn_cast<CallBase>(&*II))
512 if (CB->hasOperandBundles())
516 if (
const AllocaInst *AI = dyn_cast<AllocaInst>(II)) {
517 if (isa<ConstantInt>(AI->getArraySize()))
518 hasStaticAllocas =
true;
520 hasDynamicAllocas =
true;
526 bool TerminatorDone =
false;
527 if (
const BranchInst *BI = dyn_cast<BranchInst>(OldTI)) {
528 if (BI->isConditional()) {
534 Cond = dyn_cast_or_null<ConstantInt>(V);
541 ToClone.push_back(Dest);
542 TerminatorDone =
true;
545 }
else if (
const SwitchInst *
SI = dyn_cast<SwitchInst>(OldTI)) {
550 Cond = dyn_cast_or_null<ConstantInt>(V);
556 ToClone.push_back(Dest);
557 TerminatorDone =
true;
561 if (!TerminatorDone) {
566 VMap[OldTI] = NewInst;
569 CodeInfo->
OrigVMap[OldTI] = NewInst;
570 if (
auto *CB = dyn_cast<CallBase>(OldTI))
571 if (CB->hasOperandBundles())
583 hasStaticAllocas &&
BB != &
BB->getParent()->front();
593 bool ModuleLevelChanges,
595 const char *NameSuffix,
597 assert(NameSuffix &&
"NameSuffix cannot be null!");
607 assert(VMap.
count(&II) &&
"No mapping from source argument specified!");
610 PruningFunctionCloner PFC(NewFunc, OldFunc, VMap, ModuleLevelChanges,
611 NameSuffix, CodeInfo);
617 StartingInst = &StartingBB->
front();
621 std::vector<const BasicBlock *> CloneWorklist;
622 PFC.CloneBlock(StartingBB, StartingInst->
getIterator(), CloneWorklist);
623 while (!CloneWorklist.empty()) {
625 CloneWorklist.pop_back();
626 PFC.CloneBlock(
BB,
BB->begin(), CloneWorklist);
637 BasicBlock *NewBB = cast_or_null<BasicBlock>(V);
646 for (
const PHINode &PN : BI.phis()) {
649 if (isa<PHINode>(VMap[&PN]))
650 PHIToResolve.push_back(&PN);
659 TypeMapper, Materializer);
664 for (
unsigned phino = 0,
e = PHIToResolve.size(); phino !=
e;) {
665 const PHINode *OPN = PHIToResolve[phino];
668 BasicBlock *NewBB = cast<BasicBlock>(VMap[OldBB]);
672 for (; phino != PHIToResolve.size() &&
673 PHIToResolve[phino]->
getParent() == OldBB;
675 OPN = PHIToResolve[phino];
676 PHINode *PN = cast<PHINode>(VMap[OPN]);
679 if (
BasicBlock *MappedBlock = cast_or_null<BasicBlock>(V)) {
683 assert(InVal &&
"Unknown input value?");
702 assert(NumPreds < PN->getNumIncomingValues());
704 std::map<BasicBlock *, unsigned> PredCount;
716 for (; (PN = dyn_cast<PHINode>(
I)); ++
I) {
717 for (
const auto &PCI : PredCount) {
719 for (
unsigned NumToRemove = PCI.second; NumToRemove; --NumToRemove)
728 PN = cast<PHINode>(NewBB->
begin());
732 while ((PN = dyn_cast<PHINode>(
I++))) {
735 assert(VMap[&*OldI] == PN &&
"VMap mismatch");
752 for (
unsigned Idx = 0, Size = PHIToResolve.size(); Idx != Size; ++Idx)
753 if (isa<PHINode>(VMap[PHIToResolve[Idx]]))
754 Worklist.
insert(PHIToResolve[Idx]);
757 for (
unsigned Idx = 0; Idx != Worklist.
size(); ++Idx) {
758 const Value *OrigV = Worklist[Idx];
759 auto *
I = dyn_cast_or_null<Instruction>(VMap.
lookup(OrigV));
779 Worklist.
insert(cast<Instruction>(U));
782 I->replaceAllUsesWith(SimpleV);
786 I->eraseFromParent();
804 Worklist.push_back(&*Begin);
805 while (!Worklist.empty()) {
807 if (ReachableBlocks.
insert(
BB).second)
814 UnreachableBlocks.push_back(&
BB);
823 while (
I != NewFunc->
end()) {
824 BranchInst *BI = dyn_cast<BranchInst>(
I->getTerminator());
862 if (
ReturnInst *RI = dyn_cast<ReturnInst>(
I->getTerminator()))
863 Returns.push_back(RI);
878 ModuleLevelChanges, Returns, NameSuffix, CodeInfo);
885 for (
auto *
BB : Blocks)
886 for (
auto &Inst : *
BB)
906 LMap[OrigLoop] = NewLoop;
913 assert(OrigPH &&
"No preheader");
916 VMap[OrigPH] = NewPH;
917 Blocks.push_back(NewPH);
927 Loop *&NewLoop = LMap[CurLoop];
933 assert(OrigParent &&
"Could not find the original parent loop");
934 Loop *NewParentLoop = LMap[OrigParent];
935 assert(NewParentLoop &&
"Could not find the new parent loop");
943 Loop *&NewLoop = LMap[CurLoop];
944 assert(NewLoop &&
"Expecting new loop to be allocated");
956 Blocks.push_back(NewBB);
963 LMap[CurLoop]->moveToHeader(cast<BasicBlock>(VMap[
BB]));
968 cast<BasicBlock>(VMap[IDomBB]));
972 F->getBasicBlockList().splice(Before->
getIterator(),
F->getBasicBlockList(),
974 F->getBasicBlockList().splice(Before->
getIterator(),
F->getBasicBlockList(),
987 "There must be a single edge between PredBB and BB!");
992 for (;
PHINode *PN = dyn_cast<PHINode>(BI); ++BI)
1009 for (; StopAt != &*BI &&
BB->getTerminator() != &*BI; ++BI) {
1011 New->setName(BI->getName());
1012 New->insertBefore(NewTerm);
1013 ValueMapping[&*BI] = New;
1016 for (
unsigned i = 0,
e = New->getNumOperands();
i !=
e; ++
i)
1017 if (
Instruction *Inst = dyn_cast<Instruction>(New->getOperand(
i))) {
1018 auto I = ValueMapping.
find(Inst);
1019 if (
I != ValueMapping.
end())
1020 New->setOperand(
i,
I->second);
1032 for (
auto *ScopeList : NoAliasDeclScopes) {
1033 for (
auto &
MDOperand : ScopeList->operands()) {
1038 auto ScopeName = SNANode.
getName();
1039 if (!ScopeName.empty())
1046 ClonedScopes.
insert(std::make_pair(MD, NewScope));
1055 auto CloneScopeList = [&](
const MDNode *ScopeList) ->
MDNode * {
1056 bool NeedsReplacement =
false;
1058 for (
auto &MDOp : ScopeList->operands()) {
1059 if (
MDNode *MD = dyn_cast<MDNode>(MDOp)) {
1060 if (
auto *NewMD = ClonedScopes.
lookup(MD)) {
1061 NewScopeList.push_back(NewMD);
1062 NeedsReplacement =
true;
1065 NewScopeList.push_back(MD);
1068 if (NeedsReplacement)
1073 if (
auto *Decl = dyn_cast<NoAliasScopeDeclInst>(
I))
1074 if (
auto *NewScopeList = CloneScopeList(Decl->getScopeList()))
1075 Decl->setScopeList(NewScopeList);
1077 auto replaceWhenNeeded = [&](
unsigned MD_ID) {
1078 if (
const MDNode *CSNoAlias =
I->getMetadata(MD_ID))
1079 if (
auto *NewScopeList = CloneScopeList(CSNoAlias))
1080 I->setMetadata(MD_ID, NewScopeList);
1082 replaceWhenNeeded(LLVMContext::MD_noalias);
1083 replaceWhenNeeded(LLVMContext::MD_alias_scope);
1089 if (NoAliasDeclScopes.
empty())
1094 << NoAliasDeclScopes.
size() <<
" node(s)\n");
1106 if (NoAliasDeclScopes.
empty())
1111 << NoAliasDeclScopes.
size() <<
" node(s)\n");
1127 if (
auto *Decl = dyn_cast<NoAliasScopeDeclInst>(&
I))
1128 NoAliasDeclScopes.push_back(Decl->getScopeList());
1135 if (
auto *Decl = dyn_cast<NoAliasScopeDeclInst>(&
I))
1136 NoAliasDeclScopes.push_back(Decl->getScopeList());
This class represents an incoming formal argument to a Function.
bool isIntrinsic() const
isIntrinsic - Returns true if the function's name starts with "llvm.".
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< arg_iterator > args()
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
Return a value (possibly void), from a function.
This struct can be used to capture information about code being cloned, while it is being cloned.
Value handle that is nullable, but tries to track the Value.
A parsed version of the target data layout string in and methods for querying it.
enum llvm::Intrinsic::IITDescriptor::IITDescriptorKind Kind
Function * getDeclaration(Module *M, ID id, ArrayRef< Type * > Tys=None)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
Metadata * MapMetadata(const Metadata *MD, ValueToValueMapTy &VM, RemapFlags Flags=RF_None, ValueMapTypeRemapper *TypeMapper=nullptr, ValueMaterializer *Materializer=nullptr)
Lookup or compute a mapping for a piece of metadata.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
InstListType::iterator iterator
Instruction iterators...
Loop * cloneLoopWithPreheader(BasicBlock *Before, BasicBlock *LoopDomBB, Loop *OrigLoop, ValueToValueMapTy &VMap, const Twine &NameSuffix, LoopInfo *LI, DominatorTree *DT, SmallVectorImpl< BasicBlock * > &Blocks)
Clones a loop OrigLoop.
const Function * getParent() const
Return the enclosing method, or null if none.
const BasicBlockListType & getBasicBlockList() const
Get the underlying elements of the Function...
void applyUpdates(ArrayRef< DominatorTree::UpdateType > Updates)
Submit updates to all available trees.
Represents a single loop in the control flow graph.
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
size_type size() const
Determine the number of elements in the SetVector.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
unsigned pred_size(MachineBasicBlock *BB)
A handle to a particular switch case.
DISubprogram * getSubprogram() const
Get the attached subprogram.
const BasicBlock & getEntryBlock() const
Value * removeIncomingValue(unsigned Idx, bool DeletePHIIfEmpty=true)
Remove an incoming value.
void DeleteDeadBlocks(ArrayRef< BasicBlock * > BBs, DomTreeUpdater *DTU=nullptr, bool KeepOneInputPHIs=false)
Delete the specified blocks from BB.
static FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
static AttributeList get(LLVMContext &C, ArrayRef< std::pair< unsigned, Attribute >> Attrs)
Create an AttributeList with the specified parameters in it.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Value * MapValue(const Value *V, ValueToValueMapTy &VM, RemapFlags Flags=RF_None, ValueMapTypeRemapper *TypeMapper=nullptr, ValueMaterializer *Materializer=nullptr)
Look up or compute a value in the value map.
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
The instances of the Type class are immutable: once they are created, they are never changed.
SymbolTableList< BasicBlock >::iterator eraseFromParent()
Unlink 'this' from the containing function and delete it.
static constexpr UpdateKind Insert
DomTreeNodeBase< NodeT > * getNode(const NodeT *BB) const
getNode - return the (Post)DominatorTree node for the specified basic block.
AttributeSet getFnAttrs() const
The function attributes are returned.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
DiagnosticInfoOptimizationBase::Argument NV
auto successors(MachineBasicBlock *BB)
This is a class that can be implemented by clients to remap types when cloning constants and instruct...
const BasicBlock * getSinglePredecessor() const
Return the predecessor of this block if it has a single predecessor block.
LLVM_NODISCARD T pop_back_val()
static StringRef getPredicateName(Predicate P)
DomTreeNodeBase * getIDom() const
iterator_range< compile_unit_iterator > compile_units() const
Utility to find all debug info in a module.
void setIncomingValue(unsigned i, Value *V)
MDNode * createAnonymousAliasScope(MDNode *Domain, StringRef Name=StringRef())
Return metadata appropriate for an alias scope root node.
bool empty() const
empty - Check if the array is empty.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
bool mayHaveSideEffects() const
Return true if the instruction may have side effects.
LLVM Basic Block Representation.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
BasicBlockT * getCaseSuccessor() const
Resolves successor for current case.
This is the shared class of boolean and integer constants.
LoopT * getParentLoop() const
Return the parent loop if it exists or nullptr for top level loops.
void RemapInstruction(Instruction *I, ValueToValueMapTy &VM, RemapFlags Flags=RF_None, ValueMapTypeRemapper *TypeMapper=nullptr, ValueMaterializer *Materializer=nullptr)
Convert the instruction operands from referencing the current values into those specified by VM.
Intrinsic::ID getConstrainedIntrinsicID(const Instruction &Instr)
Returns constrained intrinsic id to represent the given instruction in strictfp function.
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
Value * getIncomingValue(unsigned i) const
Return incoming value number x.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
void addChildLoop(LoopT *NewChild)
Add the specified loop to be a child of this loop.
iterator begin()
Instruction iterator methods.
void remapInstructionsInBlocks(const SmallVectorImpl< BasicBlock * > &Blocks, ValueToValueMapTy &VMap)
Remaps instructions in Blocks using the mapping in VMap.
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
void addTopLevelLoop(LoopT *New)
This adds the specified loop to the collection of top-level loops.
std::vector< WeakTrackingVH > OperandBundleCallSites
All cloned call sites that have operand bundles attached are appended to this vector.
Value * getIncomingValueForBlock(const BasicBlock *BB) const
ArrayRef< BlockT * > getBlocks() const
Get a list of the basic blocks which make up this loop.
bool hasFnAttr(Attribute::AttrKind Kind) const
Return true if the attribute exists for the function.
auto predecessors(MachineBasicBlock *BB)
void copyAttributesFrom(const Function *Src)
copyAttributesFrom - copy all additional attributes (those not needed to create a Function) from the ...
void addMetadata(unsigned KindID, MDNode &MD)
Add a metadata attachment.
void setName(const Twine &Name)
Change the name of the value.
bool hasPersonalityFn() const
Check whether this function has a personality function.
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
SmallVector< const LoopT *, 4 > getLoopsInPreorder() const
Return all loops in the loop nest rooted by the loop in preorder, with siblings in forward program or...
void changeImmediateDominator(DomTreeNodeBase< NodeT > *N, DomTreeNodeBase< NodeT > *NewIDom)
changeImmediateDominator - This method is used to update the dominator tree information when a node's...
size_type count(const KeyT &Val) const
Return 1 if the specified key is in the map, 0 otherwise.
unsigned getNumIncomingValues() const
Return the number of incoming edges.
@ RF_NoModuleLevelChanges
If this flag is set, the remapper knows that only local values within a function (such as an instruct...
LoopT * AllocateLoop(ArgsTy &&... Args)
AttributeList getAttributes() const
Return the attribute list for this Function.
void processSubprogram(DISubprogram *SP)
Process subprogram.
void cloneAndAdaptNoAliasScopes(ArrayRef< MDNode * > NoAliasDeclScopes, ArrayRef< BasicBlock * > NewBlocks, LLVMContext &Context, StringRef Ext)
Clone the specified noalias decl scopes.
BasicBlock * CloneBasicBlock(const BasicBlock *BB, ValueToValueMapTy &VMap, const Twine &NameSuffix="", Function *F=nullptr, ClonedCodeInfo *CodeInfo=nullptr, DebugInfoFinder *DIFinder=nullptr)
Return a copy of the specified basic block, but without embedding the block into a particular functio...
BasicBlock * DuplicateInstructionsInSplitBetween(BasicBlock *BB, BasicBlock *PredBB, Instruction *StopAt, ValueToValueMapTy &ValueMapping, DomTreeUpdater &DTU)
Split edge between BB and PredBB and duplicate all non-Phi instructions from BB between its beginning...
AttributeSet getRetAttrs() const
The attributes for the ret value are returned.
This is an important base class in LLVM.
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
auto count(R &&Range, const E &Element)
Wrapper function around std::count to count the number of times an element Element occurs in the give...
Module * getParent()
Get the module that this global value is contained inside of...
void setIncomingBlock(unsigned i, BasicBlock *BB)
void getIntrinsicInfoTableEntries(ID id, SmallVectorImpl< IITDescriptor > &T)
Return the IIT table descriptor for the specified intrinsic into an array of IITDescriptors.
void emplace(ArgTypes &&... Args)
Create a new object by constructing it in place with the given arguments.
This is an important class for using LLVM in a threaded context.
static BranchInst * Create(BasicBlock *IfTrue, Instruction *InsertBefore=nullptr)
LoopT * getLoopFor(const BlockT *BB) const
Return the inner most loop that BB lives in.
BlockT * getLoopPreheader() const
If there is a preheader for this loop, return it.
void adaptNoAliasScopes(llvm::Instruction *I, const DenseMap< MDNode *, MDNode * > &ClonedScopes, LLVMContext &Context)
Adapt the metadata for the specified instruction according to the provided mapping.
Value * simplifyInstruction(Instruction *I, const SimplifyQuery &Q, OptimizationRemarkEmitter *ORE=nullptr)
See if we can compute a simplified version of this instruction.
static MDString * get(LLVMContext &Context, StringRef Str)
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StandardInstrumentations SI(Debug, VerifyEach)
void cloneNoAliasScopes(ArrayRef< MDNode * > NoAliasDeclScopes, DenseMap< MDNode *, MDNode * > &ClonedScopes, StringRef Ext, LLVMContext &Context)
Duplicate the specified list of noalias decl scopes.
void setPersonalityFn(Constant *Fn)
A Module instance is used to store all the information related to an LLVM module.
static bool hasRoundingModeOperand(Intrinsic::ID CIID)
bool insert(const value_type &X)
Insert a new element into the SetVector.
iterator_range< subprogram_iterator > subprograms() const
Instruction * clone() const
Create a copy of 'this' instruction that is identical in all ways except the following:
unsigned subprogram_count() const
void CloneAndPruneFunctionInto(Function *NewFunc, const Function *OldFunc, ValueToValueMapTy &VMap, bool ModuleLevelChanges, SmallVectorImpl< ReturnInst * > &Returns, const char *NameSuffix="", ClonedCodeInfo *CodeInfo=nullptr)
This works exactly like CloneFunctionInto, except that it does some simple constant prop and DCE on t...
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
bool isInstructionTriviallyDead(Instruction *I, const TargetLibraryInfo *TLI=nullptr)
Return true if the result produced by the instruction is not used, and the instruction will return.
SmallVector< MachineOperand, 4 > Cond
StringRef - Represent a constant reference to a string, i.e.
DenseMap< const Value *, const Value * > OrigVMap
Like VMap, but maps only unsimplified instructions.
void identifyNoAliasScopesToClone(ArrayRef< BasicBlock * > BBs, SmallVectorImpl< MDNode * > &NoAliasDeclScopes)
Find the 'llvm.experimental.noalias.scope.decl' intrinsics in the specified basic blocks and extract ...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Type * getType() const
All values are typed, get the type of this value.
void CloneAndPruneIntoFromInst(Function *NewFunc, const Function *OldFunc, const Instruction *StartingInst, ValueToValueMapTy &VMap, bool ModuleLevelChanges, SmallVectorImpl< ReturnInst * > &Returns, const char *NameSuffix="", ClonedCodeInfo *CodeInfo=nullptr)
This works like CloneAndPruneFunctionInto, except that it does not clone the entire function.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
static const Function * getParent(const Value *V)
void append_range(Container &C, Range &&R)
Wrapper function to append a range to a container.
self_iterator getIterator()
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Function * CloneFunction(Function *F, ValueToValueMapTy &VMap, ClonedCodeInfo *CodeInfo=nullptr)
Return a copy of the specified function and add it to that function's module.
StringRef getName() const
Return a constant reference to the value's name.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
DomTreeNodeBase< NodeT > * addNewBlock(NodeT *BB, NodeT *DomBB)
Add a new node to the dominator tree information.
bool ContainsCalls
This is set to true if the cloned code contains a normal call instruction.
const Instruction & front() const
@ RF_IgnoreMissingLocals
If this flag is set, the remapper ignores missing function-local entries (Argument,...
BasicBlock * SplitEdge(BasicBlock *From, BasicBlock *To, DominatorTree *DT=nullptr, LoopInfo *LI=nullptr, MemorySSAUpdater *MSSAU=nullptr, const Twine &BBName="")
Split the edge connecting the specified blocks, and return the newly created basic block between From...
StringRef getName() const
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
bool ConstantFoldTerminator(BasicBlock *BB, bool DeleteDeadConditions=false, const TargetLibraryInfo *TLI=nullptr, DomTreeUpdater *DTU=nullptr)
If a terminator instruction is predicated on a constant value, convert it into an unconditional branc...
const MDNode * getDomain() const
Get the MDNode for this AliasScopeNode's domain.
BlockT * getHeader() const
NamedMDNode * getOrInsertNamedMetadata(StringRef Name)
Return the named MDNode in the module with the specified name.
iterator find(const KeyT &Val)
Constant * getPersonalityFn() const
Get the personality function associated with this function.
const BasicBlock & front() const
const InstListType & getInstList() const
Return the underlying instruction list container.
unsigned getNumOperands() const
void addBasicBlockToLoop(BlockT *NewBB, LoopInfoBase< BlockT, LoopT > &LI)
This method is used by other analyses to update loop information.
This is a simple wrapper around an MDNode which provides a higher-level interface by hiding the detai...
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&... Args)
const BasicBlock * getParent() const
void deleteValue()
Delete a pointer to a generic Value.
static BlockAddress * get(Function *F, BasicBlock *BB)
Return a BlockAddress for the specified function and basic block.
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
size_t size() const
size - Get the array size.
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...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
A SetVector that performs no allocations if smaller than a certain size.
void CloneFunctionInto(Function *NewFunc, const Function *OldFunc, ValueToValueMapTy &VMap, CloneFunctionChangeType Changes, SmallVectorImpl< ReturnInst * > &Returns, const char *NameSuffix="", ClonedCodeInfo *CodeInfo=nullptr, ValueMapTypeRemapper *TypeMapper=nullptr, ValueMaterializer *Materializer=nullptr)
Clone OldFunc into NewFunc, transforming the old arguments into references to VMap values.
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
ValueT lookup(const KeyT &Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
an instruction to allocate memory on the stack
Value * getOperand(unsigned i) const
This is a type descriptor which explains the type requirements of an intrinsic.
Conditional or Unconditional Branch instruction.
iterator_range< type_iterator > types() const
bool ContainsDynamicAllocas
This is set to true if the cloned code contains a 'dynamic' alloca.
void processInstruction(const Module &M, const Instruction &I)
Process a single instruction and collect debug info anchors.
bool contains(ConstPtrType Ptr) const
AttributeSet getParamAttrs(unsigned ArgNo) const
The attributes for the argument or parameter at the given index are returned.
This is a class that can be implemented by clients to materialize Values on demand.
void setAttributes(AttributeList Attrs)
Set the attribute list for this Function.
LLVM Value Representation.
iterator_range< user_iterator > users()
ArgKind getArgumentKind() const
bool isConditional() const
Tracking metadata reference owned by Metadata.
BasicBlock * getSuccessor(unsigned i) const
static constexpr UpdateKind Delete
InstListType::const_iterator const_iterator
Class to represent function types.
BasicBlockListType::iterator iterator
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.