36 using namespace PatternMatch;
38 #define DEBUG_TYPE "lazy-value-info"
42 "Lazy Value Information Analysis",
false,
true)
88 LVILatticeVal() :
Tag(undefined), Val(nullptr), Range(1,
true) {}
92 if (!isa<UndefValue>(C))
96 static LVILatticeVal getNot(
Constant *C) {
98 if (!isa<UndefValue>(C))
99 Res.markNotConstant(C);
104 Res.markConstantRange(CR);
108 bool isUndefined()
const {
return Tag == undefined; }
109 bool isConstant()
const {
return Tag == constant; }
110 bool isNotConstant()
const {
return Tag == notconstant; }
111 bool isConstantRange()
const {
return Tag == constantrange; }
112 bool isOverdefined()
const {
return Tag == overdefined; }
115 assert(isConstant() &&
"Cannot get the constant of a non-constant!");
120 assert(isNotConstant() &&
"Cannot get the constant of a non-notconstant!");
125 assert(isConstantRange() &&
126 "Cannot get the constant-range of a non-constant-range!");
131 bool markOverdefined() {
140 assert(V &&
"Marking constant with NULL");
143 if (isa<UndefValue>(V))
146 assert((!isConstant() || getConstant() == V) &&
147 "Marking constant with different value");
148 assert(isUndefined());
156 assert(V &&
"Marking constant with NULL");
158 return markConstantRange(
ConstantRange(CI->getValue()+1, CI->getValue()));
159 if (isa<UndefValue>(V))
162 assert((!isConstant() || getConstant() != V) &&
163 "Marking constant !constant with same value");
164 assert((!isNotConstant() || getNotConstant() == V) &&
165 "Marking !constant with different value");
166 assert(isUndefined() || isConstant());
174 if (isConstantRange()) {
176 return markOverdefined();
178 bool changed = Range != NewR;
183 assert(isUndefined());
185 return markOverdefined();
194 bool mergeIn(
const LVILatticeVal &RHS,
const DataLayout &DL) {
195 if (RHS.isUndefined() || isOverdefined())
return false;
196 if (RHS.isOverdefined())
return markOverdefined();
206 if (RHS.isConstant()) {
209 return markOverdefined();
212 if (RHS.isNotConstant()) {
214 return markOverdefined();
222 return markNotConstant(RHS.getNotConstant());
224 return markOverdefined();
232 return markOverdefined();
235 if (isNotConstant()) {
236 if (RHS.isConstant()) {
238 return markOverdefined();
248 return markOverdefined();
251 if (RHS.isNotConstant()) {
254 return markOverdefined();
257 return markOverdefined();
260 assert(isConstantRange() &&
"New LVILattice type?");
261 if (!RHS.isConstantRange())
262 return markOverdefined();
266 return markOverdefined();
267 return markConstantRange(NewR);
277 if (Val.isUndefined())
278 return OS <<
"undefined";
279 if (Val.isOverdefined())
280 return OS <<
"overdefined";
282 if (Val.isNotConstant())
283 return OS <<
"notconstant<" << *Val.getNotConstant() <<
'>';
284 else if (Val.isConstantRange())
285 return OS <<
"constantrange<" << Val.getConstantRange().getLower() <<
", "
286 << Val.getConstantRange().getUpper() <<
'>';
287 return OS <<
"constant<" << *Val.getConstant() <<
'>';
297 class LazyValueInfoCache;
299 LazyValueInfoCache *Parent;
301 LVIValueHandle(
Value *V, LazyValueInfoCache *
P)
304 void deleted()
override;
305 void allUsesReplacedWith(
Value *V)
override {
314 class LazyValueInfoCache {
318 typedef std::map<AssertingVH<BasicBlock>, LVILatticeVal> ValueCacheEntryTy;
322 std::map<LVIValueHandle, ValueCacheEntryTy> ValueCache;
327 typedef std::pair<AssertingVH<BasicBlock>,
Value*> OverDefinedPairTy;
337 std::stack<std::pair<BasicBlock*, Value*> > BlockValueStack;
344 bool pushBlockValue(
const std::pair<BasicBlock *, Value *> &BV) {
345 if (!BlockValueSet.insert(BV).second)
348 BlockValueStack.push(BV);
356 friend struct LVIValueHandle;
358 void insertResult(
Value *Val,
BasicBlock *BB,
const LVILatticeVal &Result) {
359 SeenBlocks.insert(BB);
361 if (Result.isOverdefined())
362 OverDefinedCache.insert(std::make_pair(BB, Val));
367 LVILatticeVal &Result,
375 bool solveBlockValueNonLocal(LVILatticeVal &BBLV,
377 bool solveBlockValuePHINode(LVILatticeVal &BBLV,
379 bool solveBlockValueConstantRange(LVILatticeVal &BBLV,
381 void mergeAssumeBlockValueConstantRange(
Value *Val, LVILatticeVal &BBLV,
387 return ValueCache[LVIValueHandle(V,
this)];
418 OverDefinedCache.clear();
423 : AC(AC), DL(DL), DT(DT) {}
427 void LVIValueHandle::deleted() {
428 typedef std::pair<AssertingVH<BasicBlock>,
Value*> OverDefinedPairTy;
431 for (
const OverDefinedPairTy &
P : Parent->OverDefinedCache)
432 if (P.second == getValPtr())
434 for (
const OverDefinedPairTy &P : ToErase)
435 Parent->OverDefinedCache.erase(P);
439 Parent->ValueCache.erase(*
this);
442 void LazyValueInfoCache::eraseBlock(
BasicBlock *BB) {
445 if (I == SeenBlocks.
end())
450 for (
const OverDefinedPairTy& P : OverDefinedCache)
453 for (
const OverDefinedPairTy &P : ToErase)
454 OverDefinedCache.erase(P);
456 for (std::map<LVIValueHandle, ValueCacheEntryTy>::iterator
457 I = ValueCache.
begin(), E = ValueCache.end(); I != E; ++
I)
462 while (!BlockValueStack.empty()) {
463 std::pair<BasicBlock*, Value*> &e = BlockValueStack.top();
464 assert(BlockValueSet.count(e) &&
"Stack value should be in BlockValueSet!");
466 if (solveBlockValue(e.second, e.first)) {
468 assert(BlockValueStack.top() == e &&
"Nothing should have been pushed!");
469 assert(
lookup(e.second).count(e.first) &&
"Result should be in cache!");
471 BlockValueStack.pop();
472 BlockValueSet.erase(e);
475 assert(BlockValueStack.top() != e &&
"Stack should have been pushed!");
482 if (isa<Constant>(Val))
485 LVIValueHandle ValHandle(Val,
this);
486 std::map<LVIValueHandle, ValueCacheEntryTy>::iterator I =
487 ValueCache.
find(ValHandle);
488 if (I == ValueCache.end())
return false;
489 return I->second.count(BB);
492 LVILatticeVal LazyValueInfoCache::getBlockValue(
Value *Val,
BasicBlock *BB) {
495 return LVILatticeVal::get(
VC);
497 SeenBlocks.insert(BB);
502 if (isa<Constant>(Val))
505 if (
lookup(Val).count(BB)) {
508 <<
"' val=" <<
lookup(Val)[BB] <<
'\n');
522 if (!solveBlockValueNonLocal(Res, Val, BB))
524 insertResult(Val, BB, Res);
528 if (
PHINode *PN = dyn_cast<PHINode>(BBI)) {
529 if (!solveBlockValuePHINode(Res, PN, BB))
531 insertResult(Val, BB, Res);
535 if (
AllocaInst *AI = dyn_cast<AllocaInst>(BBI)) {
537 insertResult(Val, BB, Res);
543 LVILatticeVal Result;
544 if ((!isa<BinaryOperator>(BBI) && !isa<CastInst>(BBI)) ||
547 <<
"' - overdefined because inst def found.\n");
548 Res.markOverdefined();
549 insertResult(Val, BB, Res);
556 if (BO && !isa<ConstantInt>(BO->
getOperand(1))) {
558 <<
"' - overdefined because inst def found.\n");
560 Res.markOverdefined();
561 insertResult(Val, BB, Res);
565 if (!solveBlockValueConstantRange(Res, BBI, BB))
567 insertResult(Val, BB, Res);
572 if (
LoadInst *L = dyn_cast<LoadInst>(I)) {
573 return L->getPointerAddressSpace() == 0 &&
575 L->getModule()->getDataLayout()) == Ptr;
577 if (
StoreInst *S = dyn_cast<StoreInst>(I)) {
578 return S->getPointerAddressSpace() == 0 &&
580 S->getModule()->getDataLayout()) == Ptr;
583 if (
MI->isVolatile())
return false;
587 if (!Len || Len->
isZero())
return false;
589 if (
MI->getDestAddressSpace() == 0)
591 MI->getModule()->getDataLayout()) == Ptr)
594 if (MTI->getSourceAddressSpace() == 0)
596 MTI->getModule()->getDataLayout()) == Ptr)
602 bool LazyValueInfoCache::solveBlockValueNonLocal(LVILatticeVal &BBLV,
604 LVILatticeVal Result;
608 bool NotNull =
false;
631 assert(isa<Argument>(Val) &&
"Unknown live-in to the entry block");
636 Result.markOverdefined();
644 bool EdgesMissing =
false;
646 LVILatticeVal EdgeResult;
647 EdgesMissing |= !getEdgeValue(Val, *PI, BB, EdgeResult);
651 Result.mergeIn(EdgeResult, DL);
655 if (Result.isOverdefined()) {
657 <<
"' - overdefined because of pred.\n");
673 assert(!Result.isOverdefined());
678 bool LazyValueInfoCache::solveBlockValuePHINode(LVILatticeVal &BBLV,
680 LVILatticeVal Result;
684 bool EdgesMissing =
false;
688 LVILatticeVal EdgeResult;
692 EdgesMissing |= !getEdgeValue(PhiVal, PhiBB, BB, EdgeResult, PN);
696 Result.mergeIn(EdgeResult, DL);
700 if (Result.isOverdefined()) {
702 <<
"' - overdefined because of pred.\n");
712 assert(!Result.isOverdefined() &&
"Possible PHI in entry block?");
718 LVILatticeVal &Result,
719 bool isTrueDest =
true);
724 void LazyValueInfoCache::mergeAssumeBlockValueConstantRange(
Value *Val,
731 for (
auto &AssumeVH : AC->assumptions()) {
734 auto *I = cast<CallInst>(AssumeVH);
738 Value *C = I->getArgOperand(0);
739 if (
ICmpInst *ICI = dyn_cast<ICmpInst>(C)) {
740 LVILatticeVal Result;
742 if (BBLV.isOverdefined())
745 BBLV.mergeIn(Result, DL);
751 bool LazyValueInfoCache::solveBlockValueConstantRange(LVILatticeVal &BBLV,
756 if (pushBlockValue(std::make_pair(BB, BBI->
getOperand(0))))
758 BBLV.markOverdefined();
762 LVILatticeVal LHSVal = getBlockValue(BBI->
getOperand(0), BB);
763 mergeAssumeBlockValueConstantRange(BBI->
getOperand(0), LHSVal, BBI);
764 if (!LHSVal.isConstantRange()) {
765 BBLV.markOverdefined();
772 if (isa<BinaryOperator>(BBI)) {
776 BBLV.markOverdefined();
784 LVILatticeVal Result;
786 case Instruction::Add:
787 Result.markConstantRange(LHSRange.
add(RHSRange));
789 case Instruction::Sub:
790 Result.markConstantRange(LHSRange.
sub(RHSRange));
792 case Instruction::Mul:
793 Result.markConstantRange(LHSRange.
multiply(RHSRange));
795 case Instruction::UDiv:
796 Result.markConstantRange(LHSRange.
udiv(RHSRange));
798 case Instruction::Shl:
799 Result.markConstantRange(LHSRange.
shl(RHSRange));
801 case Instruction::LShr:
802 Result.markConstantRange(LHSRange.
lshr(RHSRange));
804 case Instruction::Trunc:
807 case Instruction::SExt:
810 case Instruction::ZExt:
813 case Instruction::BitCast:
814 Result.markConstantRange(LHSRange);
817 Result.markConstantRange(LHSRange.
binaryAnd(RHSRange));
820 Result.markConstantRange(LHSRange.
binaryOr(RHSRange));
826 <<
"' - overdefined because inst def found.\n");
827 Result.markOverdefined();
836 LVILatticeVal &Result,
bool isTrueDest) {
837 if (ICI && isa<Constant>(ICI->
getOperand(1))) {
842 Result = LVILatticeVal::get(cast<Constant>(ICI->
getOperand(1)));
844 Result = LVILatticeVal::getNot(cast<Constant>(ICI->
getOperand(1)));
856 if (CI && (ICI->
getOperand(0) == Val || NegOffset)) {
866 if (!isTrueDest) TrueValues = TrueValues.
inverse();
868 Result = LVILatticeVal::getRange(TrueValues);
885 if (BI->isConditional() &&
886 BI->getSuccessor(0) != BI->getSuccessor(1)) {
887 bool isTrueDest = BI->getSuccessor(0) == BBTo;
888 assert(BI->getSuccessor(!isTrueDest) == BBTo &&
889 "BBTo isn't a successor of BBFrom");
893 if (BI->getCondition() == Val) {
901 if (
ICmpInst *ICI = dyn_cast<ICmpInst>(BI->getCondition()))
910 if (
SI->getCondition() != Val)
913 bool DefaultCase =
SI->getDefaultDest() == BBTo;
922 if (i.getCaseSuccessor() != BBTo)
924 }
else if (i.getCaseSuccessor() == BBTo)
925 EdgesVals = EdgesVals.
unionWith(EdgeVal);
927 Result = LVILatticeVal::getRange(EdgesVals);
940 Result = LVILatticeVal::get(
VC);
945 if (!Result.isConstantRange() ||
946 Result.getConstantRange().getSingleElement())
952 if (!hasBlockValue(Val, BBFrom)) {
953 if (pushBlockValue(std::make_pair(BBFrom, Val)))
955 Result.markOverdefined();
960 LVILatticeVal
InBlock = getBlockValue(Val, BBFrom);
961 mergeAssumeBlockValueConstantRange(Val, InBlock, BBFrom->
getTerminator());
964 mergeAssumeBlockValueConstantRange(Val, InBlock, CxtI);
965 if (!InBlock.isConstantRange())
969 Result.getConstantRange().intersectWith(InBlock.getConstantRange());
970 Result = LVILatticeVal::getRange(Range);
974 if (!hasBlockValue(Val, BBFrom)) {
975 if (pushBlockValue(std::make_pair(BBFrom, Val)))
977 Result.markOverdefined();
982 Result = getBlockValue(Val, BBFrom);
983 mergeAssumeBlockValueConstantRange(Val, Result, BBFrom->
getTerminator());
992 mergeAssumeBlockValueConstantRange(Val, Result, CxtI);
996 LVILatticeVal LazyValueInfoCache::getValueInBlock(
Value *V,
BasicBlock *BB,
998 DEBUG(
dbgs() <<
"LVI Getting block end value " << *V <<
" at '"
1001 assert(BlockValueStack.empty() && BlockValueSet.empty());
1002 pushBlockValue(std::make_pair(BB, V));
1005 LVILatticeVal Result = getBlockValue(V, BB);
1006 mergeAssumeBlockValueConstantRange(V, Result, CxtI);
1008 DEBUG(
dbgs() <<
" Result = " << Result <<
"\n");
1012 LVILatticeVal LazyValueInfoCache::getValueAt(
Value *V,
Instruction *CxtI) {
1013 DEBUG(
dbgs() <<
"LVI Getting value " << *V <<
" at '"
1016 LVILatticeVal Result;
1017 mergeAssumeBlockValueConstantRange(V, Result, CxtI);
1019 DEBUG(
dbgs() <<
" Result = " << Result <<
"\n");
1023 LVILatticeVal LazyValueInfoCache::
1026 DEBUG(
dbgs() <<
"LVI Getting edge value " << *V <<
" from '"
1029 LVILatticeVal Result;
1030 if (!getEdgeValue(V, FromBB, ToBB, Result, CxtI)) {
1032 bool WasFastQuery = getEdgeValue(V, FromBB, ToBB, Result, CxtI);
1034 assert(WasFastQuery &&
"More work to do after problem solved?");
1037 DEBUG(
dbgs() <<
" Result = " << Result <<
"\n");
1053 std::vector<BasicBlock*> worklist;
1054 worklist.push_back(OldSucc);
1057 for (OverDefinedPairTy &P : OverDefinedCache)
1058 if (P.first == OldSucc)
1059 ClearSet.
insert(P.second);
1065 while (!worklist.empty()) {
1067 worklist.pop_back();
1070 if (ToUpdate == NewSucc)
continue;
1072 bool changed =
false;
1073 for (
Value *V : ClearSet) {
1076 OverDefinedCache.find(std::make_pair(ToUpdate, V));
1077 if (OI == OverDefinedCache.end())
continue;
1080 ValueCacheEntryTy &Entry = ValueCache[LVIValueHandle(V,
this)];
1081 ValueCacheEntryTy::iterator CI = Entry.find(ToUpdate);
1083 assert(CI != Entry.end() &&
"Couldn't find entry to update?");
1085 OverDefinedCache.erase(OI);
1092 if (!changed)
continue;
1107 assert(DL &&
"getCache() called with a null DataLayout");
1108 PImpl =
new LazyValueInfoCache(AC, *DL, DT);
1110 return *
static_cast<LazyValueInfoCache*
>(PImpl);
1114 AC = &getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
1118 getAnalysisIfAvailable<DominatorTreeWrapperPass>();
1121 TLI = &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
1124 getCache(PImpl, AC, &DL, DT).clear();
1139 delete &
getCache(PImpl, AC,
nullptr);
1147 LVILatticeVal Result =
1148 getCache(PImpl, AC, &DL, DT).getValueInBlock(V, BB, CxtI);
1150 if (Result.isConstant())
1151 return Result.getConstant();
1152 if (Result.isConstantRange()) {
1166 LVILatticeVal Result =
1167 getCache(PImpl, AC, &DL, DT).getValueOnEdge(V, FromBB, ToBB, CxtI);
1169 if (Result.isConstant())
1170 return Result.getConstant();
1171 if (Result.isConstantRange()) {
1180 LVILatticeVal &Result,
1186 if (Result.isConstant()) {
1189 if (
ConstantInt *ResCI = dyn_cast<ConstantInt>(Res))
1194 if (Result.isConstantRange()) {
1223 if (Result.isNotConstant()) {
1229 Result.getNotConstant(),
C, DL,
1236 Result.getNotConstant(),
C, DL,
1254 LVILatticeVal Result =
1255 getCache(PImpl, AC, &DL, DT).getValueOnEdge(V, FromBB, ToBB, CxtI);
1264 LVILatticeVal Result =
getCache(PImpl, AC, &DL, DT).getValueAt(V, CxtI);
1279 (!isa<Instruction>(V) ||
1280 cast<Instruction>(V)->
getParent() != BB)) {
1284 Tristate Baseline = getPredicateOnEdge(Pred, V, C, *PI, BB, CxtI);
1287 while (++PI != PE) {
1288 Tristate Ret = getPredicateOnEdge(Pred, V, C, *PI, BB, CxtI);
1289 if (Ret != Baseline)
break;
1305 getCache(PImpl, AC, &DL, DT).threadEdge(PredBB, OldSucc, NewSucc);
1312 getCache(PImpl, AC, &DL, DT).eraseBlock(BB);
void push_back(const T &Elt)
A parsed version of the target data layout string in and methods for querying it. ...
static bool InstructionDereferencesPointer(Instruction *I, Value *Ptr)
static IntegerType * getInt1Ty(LLVMContext &C)
const Instruction & back() const
const APInt * getSingleElement() const
If this set contains a single element, return it, otherwise return null.
DenseSet - This implements a dense probed hash-table based set.
An immutable pass that tracks lazily created AssumptionCache objects.
A cache of .assume calls within a function.
static bool isEquality(Predicate P)
isEquality - Return true if this predicate is either EQ or NE.
const Function * getParent() const
Return the enclosing method, or null if none.
bool isValidAssumeForContext(const Instruction *I, const Instruction *CxtI, const DominatorTree *DT=nullptr)
Return true if it is valid to use the assumptions provided by an assume intrinsic, I, at the point in the control-flow identified by the context instruction, CxtI.
bool isSingleElement() const
Return true if this set contains exactly one member.
LoadInst - an instruction for reading from memory.
unsigned getBitWidth() const
Get the number of bits in this IntegerType.
static ConstantRange makeAllowedICmpRegion(CmpInst::Predicate Pred, const ConstantRange &Other)
Produce the smallest range such that all values that may satisfy the given predicate with any value c...
static LazyValueInfo::Tristate getPredicateResult(unsigned Pred, Constant *C, LVILatticeVal &Result, const DataLayout &DL, TargetLibraryInfo *TLI)
StringRef getName() const
Return a constant reference to the value's name.
bool match(Val *V, const Pattern &P)
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
Constant * getConstant(Value *V, BasicBlock *BB, Instruction *CxtI=nullptr)
Determine whether the specified value is known to be a constant at the end of the specified block...
ConstantRange truncate(uint32_t BitWidth) const
Return a new range in the specified integer type, which must be strictly smaller than the current typ...
bool runOnFunction(Function &F) override
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass...
bool erase(const ValueT &V)
const APInt & getValue() const
Return the constant as an APInt value reference.
const Module * getModule() const
Return the module owning the function this basic block belongs to, or nullptr it the function does no...
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
lazy value Lazy Value Information Analysis
DominatorTree & getDomTree()
ConstantRange signExtend(uint32_t BitWidth) const
Return a new range in the specified integer type, which must be strictly larger than the current type...
ConstantRange multiply(const ConstantRange &Other) const
Return a new range representing the possible values resulting from a multiplication of a value in thi...
BinaryOp_match< LHS, RHS, Instruction::Add > m_Add(const LHS &L, const RHS &R)
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...
bool contains(const APInt &Val) const
Return true if the specified value is in the set.
static bool getEdgeValueLocal(Value *Val, BasicBlock *BBFrom, BasicBlock *BBTo, LVILatticeVal &Result)
Compute the value of Val on the edge BBFrom -> BBTo.
ConstantRange unionWith(const ConstantRange &CR) const
Return the range that results from the union of this range with another range.
class_match< ConstantInt > m_ConstantInt()
Match an arbitrary ConstantInt and ignore it.
StoreInst - an instruction for storing to memory.
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
ConstantRange subtract(const APInt &CI) const
Subtract the specified constant from the endpoints of this constant range.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
FunctionPass * createLazyValueInfoPass()
createLazyValueInfoPass - This creates an instance of the LazyValueInfo pass.
PointerType - Class to represent pointers.
Interval::succ_iterator succ_end(Interval *I)
unsigned getNumIncomingValues() const
getNumIncomingValues - Return the number of incoming edges
static bool getValueFromFromCondition(Value *Val, ICmpInst *ICI, LVILatticeVal &Result, bool isTrueDest=true)
static ConstantPointerNull * get(PointerType *T)
get() - Static factory methods - Return objects of the specified value
iterator find(const ValueT &V)
Constant * getConstantOnEdge(Value *V, BasicBlock *FromBB, BasicBlock *ToBB, Instruction *CxtI=nullptr)
Determine whether the specified value is known to be a constant on the specified edge.
bool isFullSet() const
Return true if this set contains all of the elements possible for this data-type. ...
ConstantRange lshr(const ConstantRange &Other) const
Return a new range representing the possible values resulting from a logical right shift of a value i...
LLVM Basic Block Representation.
BranchInst - Conditional or Unconditional Branch instruction.
This is an important base class in LLVM.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
APInt Or(const APInt &LHS, const APInt &RHS)
Bitwise OR function for APInt.
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...
specificval_ty m_Specific(const Value *V)
Match if we have a specific specified value.
Represent the analysis usage information of a pass.
ConstantRange udiv(const ConstantRange &Other) const
Return a new range representing the possible values resulting from an unsigned division of a value in...
BasicBlock * getIncomingBlock(unsigned i) const
getIncomingBlock - Return incoming basic block number i.
This instruction compares its operands according to the predicate given to the constructor.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
FunctionPass class - This class is used to implement most global optimizations.
Value * getOperand(unsigned i) const
Interval::pred_iterator pred_end(Interval *I)
ConstantRange sub(const ConstantRange &Other) const
Return a new range representing the possible values resulting from a subtraction of a value in this r...
Class to represent integer types.
Predicate getPredicate() const
Return the predicate for this instruction.
ConstantRange zeroExtend(uint32_t BitWidth) const
Return a new range in the specified integer type, which must be strictly larger than the current type...
bool isEmptySet() const
Return true if this set contains no members.
ConstantRange difference(const ConstantRange &CR) const
Subtract the specified range from this range (aka relative complement of the sets).
bool isPointerTy() const
isPointerTy - True if this is an instance of PointerType.
LLVMContext & getContext() const
All values hold a context through their type.
Constant * ConstantFoldCompareInstOperands(unsigned Predicate, Constant *LHS, Constant *RHS, const DataLayout &DL, const TargetLibraryInfo *TLI=nullptr)
ConstantFoldCompareInstOperands - Attempt to constant fold a compare instruction (icmp/fcmp) with the...
ConstantRange add(const ConstantRange &Other) const
Return a new range representing the possible values resulting from an addition of a value in this ran...
Value * GetUnderlyingObject(Value *V, const DataLayout &DL, unsigned MaxLookup=6)
GetUnderlyingObject - This method strips off any GEP address adjustments and pointer casts from the s...
static LazyValueInfoCache & getCache(void *&PImpl, AssumptionCache *AC, const DataLayout *DL, DominatorTree *DT=nullptr)
This lazily constructs the LazyValueInfoCache.
Tristate
This is used to return true/false/dunno results.
Tristate getPredicateOnEdge(unsigned Pred, Value *V, Constant *C, BasicBlock *FromBB, BasicBlock *ToBB, Instruction *CxtI=nullptr)
Determine whether the specified value comparison with a constant is known to be true or false on the ...
Tristate getPredicateAt(unsigned Pred, Value *V, Constant *C, Instruction *CxtI)
Determine whether the specified value comparison with a constant is known to be true or false at the ...
std::pair< iterator, bool > insert(const ValueT &V)
MemIntrinsic - This is the common base class for memset/memcpy/memmove.
unsigned getIntegerBitWidth() const
This is the shared class of boolean and integer constants.
Value * getIncomingValue(unsigned i) const
getIncomingValue - Return incoming value number x
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
ConstantRange inverse() const
Return a new range that is the logical not of the current set.
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.
This class represents a range of values.
INITIALIZE_PASS_BEGIN(LazyValueInfo,"lazy-value-info","Lazy Value Information Analysis", false, true) INITIALIZE_PASS_END(LazyValueInfo
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.
bool isZero() const
This is just a convenience method to make client code smaller for a common code.
const BasicBlock & getEntryBlock() const
bool isNullValue() const
isNullValue - Return true if this is the value that would be returned by getNullValue.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
ConstantRange binaryOr(const ConstantRange &Other) const
Return a new range representing the possible values resulting from a binary-or of a value in this ran...
Class for arbitrary precision integers.
bool isIntegerTy() const
isIntegerTy - True if this is an instance of IntegerType.
void setPreservesAll()
Set by analyses that do not transform their input at all.
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)
bool isKnownNonNull(const Value *V, const TargetLibraryInfo *TLI=nullptr)
isKnownNonNull - Return true if this pointer couldn't possibly be null by its definition.
ConstantRange shl(const ConstantRange &Other) const
Return a new range representing the possible values resulting from a left shift of a value in this ra...
APInt And(const APInt &LHS, const APInt &RHS)
Bitwise AND function for APInt.
static const uint16_t * lookup(unsigned opcode, unsigned domain)
MemTransferInst - This class wraps the llvm.memcpy/memmove intrinsics.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
void threadEdge(BasicBlock *PredBB, BasicBlock *OldSucc, BasicBlock *NewSucc)
Inform the analysis cache that we have threaded an edge from PredBB to OldSucc to be from PredBB to N...
ConstantRange binaryAnd(const ConstantRange &Other) const
Return a new range representing the possible values resulting from a binary-and of a value in this ra...
TerminatorInst * getTerminator()
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
static ConstantRange makeConstantRange(Predicate pred, const APInt &C)
Initialize a set of values that all satisfy the predicate with C.
Solution solve(PBQPRAGraph &G)
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
lazy value Lazy Value Information false
void eraseBlock(BasicBlock *BB)
Inform the analysis cache that we have erased a block.
SwitchInst - Multiway switch.
This pass computes, caches, and vends lazy value constraint information.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
unsigned getOpcode() const
getOpcode() returns a member of one of the enums like Instruction::Add.
static const Function * getParent(const Value *V)
This class implements an extremely fast bulk output stream that can only output to a stream...
C - The default llvm calling convention, compatible with C.
Value handle with callbacks on RAUW and destruction.
Legacy analysis pass which computes a DominatorTree.
const BasicBlock * getParent() const
AllocaInst - an instruction to allocate memory on the stack.
static bool InBlock(const Value *V, const BasicBlock *BB)
#define LLVM_ATTRIBUTE_USED