49 #define DEBUG_TYPE "local"
51 STATISTIC(NumRemoved,
"Number of unreachable basic blocks removed");
70 if (
BranchInst *BI = dyn_cast<BranchInst>(T)) {
71 if (BI->isUnconditional())
return false;
75 if (
ConstantInt *Cond = dyn_cast<ConstantInt>(BI->getCondition())) {
78 BasicBlock *Destination = Cond->getZExtValue() ? Dest1 : Dest2;
79 BasicBlock *OldDest = Cond->getZExtValue() ? Dest2 : Dest1;
101 assert(BI->getParent() &&
"Terminator not inserted in block!");
106 Value *Cond = BI->getCondition();
107 BI->eraseFromParent();
108 if (DeleteDeadConditions)
123 if (isa<UnreachableInst>(DefaultDest->getFirstNonPHIOrDbg()) &&
124 SI->getNumCases() > 0) {
125 TheOnlyDest =
SI->case_begin().getCaseSuccessor();
132 if (i.getCaseValue() == CI) {
133 TheOnlyDest = i.getCaseSuccessor();
139 if (i.getCaseSuccessor() == DefaultDest) {
141 unsigned NCases =
SI->getNumCases();
150 mdconst::dyn_extract<ConstantInt>(MD->
getOperand(MD_i));
155 unsigned idx = i.getCaseIndex();
156 Weights[0] += Weights[idx+1];
162 createBranchWeights(Weights));
165 DefaultDest->removePredecessor(
SI->getParent());
174 if (i.getCaseSuccessor() != TheOnlyDest) TheOnlyDest =
nullptr;
177 if (CI && !TheOnlyDest) {
180 TheOnlyDest =
SI->getDefaultDest();
191 for (
unsigned i = 0, e =
SI->getNumSuccessors(); i != e; ++i) {
194 if (Succ == TheOnlyDest)
195 TheOnlyDest =
nullptr;
201 Value *Cond =
SI->getCondition();
202 SI->eraseFromParent();
203 if (DeleteDeadConditions)
208 if (
SI->getNumCases() == 1) {
218 SI->getDefaultDest());
222 mdconst::dyn_extract<ConstantInt>(MD->
getOperand(2));
224 mdconst::dyn_extract<ConstantInt>(MD->
getOperand(1));
225 assert(SICase && SIDef);
230 SIDef->getValue().getZExtValue()));
234 SI->eraseFromParent();
243 dyn_cast<BlockAddress>(IBI->getAddress()->stripPointerCasts())) {
244 BasicBlock *TheOnlyDest = BA->getBasicBlock();
248 for (
unsigned i = 0, e = IBI->getNumDestinations(); i != e; ++i) {
249 if (IBI->getDestination(i) == TheOnlyDest)
250 TheOnlyDest =
nullptr;
255 IBI->eraseFromParent();
256 if (DeleteDeadConditions)
284 if (!I->
use_empty() || isa<TerminatorInst>(
I))
return false;
287 if (isa<LandingPadInst>(I))
293 if (DDI->getAddress())
309 if (II->getIntrinsicID() == Intrinsic::stacksave)
313 if (II->getIntrinsicID() == Intrinsic::lifetime_start ||
314 II->getIntrinsicID() == Intrinsic::lifetime_end)
315 return isa<UndefValue>(II->getArgOperand(1));
318 if (II->getIntrinsicID() == Intrinsic::assume) {
319 if (
ConstantInt *Cond = dyn_cast<ConstantInt>(II->getArgOperand(0)))
320 return !Cond->isZero();
329 if (
Constant *
C = dyn_cast<Constant>(CI->getArgOperand(0)))
330 return C->isNullValue() || isa<UndefValue>(
C);
369 }
while (!DeadInsts.
empty());
385 for (++UI; UI != UE; ++UI) {
401 I = cast<Instruction>(*
I->user_begin())) {
407 if (!Visited.
insert(
I).second) {
424 bool MadeChange =
false;
435 assert(!BI->isTerminator());
471 if (!isa<PHINode>(BB->
begin()))
480 while (
PHINode *PN = dyn_cast<PHINode>(PhiIt)) {
482 Value *OldPhiIt = PhiIt;
490 if (PhiIt != OldPhiIt) PhiIt = &BB->
front();
502 while (
PHINode *PN = dyn_cast<PHINode>(DestBB->
begin())) {
503 Value *NewVal = PN->getIncomingValue(0);
507 PN->eraseFromParent();
511 assert(PredBB &&
"Block doesn't have a single predecessor!");
549 return First == Second || isa<UndefValue>(First) || isa<UndefValue>(Second);
558 assert(*
succ_begin(BB) == Succ &&
"Succ is not successor of BB!");
578 if (BBPN && BBPN->getParent() == BB) {
581 if (BBPreds.
count(IBB) &&
585 << Succ->
getName() <<
" is conflicting with "
586 << BBPN->getName() <<
" with regard to common predecessor "
598 if (BBPreds.
count(IBB) &&
601 << Succ->
getName() <<
" is conflicting with regard to common "
602 <<
"predecessor " << IBB->
getName() <<
"\n");
629 if (!isa<UndefValue>(OldVal)) {
630 assert((!IncomingValues.
count(BB) ||
631 IncomingValues.
find(BB)->second == OldVal) &&
632 "Expected OldVal to match incoming value from BB!");
634 IncomingValues.
insert(std::make_pair(BB, OldVal));
639 if (It != IncomingValues.
end())
return It->second;
658 if (!isa<UndefValue>(V))
659 IncomingValues.
insert(std::make_pair(BB, V));
673 if (!isa<UndefValue>(V))
continue;
677 if (It == IncomingValues.
end())
continue;
694 assert(OldVal &&
"No entry in PHI for Pred BB!");
711 if (isa<PHINode>(OldVal) && cast<PHINode>(OldVal)->
getParent() == BB) {
712 PHINode *OldValPN = cast<PHINode>(OldVal);
729 for (
unsigned i = 0, e = BBPreds.
size(); i != e; ++i) {
752 "TryToSimplifyUncondBranchFromEmptyBlock called on entry block!");
756 if (BB == Succ)
return false;
774 if (!Succ->getSinglePredecessor()) {
776 while (isa<PHINode>(*BBI)) {
777 for (
Use &U : BBI->uses()) {
778 if (
PHINode* PN = dyn_cast<PHINode>(U.getUser())) {
779 if (PN->getIncomingBlock(U) != BB)
789 DEBUG(
dbgs() <<
"Killing Trivial BB: \n" << *BB);
791 if (isa<PHINode>(Succ->begin())) {
805 if (Succ->getSinglePredecessor()) {
815 assert(PN->use_empty() &&
"There shouldn't be any uses here!");
816 PN->eraseFromParent();
822 if (!Succ->hasName()) Succ->takeName(BB);
837 struct PHIDenseMapInfo {
838 static PHINode *getEmptyKey() {
841 static PHINode *getTombstoneKey() {
844 static unsigned getHashValue(
PHINode *PN) {
853 if (LHS == getEmptyKey() || LHS == getTombstoneKey() ||
854 RHS == getEmptyKey() || RHS == getTombstoneKey())
864 bool Changed =
false;
866 auto Inserted = PHISet.
insert(PN);
867 if (!Inserted.second) {
889 if (
AllocaInst *AI = dyn_cast<AllocaInst>(V)) {
895 if (AI->getAlignment() >= PrefAlign)
896 return AI->getAlignment();
897 AI->setAlignment(PrefAlign);
901 if (
auto *GO = dyn_cast<GlobalObject>(V)) {
906 if (!GO->isStrongDefinitionForLinker())
909 if (GO->getAlignment() >= PrefAlign)
910 return GO->getAlignment();
915 if (!GO->hasSection() || GO->getAlignment() == 0)
916 GO->setAlignment(PrefAlign);
917 return GO->getAlignment();
933 "getOrEnforceKnownAlignment expects a pointer!");
936 APInt KnownZero(BitWidth, 0), KnownOne(BitWidth, 0);
938 unsigned TrailZ = KnownZero.countTrailingOnes();
942 TrailZ =
std::min(TrailZ,
unsigned(
sizeof(
unsigned) * CHAR_BIT - 1));
949 if (PrefAlign > Align)
970 DVI->getOffset() == 0 &&
971 DVI->getVariable() == DIVar)
983 assert(DIVar &&
"Missing variable");
1010 assert(DIVar &&
"Missing variable");
1033 if (
auto DDI = dyn_cast<DbgDeclareInst>(BI))
1039 for (
auto &
I : Dbgs) {
1052 else if (
LoadInst *LI = dyn_cast<LoadInst>(U))
1054 else if (
CallInst *CI = dyn_cast<CallInst>(U)) {
1058 DIB.insertDbgValueIntrinsic(AI, 0, DDI->
getVariable(),
1088 assert(DIVar &&
"Missing variable");
1096 NewDIExpr.
push_back(dwarf::DW_OP_deref);
1098 NewDIExpr.
append(DIExpr->elements_begin(), DIExpr->elements_end());
1105 Builder.
insertDeclare(NewAllocaAddress, DIVar, DIExpr, Loc, BB);
1131 while (BBI != BBE) {
1132 if (!BBI->use_empty())
1142 NewCall->takeName(II);
1163 bool Changed =
false;
1175 if (II->getIntrinsicID() == Intrinsic::assume) {
1176 bool MakeUnreachable =
false;
1177 if (isa<UndefValue>(II->getArgOperand(0)))
1178 MakeUnreachable =
true;
1180 dyn_cast<ConstantInt>(II->getArgOperand(0)))
1181 MakeUnreachable = Cond->isZero();
1183 if (MakeUnreachable) {
1191 if (
CallInst *CI = dyn_cast<CallInst>(BBI)) {
1192 if (CI->doesNotReturn()) {
1197 if (!isa<UnreachableInst>(BBI)) {
1211 if (
SI->isVolatile())
continue;
1213 Value *Ptr =
SI->getOperand(1);
1215 if (isa<UndefValue>(Ptr) ||
1216 (isa<ConstantPointerNull>(Ptr) &&
1217 SI->getPointerAddressSpace() == 0)) {
1227 Value *Callee = II->getCalledValue();
1228 if (isa<ConstantPointerNull>(Callee) || isa<UndefValue>(Callee)) {
1232 if (II->use_empty() && II->onlyReadsMemory()) {
1235 II->getUnwindDest()->removePredecessor(II->getParent());
1245 if (Reachable.
insert(*SI).second)
1247 }
while (!Worklist.
empty());
1262 assert(Reachable.
size() < F.
size());
1263 NumRemoved += F.
size()-Reachable.
size();
1268 if (Reachable.
count(BB))
1273 (*SI)->removePredecessor(BB);
1274 BB->dropAllReferences();
1290 for (
unsigned i = 0, n = Metadata.
size(); i < n; ++i) {
1291 unsigned Kind = Metadata[i].first;
1293 MDNode *KMD = Metadata[i].second;
1339 DEBUG(
dbgs() <<
"Replace dominated use of '"
1341 << *To <<
" in " << *U <<
"\n");
static bool markAliveBlocks(Function &F, SmallPtrSetImpl< BasicBlock * > &Reachable)
iplist< Instruction >::iterator eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing basic block and deletes it...
void push_back(const T &Elt)
use_iterator_impl< Use > use_iterator
A parsed version of the target data layout string in and methods for querying it. ...
ConstantIntTy * getCaseValue()
Resolves case value for current case.
void removePredecessor(BasicBlock *Pred, bool DontDeleteUselessPHIs=false)
Notify the BasicBlock that the predecessor Pred is no longer able to reach it.
static unsigned enforceKnownAlignment(Value *V, unsigned Align, unsigned PrefAlign, const DataLayout &DL)
enforceKnownAlignment - If the specified pointer points to an object that we control, modify the object's alignment to PrefAlign.
void addIncoming(Value *V, BasicBlock *BB)
addIncoming - Add an incoming value to the end of the PHI list
unsigned getOrEnforceKnownAlignment(Value *V, unsigned PrefAlign, const DataLayout &DL, const Instruction *CxtI=nullptr, AssumptionCache *AC=nullptr, const DominatorTree *DT=nullptr)
getOrEnforceKnownAlignment - If the specified pointer has an alignment that we can determine...
LLVM Argument representation.
uint64_t getZExtValue() const
Get zero extended value.
STATISTIC(NumFunctions,"Total number of functions")
static bool CanPropagatePredecessorsForPHIs(BasicBlock *BB, BasicBlock *Succ)
CanPropagatePredecessorsForPHIs - Return true if we can fold BB, an almost-empty BB ending in an unco...
DbgDeclareInst * FindAllocaDbgDeclare(Value *V)
FindAllocaDbgDeclare - Finds the llvm.dbg.declare intrinsic corresponding to an alloca, if any.
DenseSet - This implements a dense probed hash-table based set.
This class represents zero extension of integer types.
unsigned getNumOperands() const
unsigned getNumOperands() const
Return number of MDNode operands.
unsigned getPointerTypeSizeInBits(Type *) const
Layout pointer size, in bits, based on the type.
value_op_iterator value_op_begin()
static MDNode * getMostGenericAliasScope(MDNode *A, MDNode *B)
CallInst - This class represents a function call, abstracting a target machine's calling convention...
size_type count(PtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
void computeKnownBits(Value *V, APInt &KnownZero, APInt &KnownOne, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr)
Determine which bits of V are known to be either zero or one and return them in the KnownZero/KnownOn...
void MergeBasicBlockIntoOnlyPred(BasicBlock *BB, DominatorTree *DT=nullptr)
MergeBasicBlockIntoOnlyPred - BB is a block with one predecessor and its predecessor is known to have...
bool mayHaveSideEffects() const
mayHaveSideEffects - Return true if the instruction may have side effects.
static Constant * getIntToPtr(Constant *C, Type *Ty, bool OnlyIfReduced=false)
A cache of .assume calls within a function.
value_op_iterator value_op_end()
const Function * getParent() const
Return the enclosing method, or null if none.
static void replaceUndefValuesInPhi(PHINode *PN, const IncomingValueMap &IncomingValues)
Replace the incoming undef values to a phi with the values from a block-to-value map.
bool SimplifyInstructionsInBlock(BasicBlock *BB, const TargetLibraryInfo *TLI=nullptr)
SimplifyInstructionsInBlock - Scan the specified basic block and try to simplify any instructions in ...
const Instruction & front() const
This class represents a sign extension of integer types.
LoadInst - an instruction for reading from memory.
Value * CreateICmpEQ(Value *LHS, Value *RHS, const Twine &Name="")
void RemovePredecessorAndSimplify(BasicBlock *BB, BasicBlock *Pred)
RemovePredecessorAndSimplify - Like BasicBlock::removePredecessor, this method is called when we're a...
BranchInst * CreateCondBr(Value *Cond, BasicBlock *True, BasicBlock *False, MDNode *BranchWeights=nullptr)
Create a conditional 'br Cond, TrueDest, FalseDest' instruction.
static Value * selectIncomingValueForBlock(Value *OldVal, BasicBlock *BB, IncomingValueMap &IncomingValues)
Determines the value to use as the phi node input for a block.
unsigned replaceDominatedUsesWith(Value *From, Value *To, DominatorTree &DT, const BasicBlockEdge &Edge)
Replace each use of 'From' with 'To' if that use is dominated by the given edge.
Instruction * insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset, DILocalVariable *VarInfo, DIExpression *Expr, const DILocation *DL, BasicBlock *InsertAtEnd)
Insert a new llvm.dbg.value intrinsic call.
const CallInst * isFreeCall(const Value *I, const TargetLibraryInfo *TLI)
isFreeCall - Returns non-null if the value is a call to the builtin free()
StringRef getName() const
Return a constant reference to the value's name.
block_iterator block_end()
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
iterator begin()
Instruction iterator methods.
bool isArrayAllocation() const
isArrayAllocation - Return true if there is an allocation size parameter to the allocation instructio...
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
BlockAddress - The address of a basic block.
Value * removeIncomingValue(unsigned Idx, bool DeletePHIIfEmpty=true)
removeIncomingValue - Remove an incoming value.
bool isIdenticalTo(const Instruction *I) const
isIdenticalTo - Return true if the specified instruction is exactly identical to the current one...
static CallInst * Create(Value *Func, ArrayRef< Value * > Args, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
const APInt & getValue() const
Return the constant as an APInt value reference.
T LLVM_ATTRIBUTE_UNUSED_RESULT pop_back_val()
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Instruction * insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo, DIExpression *Expr, const DILocation *DL, BasicBlock *InsertAtEnd)
Insert a new llvm.dbg.declare intrinsic call.
A Use represents the edge between a Value definition and its users.
bool ConstantFoldTerminator(BasicBlock *BB, bool DeleteDeadConditions=false, const TargetLibraryInfo *TLI=nullptr)
ConstantFoldTerminator - If a terminator instruction is predicated on a constant value, convert it into an unconditional branch to the constant destination.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
const Value * getCalledValue() const
getCalledValue - Get a pointer to the function that is invoked by this instruction ...
bool hasAddressTaken() const
Returns true if there are any uses of this basic block other than direct branches, switches, etc.
Number of individual test Apply this number of consecutive mutations to each input exit after the first new interesting input is found the minimized corpus is saved into the first input directory Number of jobs to run If min(jobs, NumberOfCpuCores()/2)\" is used.") FUZZER_FLAG_INT(reload
bool canSimplifyInvokeNoUnwind(const Function *F)
static const unsigned MaximumAlignment
block_iterator block_begin()
Interval::succ_iterator succ_begin(Interval *I)
succ_begin/succ_end - define methods so that Intervals may be used just like BasicBlocks can with the...
user_iterator_impl< User > user_iterator
static void changeToCall(InvokeInst *II)
changeToCall - Convert the specified invoke into a normal call.
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
Value handle that is nullable, but tries to track the Value.
static bool areAllUsesEqual(Instruction *I)
areAllUsesEqual - Check whether the uses of a value are all the same.
static MDNode * intersect(MDNode *A, MDNode *B)
Function * getDeclaration(Module *M, ID id, ArrayRef< Type * > Tys=None)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
StoreInst - an instruction for storing to memory.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
bool isArrayTy() const
isArrayTy - True if this is an instance of ArrayType.
bool EliminateDuplicatePHINodes(BasicBlock *BB)
EliminateDuplicatePHINodes - Check for and eliminate duplicate PHI nodes in this block.
static void gatherIncomingValuesToPhi(PHINode *PN, IncomingValueMap &IncomingValues)
Create a map from block to value for the operands of a given phi.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
Type * getElementType() const
BasicBlock * getNormalDest() const
Interval::succ_iterator succ_end(Interval *I)
unsigned getNumIncomingValues() const
getNumIncomingValues - Return the number of incoming edges
DenseMap< BasicBlock *, Value * > IncomingValueMap
static MDNode * getMostGenericRange(MDNode *A, MDNode *B)
Subclasses of this class are all able to terminate a basic block.
LLVM Basic Block Representation.
void getAllMetadataOtherThanDebugLoc(SmallVectorImpl< std::pair< unsigned, MDNode * >> &MDs) const
getAllMetadataOtherThanDebugLoc - This does the same thing as getAllMetadata, except that it filters ...
void eraseNode(NodeT *BB)
eraseNode - Removes a node from the dominator tree.
DIExpression * getExpression() const
bool TryToSimplifyUncondBranchFromEmptyBlock(BasicBlock *BB)
TryToSimplifyUncondBranchFromEmptyBlock - BB is known to contain an unconditional branch...
BranchInst - Conditional or Unconditional Branch instruction.
static BlockAddress * get(Function *F, BasicBlock *BB)
get - Return a BlockAddress for the specified function and basic block.
UnreachableInst - This function has undefined behavior.
This is an important base class in LLVM.
PointerType * getType() const
getType - Overload to return most specific pointer type
This file contains the declarations for the subclasses of Constant, which represent the different fla...
IndirectBrInst - Indirect Branch Instruction.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
Interval::pred_iterator pred_begin(Interval *I)
pred_begin/pred_end - define methods so that Intervals may be used just like BasicBlocks can with the...
const DebugLoc & getDebugLoc() const
getDebugLoc - Return the debug location for this node as a DebugLoc.
static bool CanMergeValues(Value *First, Value *Second)
CanMergeValues - Return true if we can choose one of these values to use in place of the other...
BasicBlock * getIncomingBlock(unsigned i) const
getIncomingBlock - Return incoming basic block number i.
const InstListType & getInstList() const
Return the underlying instruction list container.
Value * getOperand(unsigned i) const
Interval::pred_iterator pred_end(Interval *I)
static bool LdStHasDebugValue(const DILocalVariable *DIVar, Instruction *I)
===---------------------------------------------------------------——===// Dbg Intrinsic utilities ...
static MDNode * getMostGenericTBAA(MDNode *A, MDNode *B)
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
bool isPointerTy() const
isPointerTy - True if this is an instance of PointerType.
static UndefValue * get(Type *T)
get() - Static factory methods - Return an 'undef' object of the specified type.
bool RecursivelyDeleteTriviallyDeadInstructions(Value *V, const TargetLibraryInfo *TLI=nullptr)
RecursivelyDeleteTriviallyDeadInstructions - If the specified value is a trivially dead instruction...
LLVMContext & getContext() const
All values hold a context through their type.
bool LowerDbgDeclare(Function &F)
LowerDbgDeclare - Lowers llvm.dbg.declare intrinsics into appropriate set of llvm.dbg.value intrinsics.
iterator erase(iterator where)
void setMetadata(unsigned KindID, MDNode *Node)
setMetadata - Set the metadata of the specified kind to the specified node.
CallingConv::ID getCallingConv() const
getCallingConv/setCallingConv - Get or set the calling convention of this function call...
static void redirectValuesFromPredecessorsToPhi(BasicBlock *BB, const PredBlockVector &BBPreds, PHINode *PN)
Replace a value flowing from a block to a phi with potentially multiple instances of that value flowi...
bool recursivelySimplifyInstruction(Instruction *I, const TargetLibraryInfo *TLI=nullptr, const DominatorTree *DT=nullptr, AssumptionCache *AC=nullptr)
Recursively attempt to simplify an instruction.
bool dominates(const Instruction *Def, const Use &U) const
Return true if Def dominates a use in User.
static void changeToUnreachable(Instruction *I, bool UseLLVMTrap)
changeToUnreachable - Insert an unreachable instruction before the specified instruction, making it and the rest of the code in the block dead.
const MDOperand & getOperand(unsigned I) const
std::pair< iterator, bool > insert(const ValueT &V)
void moveAfter(BasicBlock *MovePos)
Unlink this basic block from its current function and insert it right after MovePos in the function M...
const BasicBlockListType & getBasicBlockList() const
BasicBlock * getUnwindDest() const
DomTreeNodeBase< NodeT > * getIDom() const
This is the shared class of boolean and integer constants.
Value * getIncomingValue(unsigned i) const
getIncomingValue - Return incoming value number x
bool ConvertDebugDeclareToDebugValue(DbgDeclareInst *DDI, StoreInst *SI, DIBuilder &Builder)
===---------------------------------------------------------------——===// Dbg Intrinsic utilities ...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Type * getType() const
All values are typed, get the type of this value.
Provides information about what library functions are available for the current target.
MDNode * getMetadata(unsigned KindID) const
getMetadata - Get the metadata of given kind attached to this Instruction.
bool RecursivelyDeleteDeadPHINode(PHINode *PN, const TargetLibraryInfo *TLI=nullptr)
RecursivelyDeleteDeadPHINode - If the specified value is an effectively dead PHI node, due to being a def-use chain of single-use nodes that either forms a cycle or is terminated by a trivially dead instruction, delete it.
BasicBlockTy * getCaseSuccessor()
Resolves successor for current case.
Value * stripPointerCasts()
Strip off pointer casts, all-zero GEPs, and aliases.
DIExpression * createExpression(ArrayRef< uint64_t > Addr=None)
Create a new descriptor for the specified variable which has a complex address expression for its add...
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
static BranchInst * Create(BasicBlock *IfTrue, Instruction *InsertBefore=nullptr)
const BasicBlock & getEntryBlock() const
static cl::opt< AlignMode > Align(cl::desc("Load/store alignment support"), cl::Hidden, cl::init(NoStrictAlign), cl::values(clEnumValN(StrictAlign,"aarch64-strict-align","Disallow all unaligned memory accesses"), clEnumValN(NoStrictAlign,"aarch64-no-strict-align","Allow unaligned memory accesses"), clEnumValEnd))
Value handle that asserts if the Value is deleted.
SmallVector< BasicBlock *, 16 > PredBlockVector
void splice(iterator where, iplist &L2)
void setOperand(unsigned i, Value *Val)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
size_type count(const KeyT &Val) const
Return 1 if the specified key is in the map, 0 otherwise.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Class for arbitrary precision integers.
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
bool exceedsNaturalStackAlignment(unsigned Align) const
Returns true if the given alignment exceeds the natural stack alignment.
bool replaceDbgDeclareForAlloca(AllocaInst *AI, Value *NewAllocaAddress, DIBuilder &Builder, bool Deref)
Replaces llvm.dbg.declare instruction when an alloca is replaced with a new value.
Value * getIncomingValueForBlock(const BasicBlock *BB) const
iterator_range< user_iterator > users()
BasicBlock * getSinglePredecessor()
Return the predecessor of this block if it has a single predecessor block.
LLVM_ATTRIBUTE_UNUSED_RESULT std::enable_if< !is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
hash_code hash_combine_range(InputIteratorT first, InputIteratorT last)
Compute a hash_code for a sequence of values.
const AttributeSet & getAttributes() const
getAttributes - Return the parameter attributes for this invoke.
static IntegerType * getInt32Ty(LLVMContext &C)
DbgValueInst - This represents the llvm.dbg.value instruction.
iplist< BasicBlock >::iterator eraseFromParent()
Unlink 'this' from the containing function and delete it.
TerminatorInst * getTerminator()
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
bool isAllocLikeFn(const Value *V, const TargetLibraryInfo *TLI, bool LookThroughBitCast=false)
Tests if a value is a call or invoke to a library function that allocates memory (either malloc...
iterator find(const KeyT &Val)
void destroyConstant()
Called if some element of this constant is no longer valid.
void dropUnknownMetadata(ArrayRef< unsigned > KnownIDs)
Drop unknown metadata.
void changeImmediateDominator(DomTreeNodeBase< NodeT > *N, DomTreeNodeBase< NodeT > *NewIDom)
changeImmediateDominator - This method is used to update the dominator tree information when a node's...
SwitchInst - Multiway switch.
static bool isArray(AllocaInst *AI)
Determine whether this alloca is either a VLA or an array.
DILocalVariable * getVariable() const
user_iterator user_begin()
const ARM::ArchExtKind Kind
LLVMContext & getContext() const
Get the context in which this basic block lives.
Module * getParent()
Get the module that this global value is contained inside of...
bool isInstructionTriviallyDead(Instruction *I, const TargetLibraryInfo *TLI=nullptr)
isInstructionTriviallyDead - Return true if the result produced by the instruction is not used...
LLVM Value Representation.
Value * getAddress() const
DbgDeclareInst - This represents the llvm.dbg.declare instruction.
static const Function * getParent(const Value *V)
BranchInst * CreateBr(BasicBlock *Dest)
Create an unconditional 'br label X' instruction.
InvokeInst - Invoke instruction.
C - The default llvm calling convention, compatible with C.
bool removeUnreachableBlocks(Function &F)
Remove all blocks that can not be reached from the function's entry.
DomTreeNodeBase< NodeT > * getNode(NodeT *BB) const
getNode - return the (Post)DominatorTree node for the specified basic block.
void setIncomingValue(unsigned i, Value *V)
static MDNode * getMostGenericFPMath(MDNode *A, MDNode *B)
DbgDeclareInst - This represents the llvm.dbg.declare instruction.
void combineMetadata(Instruction *K, const Instruction *J, ArrayRef< unsigned > KnownIDs)
Combine the metadata of two instructions so that K can replace J.
const BasicBlock * getParent() const
InstListType::iterator iterator
Instruction iterators...
IntrinsicInst - A useful wrapper class for inspecting calls to intrinsic functions.
AllocaInst - an instruction to allocate memory on the stack.