Go to the documentation of this file.
30 #define DEBUG_TYPE "sccp"
92 TrackedMultipleRetVals;
121 using Edge = std::pair<BasicBlock *, BasicBlock *>;
145 bool MayIncludeUndef =
false);
149 return markConstant(ValueState[V], V,
C);
168 "non-structs should use markConstant");
169 return mergeInValue(ValueState[V], V, MergeWithV, Opts);
184 if (
auto *
C = dyn_cast<Constant>(V))
197 "Invalid element #");
199 auto I = StructValueState.
insert(
206 if (
auto *
C = dyn_cast<Constant>(V)) {
211 else if (isa<UndefValue>(Elt))
233 if (BBExecutable.count(
I->getParent()))
238 void addAdditionalUser(
Value *V,
User *U) {
239 auto Iter = AdditionalUsers.
insert({V, {}});
240 Iter.first->second.insert(U);
244 void markUsersAsChanged(
Value *
I) {
249 if (isa<Function>(
I)) {
250 for (
User *U :
I->users()) {
251 if (
auto *CB = dyn_cast<CallBase>(U))
252 handleCallResult(*CB);
255 for (
User *U :
I->users())
256 if (
auto *UI = dyn_cast<Instruction>(U))
257 operandChangedState(UI);
260 auto Iter = AdditionalUsers.
find(
I);
261 if (Iter != AdditionalUsers.
end()) {
265 for (
User *U : Iter->second)
266 if (
auto *UI = dyn_cast<Instruction>(U))
267 ToNotify.push_back(UI);
269 operandChangedState(UI);
272 void handleCallOverdefined(
CallBase &CB);
273 void handleCallResult(
CallBase &CB);
274 void handleCallArguments(
CallBase &CB);
298 markOverdefined(&CPI);
299 visitTerminator(CPI);
315 visitTerminator(CBI);
338 auto A = AnalysisResults.
find(
I->getParent()->getParent());
339 if (
A == AnalysisResults.
end())
341 return A->second.PredInfo->getPredicateInfoFor(
I);
345 auto A = AnalysisResults.
find(&
F);
346 assert(
A != AnalysisResults.
end() &&
"Need analysis results for function.");
353 :
DL(
DL), GetTLI(GetTLI), Ctx(Ctx) {}
366 if (
auto *STy = dyn_cast<StructType>(
F->getReturnType())) {
368 for (
unsigned i = 0,
e = STy->getNumElements();
i !=
e; ++
i)
369 TrackedMultipleRetVals.
insert(
371 }
else if (!
F->getReturnType()->isVoidTy())
376 MustPreserveReturnsInFunctions.
insert(
F);
380 return MustPreserveReturnsInFunctions.
count(
F);
384 TrackingIncomingArguments.
insert(
F);
388 return TrackingIncomingArguments.
count(
F);
396 return BBExecutable.count(
BB);
402 std::vector<ValueLatticeElement> StructValues;
403 auto *STy = dyn_cast<StructType>(V->
getType());
404 assert(STy &&
"getStructLatticeValueFor() can be called only on structs");
405 for (
unsigned i = 0,
e = STy->getNumElements();
i !=
e; ++
i) {
406 auto I = StructValueState.
find(std::make_pair(V,
i));
407 assert(
I != StructValueState.
end() &&
"Value not in valuemap!");
408 StructValues.push_back(
I->second);
417 "Should use getStructLatticeValueFor");
421 "V not found in ValueState nor Paramstate map!");
426 return TrackedRetVals;
430 return TrackedGlobals;
434 return MRVFunctionsTracked;
438 if (
auto *STy = dyn_cast<StructType>(V->
getType()))
439 for (
unsigned i = 0,
e = STy->getNumElements();
i !=
e; ++
i)
440 markOverdefined(getStructValueState(V,
i), V);
442 markOverdefined(ValueState[V], V);
450 return TrackingIncomingArguments;
458 BBExecutable.erase(&
BB);
465 if (!BBExecutable.insert(
BB).second)
467 LLVM_DEBUG(
dbgs() <<
"Marking Block Executable: " <<
BB->getName() <<
'\n');
468 BBWorkList.push_back(
BB);
473 if (
IV.isOverdefined())
474 return OverdefinedInstWorkList.push_back(V);
475 InstWorkList.push_back(V);
480 pushToWorkList(
IV, V);
485 if (!
IV.markConstant(
C, MayIncludeUndef))
488 pushToWorkList(
IV, V);
493 if (!
IV.markOverdefined())
497 if (
auto *
F = dyn_cast<Function>(V))
dbgs()
498 <<
"Function '" <<
F->getName() <<
"'\n";
499 else dbgs() << *V <<
'\n');
501 pushToWorkList(
IV, V);
507 const auto &It = TrackedMultipleRetVals.find(std::make_pair(
F,
i));
508 assert(It != TrackedMultipleRetVals.end());
522 if (CR.getSingleElement())
530 assert(!
Args.empty() &&
"Specialization without arguments");
531 assert(
F->arg_size() ==
Args[0].Formal->getParent()->arg_size() &&
532 "Functions should have the same number of arguments");
534 auto Iter =
Args.begin();
536 Argument *OldArg =
Args[0].Formal->getParent()->arg_begin();
537 for (
auto End =
F->arg_end(); NewArg != End; ++NewArg, ++OldArg) {
542 if (Iter !=
Args.end() && OldArg == Iter->Formal) {
544 markConstant(NewArg, Iter->Actual);
546 }
else if (ValueState.count(OldArg)) {
555 auto &NewValue = ValueState[NewArg];
556 NewValue = ValueState[OldArg];
557 pushToWorkList(NewValue, NewArg);
562 void SCCPInstVisitor::visitInstruction(
Instruction &
I) {
572 if (
IV.mergeIn(MergeWithV, Opts)) {
573 pushToWorkList(
IV, V);
574 LLVM_DEBUG(
dbgs() <<
"Merged " << MergeWithV <<
" into " << *V <<
" : "
582 if (!KnownFeasibleEdges.
insert(Edge(
Source, Dest)).second)
590 <<
" -> " << Dest->
getName() <<
'\n');
600 void SCCPInstVisitor::getFeasibleSuccessors(
Instruction &TI,
603 if (
auto *BI = dyn_cast<BranchInst>(&TI)) {
604 if (BI->isUnconditional()) {
615 Succs[0] = Succs[1] =
true;
620 Succs[CI->
isZero()] =
true;
630 if (
auto *
SI = dyn_cast<SwitchInst>(&TI)) {
631 if (!
SI->getNumCases()) {
637 Succs[
SI->findCaseValue(CI)->getSuccessorIndex()] =
true;
645 for (
const auto &Case :
SI->cases()) {
646 const APInt &CaseValue = Case.getCaseValue()->getValue();
648 Succs[Case.getSuccessorIndex()] =
true;
652 Succs[
SI->case_default()->getSuccessorIndex()] =
true;
664 if (
auto *IBR = dyn_cast<IndirectBrInst>(&TI)) {
677 "Block address of a different function ?");
678 for (
unsigned i = 0;
i < IBR->getNumSuccessors(); ++
i) {
680 if (IBR->getDestination(
i) ==
T) {
693 if (isa<CallBrInst>(&TI)) {
698 LLVM_DEBUG(
dbgs() <<
"Unknown terminator instruction: " << TI <<
'\n');
708 return KnownFeasibleEdges.
count(Edge(
From, To));
728 void SCCPInstVisitor::visitPHINode(
PHINode &PN) {
732 return (
void)markOverdefined(&PN);
740 return (
void)markOverdefined(&PN);
742 unsigned NumActiveIncoming = 0;
766 mergeInValue(&PN, PhiState,
768 NumActiveIncoming + 1));
774 void SCCPInstVisitor::visitReturnInst(
ReturnInst &
I) {
775 if (
I.getNumOperands() == 0)
779 Value *ResultOp =
I.getOperand(0);
783 auto TFRVI = TrackedRetVals.find(
F);
784 if (TFRVI != TrackedRetVals.end()) {
785 mergeInValue(TFRVI->second,
F, getValueState(ResultOp));
791 if (!TrackedMultipleRetVals.empty()) {
792 if (
auto *STy = dyn_cast<StructType>(ResultOp->
getType()))
793 if (MRVFunctionsTracked.count(
F))
794 for (
unsigned i = 0,
e = STy->getNumElements();
i !=
e; ++
i)
795 mergeInValue(TrackedMultipleRetVals[std::make_pair(
F,
i)],
F,
796 getStructValueState(ResultOp,
i));
800 void SCCPInstVisitor::visitTerminator(
Instruction &TI) {
802 getFeasibleSuccessors(TI, SuccFeasible);
807 for (
unsigned i = 0,
e = SuccFeasible.size();
i !=
e; ++
i)
812 void SCCPInstVisitor::visitCastInst(
CastInst &
I) {
825 if (isa<UndefValue>(
C))
829 }
else if (
I.getDestTy()->isIntegerTy()) {
830 auto &LV = getValueState(&
I);
834 : ConstantRange::getFull(
835 I.getOperand(0)->getType()->getScalarSizeInBits());
837 Type *DestTy =
I.getDestTy();
843 if (
I.getOpcode() == Instruction::BitCast &&
844 I.getOperand(0)->getType()->isVectorTy() &&
846 return (
void)markOverdefined(&
I);
849 OpRange.
castOp(
I.getOpcode(),
DL.getTypeSizeInBits(DestTy));
859 return (
void)markOverdefined(&EVI);
864 return (
void)markOverdefined(&EVI);
868 return (
void)markOverdefined(&EVI);
874 mergeInValue(getValueState(&EVI), &EVI, EltVal);
877 return (
void)markOverdefined(&EVI);
882 auto *STy = dyn_cast<StructType>(IVI.
getType());
884 return (
void)markOverdefined(&IVI);
889 return (
void)markOverdefined(&IVI);
893 if (IVI.getNumIndices() != 1)
894 return (
void)markOverdefined(&IVI);
896 Value *Aggr = IVI.getAggregateOperand();
897 unsigned Idx = *IVI.idx_begin();
900 for (
unsigned i = 0,
e = STy->getNumElements();
i !=
e; ++
i) {
904 mergeInValue(getStructValueState(&IVI,
i), &IVI, EltVal);
908 Value *Val = IVI.getInsertedValueOperand();
911 markOverdefined(getStructValueState(&IVI,
i), &IVI);
914 mergeInValue(getStructValueState(&IVI,
i), &IVI, InVal);
919 void SCCPInstVisitor::visitSelectInst(
SelectInst &
I) {
922 if (
I.getType()->isStructTy())
923 return (
void)markOverdefined(&
I);
928 return (
void)markOverdefined(&
I);
934 if (
ConstantInt *CondCB = getConstantInt(CondValue)) {
935 Value *OpVal = CondCB->isZero() ?
I.getFalseValue() :
I.getTrueValue();
936 mergeInValue(&
I, getValueState(OpVal));
946 bool Changed = ValueState[&
I].mergeIn(TVal);
947 Changed |= ValueState[&
I].mergeIn(FVal);
949 pushToWorkListMsg(ValueState[&
I], &
I);
953 void SCCPInstVisitor::visitUnaryOperator(
Instruction &
I) {
960 return (
void)markOverdefined(&
I);
966 if (isa<UndefValue>(
C))
968 return (
void)markConstant(
IV, &
I,
C);
979 void SCCPInstVisitor::visitBinaryOperator(
Instruction &
I) {
984 if (
IV.isOverdefined())
992 return (
void)markOverdefined(&
I);
1000 auto *
C = dyn_cast_or_null<Constant>(
R);
1003 if (isa<UndefValue>(
C))
1012 return (
void)mergeInValue(&
I, NewV);
1017 if (!
I.getType()->isIntegerTy())
1018 return markOverdefined(&
I);
1021 ConstantRange A = ConstantRange::getFull(
I.getType()->getScalarSizeInBits());
1022 ConstantRange B = ConstantRange::getFull(
I.getType()->getScalarSizeInBits());
1037 void SCCPInstVisitor::visitCmpInst(
CmpInst &
I) {
1041 return (
void)markOverdefined(&
I);
1043 Value *Op1 =
I.getOperand(0);
1044 Value *Op2 =
I.getOperand(1);
1048 auto V1State = getValueState(Op1);
1049 auto V2State = getValueState(Op2);
1053 if (isa<UndefValue>(
C))
1057 mergeInValue(&
I, CV);
1066 markOverdefined(&
I);
1073 return (
void)markOverdefined(&
I);
1078 for (
unsigned i = 0,
e =
I.getNumOperands();
i !=
e; ++
i) {
1084 return (
void)markOverdefined(&
I);
1091 return (
void)markOverdefined(&
I);
1098 if (isa<UndefValue>(
C))
1100 markConstant(&
I,
C);
1103 void SCCPInstVisitor::visitStoreInst(
StoreInst &
SI) {
1105 if (
SI.getOperand(0)->getType()->isStructTy())
1108 if (TrackedGlobals.empty() || !isa<GlobalVariable>(
SI.getOperand(1)))
1112 auto I = TrackedGlobals.find(GV);
1113 if (
I == TrackedGlobals.end())
1117 mergeInValue(
I->second, GV, getValueState(
SI.getOperand(0)),
1119 if (
I->second.isOverdefined())
1120 TrackedGlobals.erase(
I);
1124 if (
MDNode *Ranges =
I->getMetadata(LLVMContext::MD_range))
1125 if (
I->getType()->isIntegerTy())
1128 if (
I->hasMetadata(LLVMContext::MD_nonnull))
1136 void SCCPInstVisitor::visitLoadInst(
LoadInst &
I) {
1139 if (
I.getType()->isStructTy() ||
I.isVolatile())
1140 return (
void)markOverdefined(&
I);
1145 return (
void)markOverdefined(&
I);
1157 if (isa<ConstantPointerNull>(Ptr)) {
1159 return (
void)markOverdefined(
IV, &
I);
1165 if (
auto *GV = dyn_cast<GlobalVariable>(Ptr)) {
1166 if (!TrackedGlobals.empty()) {
1168 auto It = TrackedGlobals.find(GV);
1169 if (It != TrackedGlobals.end()) {
1178 if (isa<UndefValue>(
C))
1180 return (
void)markConstant(
IV, &
I,
C);
1188 void SCCPInstVisitor::visitCallBase(
CallBase &CB) {
1189 handleCallResult(CB);
1190 handleCallArguments(CB);
1193 void SCCPInstVisitor::handleCallOverdefined(
CallBase &CB) {
1202 return (
void)markOverdefined(&CB);
1209 if (
A.get()->getType()->isStructTy())
1210 return markOverdefined(&CB);
1216 return (
void)markOverdefined(&CB);
1222 return (
void)markOverdefined(&CB);
1228 if (isa<UndefValue>(
C))
1230 return (
void)markConstant(&CB,
C);
1238 void SCCPInstVisitor::handleCallArguments(
CallBase &CB) {
1243 if (!TrackingIncomingArguments.empty() &&
1244 TrackingIncomingArguments.count(
F)) {
1253 if (AI->hasByValAttr() && !
F->onlyReadsMemory()) {
1254 markOverdefined(&*AI);
1258 if (
auto *STy = dyn_cast<StructType>(AI->getType())) {
1259 for (
unsigned i = 0,
e = STy->getNumElements();
i !=
e; ++
i) {
1261 mergeInValue(getStructValueState(&*AI,
i), &*AI,
CallArg,
1270 void SCCPInstVisitor::handleCallResult(
CallBase &CB) {
1273 if (
auto *II = dyn_cast<IntrinsicInst>(&CB)) {
1274 if (II->getIntrinsicID() == Intrinsic::ssa_copy) {
1281 assert(PI &&
"Missing predicate info for ssa.copy");
1285 mergeInValue(ValueState[&CB], &CB, CopyOfVal);
1293 if (getValueState(OtherOp).isUnknown()) {
1294 addAdditionalUser(OtherOp, &CB);
1307 bool MayIncludeUndef = !isa<PredicateAssume>(PI);
1313 ConstantRange::getFull(
DL.getTypeSizeInBits(CopyOf->
getType()));
1324 : ConstantRange::getFull(
1325 DL.getTypeSizeInBits(CopyOf->
getType()));
1326 auto NewCR = ImposedCR.intersectWith(CopyOfCR);
1330 if (!CopyOfCR.contains(NewCR) && CopyOfCR.getSingleMissingElement())
1333 addAdditionalUser(OtherOp, &CB);
1334 mergeInValue(
IV, &CB,
1340 addAdditionalUser(OtherOp, &CB);
1341 mergeInValue(
IV, &CB, CondVal);
1346 addAdditionalUser(OtherOp, &CB);
1347 mergeInValue(
IV, &CB,
1352 return (
void)mergeInValue(
IV, &CB, CopyOfVal);
1360 for (
Value *
Op : II->args()) {
1366 ConstantRange::getFull(
Op->getType()->getScalarSizeInBits()));
1378 if (!
F ||
F->isDeclaration())
1379 return handleCallOverdefined(CB);
1382 if (
auto *STy = dyn_cast<StructType>(
F->getReturnType())) {
1383 if (!MRVFunctionsTracked.count(
F))
1384 return handleCallOverdefined(CB);
1388 for (
unsigned i = 0,
e = STy->getNumElements();
i !=
e; ++
i)
1389 mergeInValue(getStructValueState(&CB,
i), &CB,
1390 TrackedMultipleRetVals[std::make_pair(
F,
i)],
1393 auto TFRVI = TrackedRetVals.find(
F);
1394 if (TFRVI == TrackedRetVals.end())
1395 return handleCallOverdefined(CB);
1404 while (!BBWorkList.empty() || !InstWorkList.empty() ||
1405 !OverdefinedInstWorkList.empty()) {
1408 while (!OverdefinedInstWorkList.empty()) {
1409 Value *
I = OverdefinedInstWorkList.pop_back_val();
1420 markUsersAsChanged(
I);
1424 while (!InstWorkList.empty()) {
1425 Value *
I = InstWorkList.pop_back_val();
1437 markUsersAsChanged(
I);
1441 while (!BBWorkList.empty()) {
1470 bool MadeChange =
false;
1472 if (!BBExecutable.count(&
BB))
1477 if (
I.getType()->isVoidTy())
1480 if (
auto *STy = dyn_cast<StructType>(
I.getType())) {
1484 if (
auto *CB = dyn_cast<CallBase>(&
I))
1486 if (MRVFunctionsTracked.count(
F))
1491 if (isa<ExtractValueInst>(
I) || isa<InsertValueInst>(
I))
1495 for (
unsigned i = 0,
e = STy->getNumElements();
i !=
e; ++
i) {
1498 markOverdefined(LV, &
I);
1514 if (
auto *CB = dyn_cast<CallBase>(&
I))
1516 if (TrackedRetVals.count(
F))
1519 if (isa<LoadInst>(
I)) {
1526 markOverdefined(&
I);
1534 if (
auto *BI = dyn_cast<BranchInst>(TI)) {
1535 if (!BI->isConditional())
1542 if (isa<UndefValue>(BI->getCondition())) {
1554 if (markEdgeExecutable(&
BB, DefaultSuccessor))
1560 if (
auto *IBR = dyn_cast<IndirectBrInst>(TI)) {
1563 if (IBR->getNumSuccessors() < 1)
1571 if (isa<UndefValue>(IBR->getAddress())) {
1573 markEdgeExecutable(&
BB, IBR->getSuccessor(0));
1583 BasicBlock *DefaultSuccessor = IBR->getSuccessor(0);
1584 if (markEdgeExecutable(&
BB, DefaultSuccessor))
1590 if (
auto *
SI = dyn_cast<SwitchInst>(TI)) {
1591 if (!
SI->getNumCases() ||
1597 if (isa<UndefValue>(
SI->getCondition())) {
1598 SI->setCondition(
SI->case_begin()->getCaseValue());
1599 markEdgeExecutable(&
BB,
SI->case_begin()->getCaseSuccessor());
1608 BasicBlock *DefaultSuccessor =
SI->case_begin()->getCaseSuccessor();
1609 if (markEdgeExecutable(&
BB, DefaultSuccessor))
1636 return Visitor->markBlockExecutable(
BB);
1640 return Visitor->getPredicateInfoFor(
I);
1646 Visitor->trackValueOfGlobalVariable(GV);
1650 Visitor->addTrackedFunction(
F);
1654 Visitor->addToMustPreserveReturnsInFunctions(
F);
1658 return Visitor->mustPreserveReturn(
F);
1662 Visitor->addArgumentTrackedFunction(
F);
1666 return Visitor->isArgumentTrackedFunction(
F);
1672 return Visitor->resolvedUndefsIn(
F);
1676 return Visitor->isBlockExecutable(
BB);
1680 return Visitor->isEdgeFeasible(
From, To);
1683 std::vector<ValueLatticeElement>
1685 return Visitor->getStructLatticeValueFor(V);
1689 return Visitor->removeLatticeValueFor(V);
1693 return Visitor->getLatticeValueFor(V);
1698 return Visitor->getTrackedRetVals();
1703 return Visitor->getTrackedGlobals();
1707 return Visitor->getMRVFunctionsTracked();
1713 return Visitor->isStructLatticeConstant(
F, STy);
1717 return Visitor->getConstant(LV);
1721 return Visitor->getArgumentTrackedFunctions();
1726 Visitor->markArgInFuncSpecialization(
F,
Args);
1730 Visitor->markFunctionUnreachable(
F);
static ValueLatticeElement getNot(Constant *C)
void removeLatticeValueFor(Value *V)
MergeOptions & setMaxWidenSteps(unsigned Steps=1)
This class represents an incoming formal argument to a Function.
const ConstantRange & getConstantRange(bool UndefAllowed=true) const
Returns the constant range for this value.
This is an optimization pass for GlobalISel generic memory operations.
Return a value (possibly void), from a function.
A parsed version of the target data layout string in and methods for querying it.
const ValueLatticeElement & getLatticeValueFor(Value *V) const
DomTreeUpdater getDTU(Function &F)
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Helper struct for bundling up the analysis results per function for IPSCCP.
Constant * getConstant() const
std::vector< ValueLatticeElement > getStructLatticeValueFor(Value *V) const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
static ValueLatticeElement::MergeOptions getMaxWidenStepsOpts()
Returns MergeOptions with MaxWidenSteps set to MaxNumRangeExtensions.
bool isEdgeFeasible(BasicBlock *From, BasicBlock *To) const
void markArgInFuncSpecialization(Function *F, const SmallVectorImpl< ArgInfo > &Args)
Constant * getConstant(const ValueLatticeElement &LV) const
Helper to return a Constant if LV is either a constant or a constant range with a single element.
bool erase(const KeyT &Val)
bool isStructLatticeConstant(Function *F, StructType *STy)
The instances of the Type class are immutable: once they are created, they are never changed.
static ValueLatticeElement getOverdefined()
An instruction for ordering other memory operations.
This class implements a map that also provides access to all stored values in a deterministic order.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
bool markBlockExecutable(BasicBlock *BB)
markBlockExecutable - This method can be used by clients to mark all of the blocks that are known to ...
User::op_iterator arg_begin()
Return the iterator pointing to the beginning of the argument list.
void visit(Instruction *I)
ConstantRange getConstantRangeFromMetadata(const MDNode &RangeMD)
Parse out a conservative ConstantRange from !range metadata.
SCCPInstVisitor(const DataLayout &DL, std::function< const TargetLibraryInfo &(Function &)> GetTLI, LLVMContext &Ctx)
std::pair< iterator, bool > insert(const ValueT &V)
size_type count(const_arg_type_t< ValueT > V) const
Return 1 if the specified key is in the set, 0 otherwise.
bool isExceptionalTerminator() const
void addArgumentTrackedFunction(Function *F)
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 bool isIntrinsicSupported(Intrinsic::ID IntrinsicID)
Returns true if ConstantRange calculations are supported for intrinsic with IntrinsicID.
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 ID Predecessors according to mbb< bb27, 0x8b0a7c0 > Note ADDri is not a two address instruction its result reg1037 is an operand of the PHI node in bb76 and its operand reg1039 is the result of the PHI node We should treat it as a two address code and make sure the ADDri is scheduled after any node that reads reg1039 Use info(i.e. register scavenger) to assign it a free register to allow reuse the collector could move the objects and invalidate the derived pointer This is bad enough in the first but safe points can crop up unpredictably **array_addr i32 n y store obj * new
void markFunctionUnreachable(Function *F)
Mark all of the blocks in function F non-executable.
bool resolvedUndefsIn(Function &F)
resolvedUndefsIn - While solving the dataflow for a function, we assume that branches on undef values...
LLVM Basic Block Representation.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
This is the shared class of boolean and integer constants.
bool isArgumentTrackedFunction(Function *F)
static ValueLatticeElement getValueFromMetadata(const Instruction *I)
unsigned getNumSuccessors() const
Return the number of successors that this instruction has.
bool isSingleValueType() const
Return true if the type is a valid type for a register in codegen.
Struct to control some aspects related to merging constant ranges.
void markOverdefined(Value *V)
bool isUnknownOrUndef() const
Value * getIncomingValue(unsigned i) const
Return incoming value number x.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
void markOverdefined(Value *V)
markOverdefined - Mark the specified value overdefined.
Constant * ConstantFoldCastOperand(unsigned Opcode, Constant *C, Type *DestTy, const DataLayout &DL)
Attempt to constant fold a cast with the specified operand.
(vector float) vec_cmpeq(*A, *B) C
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
bool isArgumentTrackedFunction(Function *F)
Returns true if the given function is in the solver's set of argument-tracked functions.
bool isSingleElement() const
Return true if this set contains exactly one member.
static Optional< unsigned > getOpcode(ArrayRef< VPValue * > Values)
Returns the opcode of Values or ~0 if they do not all agree.
Constant * ConstantFoldCall(const CallBase *Call, Function *F, ArrayRef< Constant * > Operands, const TargetLibraryInfo *TLI=nullptr)
ConstantFoldCall - Attempt to constant fold a call to the specified function with the specified argum...
bool canConstantFoldCallTo(const CallBase *Call, const Function *F)
canConstantFoldCallTo - Return true if its even possible to fold a call to the specified function.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
void addAnalysis(Function &F, AnalysisResultsForFn A)
iterator_range< const_phi_iterator > phis() const
Returns a range that iterates over the phis in the basic block.
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 isStructLatticeConstant(Function *F, StructType *STy)
BasicBlock * getSuccessor(unsigned Idx) const
Return the specified successor. This instruction must be a terminator.
const SmallPtrSet< Function *, 16 > getMRVFunctionsTracked()
unsigned getNumIncomingValues() const
Return the number of incoming edges.
CmpInst::Predicate Predicate
static ConstantRange intrinsic(Intrinsic::ID IntrinsicID, ArrayRef< ConstantRange > Ops)
Compute range of intrinsic result for the given operand ranges.
mir Rename Register Operands
This class is the base class for the comparison instructions.
bool markConstant(Constant *V, bool MayIncludeUndef=false)
const MapVector< Function *, ValueLatticeElement > & getTrackedRetVals()
getTrackedRetVals - Get the inferred return value map.
ConstantRange castOp(Instruction::CastOps CastOp, uint32_t BitWidth) const
Return a new range representing the possible values resulting from an application of the specified ca...
void visitCall(CallInst &I)
const ValueLatticeElement & getLatticeValueFor(Value *V) const
An instruction for storing to memory.
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
This is an important base class in LLVM.
uint32_t getBitWidth() const
Get the bit width of this ConstantRange.
std::string getNameOrAsOperand() const
Helper class for SCCPSolver.
static ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
Value * SimplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS, const SimplifyQuery &Q)
Given operands for a BinaryOperator, fold the result or return null.
CallBr instruction, tracking function calls that may not return control but instead transfer it to a ...
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
This is an important class for using LLVM in a threaded context.
static bool isConstant(const MachineInstr &MI)
const PredicateBase * getPredicateInfoFor(Instruction *I)
void addArgumentTrackedFunction(Function *F)
static const unsigned MaxNumRangeExtensions
static Constant * get(unsigned Opcode, Constant *C1, unsigned Flags=0, Type *OnlyIfReducedTy=nullptr)
get - Return a unary operator constant expression, folding if possible.
SmallPtrSetImpl< Function * > & getArgumentTrackedFunctions()
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
void visit(Iterator Start, Iterator End)
const MapVector< Function *, ValueLatticeElement > & getTrackedRetVals()
Constant * getCompare(CmpInst::Predicate Pred, Type *Ty, const ValueLatticeElement &Other) const
true, false or undef constants, or nullptr if the comparison cannot be evaluated.
const DenseMap< GlobalVariable *, ValueLatticeElement > & getTrackedGlobals()
getTrackedGlobals - Get and return the set of inferred initializers for global variables.
unsigned getNumRangeExtensions() const
iterator find(const_arg_type_t< KeyT > Val)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
StandardInstrumentations SI(Debug, VerifyEach)
This class represents the LLVM 'select' instruction.
print Print MemDeps of function
bool isVoidTy() const
Return true if this is 'void'.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
Class for arbitrary precision integers.
bool mustPreserveReturn(Function *F)
The address of a basic block.
DomTreeUpdater getDTU(Function &F)
void markArgInFuncSpecialization(Function *F, const SmallVectorImpl< ArgInfo > &Args)
Mark the constant arguments of a new function specialization.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
SCCPSolver(const DataLayout &DL, std::function< const TargetLibraryInfo &(Function &)> GetTLI, LLVMContext &Ctx)
Class to represent struct types.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Constant * getAggregateElement(unsigned Elt) const
For aggregates (struct/array/vector) return the constant that corresponds to the specified element if...
Type * getType() const
All values are typed, get the type of this value.
bool isZero() const
This is just a convenience method to make client code smaller for a common code.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
void removeLatticeValueFor(Value *V)
This class represents lattice values for constants.
Base class for instruction visitors.
bool mustPreserveReturn(Function *F)
Returns true if the return of the given function cannot be modified.
This is the base class for all instructions that perform data casts.
StringRef getName() const
Return a constant reference to the value's name.
void trackValueOfGlobalVariable(GlobalVariable *GV)
An instruction for reading from memory.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
bool isOverdefined() const
const DenseMap< GlobalVariable *, ValueLatticeElement > & getTrackedGlobals()
Constant * getConstant(const ValueLatticeElement &LV) const
bool isBlockExecutable(BasicBlock *BB) const
unsigned getNumElements() const
Random access to the elements.
static ConstantInt * getFalse(LLVMContext &Context)
Constant * ConstantFoldLoadFromConstPtr(Constant *C, Type *Ty, APInt Offset, const DataLayout &DL)
Return the value that a load from C with offset Offset would produce if it is constant and determinab...
bool isEdgeFeasible(BasicBlock *From, BasicBlock *To) const
void markFunctionUnreachable(Function *F)
Resume the propagation of an exception.
void assign(size_type NumElts, ValueParamT Elt)
const PredicateBase * getPredicateInfoFor(Instruction *I)
static ValueLatticeElement getRange(ConstantRange CR, bool MayIncludeUndef=false)
Provides information about what library functions are available for the current target.
bool resolvedUndefsIn(Function &F)
resolvedUndefsIn - While solving the dataflow for a function, we assume that branches on undef values...
void addTrackedFunction(Function *F)
static Constant * getGetElementPtr(Type *Ty, Constant *C, ArrayRef< Constant * > IdxList, bool InBounds=false, Optional< unsigned > InRangeIndex=None, Type *OnlyIfReducedTy=nullptr)
Getelementptr form.
bool contains(const APInt &Val) const
Return true if the specified value is in the set.
This class represents a range of values.
bool mergeIn(const ValueLatticeElement &RHS, MergeOptions Opts=MergeOptions())
Updates this object to approximate both this object and RHS.
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
void addToMustPreserveReturnsInFunctions(Function *F)
Add function to the list of functions whose return cannot be modified.
bool isStructTy() const
True if this is an instance of StructType.
bool isConstantRange(bool UndefAllowed=true) const
Returns true if this value is a constant range.
const BasicBlock * getParent() const
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.
Align max(MaybeAlign Lhs, Align Rhs)
static const uint32_t IV[8]
void trackValueOfGlobalVariable(GlobalVariable *GV)
trackValueOfGlobalVariable - Clients can use this method to inform the SCCPSolver that it should trac...
void addToMustPreserveReturnsInFunctions(Function *F)
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
Type * getValueType() const
std::vector< ValueLatticeElement > getStructLatticeValueFor(Value *V) const
This class represents a function call, abstracting a target machine's calling convention.
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
This function has undefined behavior.
void solve()
Solve - Solve for constants and executable blocks.
BlockVerifier::State From
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Value * getOperand(unsigned i) const
void addAnalysis(Function &F, AnalysisResultsForFn A)
bool NullPointerIsDefined(const Function *F, unsigned AS=0)
Check whether null pointer dereferencing is considered undefined behavior for a given function or an ...
void addTrackedFunction(Function *F)
addTrackedFunction - If the SCCP solver is supposed to track calls into and out of the specified func...
This instruction inserts a struct field of array element value into an aggregate value.
void visitCallInst(CallInst &I)
bool markBlockExecutable(BasicBlock *BB)
MergeOptions & setCheckWiden(bool V=true)
LLVM Value Representation.
const SmallPtrSet< Function *, 16 > getMRVFunctionsTracked()
getMRVFunctionsTracked - Get the set of functions which return multiple values tracked by the pass.
iterator_range< User::op_iterator > args()
Iteration adapter for range-for loops.
SmallPtrSetImpl< Function * > & getArgumentTrackedFunctions()
Return a reference to the set of argument tracked functions.
void setNumRangeExtensions(unsigned N)
bool isBlockExecutable(BasicBlock *BB) const
static bool isOverdefined(const ValueLatticeElement &LV)
A Use represents the edge between a Value definition and its users.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.