Go to the documentation of this file.
91 #define DEBUG_TYPE "local"
93 STATISTIC(NumRemoved,
"Number of unreachable basic blocks removed");
94 STATISTIC(NumPHICSEs,
"Number of PHI's that got CSE'd");
98 #ifdef EXPENSIVE_CHECKS
104 cl::desc(
"Perform extra assertion checking to verify that PHINodes's hash "
105 "function is well-behaved w.r.t. its isEqual predicate"));
110 "When the basic block contains not more than this number of PHI nodes, "
111 "perform a (faster!) exhaustive search instead of set-driven one."));
135 if (
auto *BI = dyn_cast<BranchInst>(
T)) {
136 if (BI->isUnconditional())
return false;
141 if (Dest2 == Dest1) {
147 assert(BI->getParent() &&
"Terminator not inserted in block!");
153 BI->eraseFromParent();
154 if (DeleteDeadConditions)
159 if (
auto *
Cond = dyn_cast<ConstantInt>(BI->getCondition())) {
171 BI->eraseFromParent();
180 if (
auto *
SI = dyn_cast<SwitchInst>(
T)) {
183 auto *CI = dyn_cast<ConstantInt>(
SI->getCondition());
189 SI->getNumCases() > 0) {
190 TheOnlyDest =
SI->case_begin()->getCaseSuccessor();
193 bool Changed =
false;
196 for (
auto i =
SI->case_begin(),
e =
SI->case_end();
i !=
e;) {
198 if (
i->getCaseValue() == CI) {
199 TheOnlyDest =
i->getCaseSuccessor();
205 if (
i->getCaseSuccessor() == DefaultDest) {
206 MDNode *MD =
SI->getMetadata(LLVMContext::MD_prof);
207 unsigned NCases =
SI->getNumCases();
215 auto *CI = mdconst::extract<ConstantInt>(MD->
getOperand(MD_i));
216 Weights.push_back(CI->getValue().getZExtValue());
219 unsigned idx =
i->getCaseIndex();
220 Weights[0] += Weights[idx+1];
222 std::swap(Weights[idx+1], Weights.back());
224 SI->setMetadata(LLVMContext::MD_prof,
226 createBranchWeights(Weights));
231 i =
SI->removeCase(
i);
240 if (
i->getCaseSuccessor() != TheOnlyDest)
241 TheOnlyDest =
nullptr;
247 if (CI && !TheOnlyDest) {
250 TheOnlyDest =
SI->getDefaultDest();
265 if (DTU && Succ != TheOnlyDest)
266 RemovedSuccessors.
insert(Succ);
268 if (Succ == SuccToKeep) {
269 SuccToKeep =
nullptr;
277 SI->eraseFromParent();
278 if (DeleteDeadConditions)
281 std::vector<DominatorTree::UpdateType> Updates;
282 Updates.reserve(RemovedSuccessors.
size());
283 for (
auto *RemovedSuccessor : RemovedSuccessors)
290 if (
SI->getNumCases() == 1) {
293 auto FirstCase = *
SI->case_begin();
295 FirstCase.getCaseValue(),
"cond");
299 FirstCase.getCaseSuccessor(),
300 SI->getDefaultDest());
301 MDNode *MD =
SI->getMetadata(LLVMContext::MD_prof);
304 mdconst::dyn_extract<ConstantInt>(MD->
getOperand(2));
306 mdconst::dyn_extract<ConstantInt>(MD->
getOperand(1));
316 MDNode *MakeImplicitMD =
SI->getMetadata(LLVMContext::MD_make_implicit);
318 NewBr->
setMetadata(LLVMContext::MD_make_implicit, MakeImplicitMD);
321 SI->eraseFromParent();
327 if (
auto *IBI = dyn_cast<IndirectBrInst>(
T)) {
330 dyn_cast<BlockAddress>(IBI->getAddress()->stripPointerCasts())) {
331 BasicBlock *TheOnlyDest = BA->getBasicBlock();
338 for (
unsigned i = 0,
e = IBI->getNumDestinations();
i !=
e; ++
i) {
340 if (DTU && DestBB != TheOnlyDest)
341 RemovedSuccessors.
insert(DestBB);
342 if (IBI->getDestination(
i) == SuccToKeep) {
343 SuccToKeep =
nullptr;
349 IBI->eraseFromParent();
350 if (DeleteDeadConditions)
357 BA->destroyConstant();
363 BB->getTerminator()->eraseFromParent();
368 std::vector<DominatorTree::UpdateType> Updates;
369 Updates.reserve(RemovedSuccessors.
size());
370 for (
auto *RemovedSuccessor : RemovedSuccessors)
397 if (
I->isTerminator())
408 if (DDI->getAddress())
413 if (DVI->hasArgList() || DVI->getValue(0))
423 if (!
I->willReturn())
426 if (!
I->mayHaveSideEffects())
433 if (II->getIntrinsicID() == Intrinsic::stacksave ||
434 II->getIntrinsicID() == Intrinsic::launder_invariant_group)
437 if (II->isLifetimeStartOrEnd()) {
438 auto *
Arg = II->getArgOperand(1);
440 if (isa<UndefValue>(
Arg))
444 if (isa<AllocaInst>(
Arg) || isa<GlobalValue>(
Arg) || isa<Argument>(
Arg))
446 if (IntrinsicInst *IntrinsicUse =
447 dyn_cast<IntrinsicInst>(Use.getUser()))
448 return IntrinsicUse->isLifetimeStartOrEnd();
458 if ((II->getIntrinsicID() == Intrinsic::assume &&
460 II->getIntrinsicID() == Intrinsic::experimental_guard) {
462 return !
Cond->isZero();
472 if (
Constant *
C = dyn_cast<Constant>(CI->getArgOperand(0)))
473 return C->isNullValue() || isa<UndefValue>(
C);
475 if (
auto *Call = dyn_cast<CallBase>(
I))
494 DeadInsts.push_back(
I);
496 AboutToDeleteCallback);
505 unsigned S = 0,
E = DeadInsts.size(), Alive = 0;
506 for (;
S !=
E; ++
S) {
507 auto *
I = cast<Instruction>(DeadInsts[
S]);
509 DeadInsts[
S] =
nullptr;
516 AboutToDeleteCallback);
525 while (!DeadInsts.empty()) {
531 "Live instruction found in dead worklist!");
532 assert(
I->use_empty() &&
"Instructions with uses are not dead.");
537 if (AboutToDeleteCallback)
538 AboutToDeleteCallback(
I);
542 for (
Use &OpU :
I->operands()) {
543 Value *OpV = OpU.get();
554 DeadInsts.push_back(OpI);
559 I->eraseFromParent();
566 for (
auto *DII : DbgUsers) {
568 DII->replaceVariableLocationOp(
I,
Undef);
570 return !DbgUsers.empty();
584 for (++UI; UI != UE; ++UI) {
601 I = cast<Instruction>(*
I->user_begin())) {
607 if (!Visited.
insert(
I).second) {
627 for (
unsigned i = 0,
e =
I->getNumOperands();
i !=
e; ++
i) {
629 I->setOperand(
i,
nullptr);
642 I->eraseFromParent();
650 for (
User *U :
I->users()) {
652 WorkList.
insert(cast<Instruction>(U));
657 bool Changed =
false;
658 if (!
I->use_empty()) {
659 I->replaceAllUsesWith(SimpleV);
663 I->eraseFromParent();
678 bool MadeChange =
false;
695 assert(!BI->isTerminator());
705 while (!WorkList.
empty()) {
720 while (
PHINode *PN = dyn_cast<PHINode>(DestBB->
begin())) {
721 Value *NewVal = PN->getIncomingValue(0);
724 PN->replaceAllUsesWith(NewVal);
725 PN->eraseFromParent();
729 assert(PredBB &&
"Block doesn't have a single predecessor!");
731 bool ReplaceEntryBB =
false;
733 ReplaceEntryBB =
true;
742 Updates.
reserve(Updates.size() + 2 * PredsOfPredBB.
size() + 1);
743 for (
BasicBlock *PredOfPredBB : PredsOfPredBB)
745 if (PredOfPredBB != PredBB)
747 for (
BasicBlock *PredOfPredBB : PredsOfPredBB)
779 "The successor list of PredBB isn't empty before "
780 "applying corresponding DTU updates.");
801 return First == Second || isa<UndefValue>(
First) || isa<UndefValue>(Second);
832 if (BBPreds.
count(IBB) &&
836 <<
"Can't fold, phi node " << PN->
getName() <<
" in "
837 << Succ->
getName() <<
" is conflicting with "
838 << BBPN->
getName() <<
" with regard to common predecessor "
850 if (BBPreds.
count(IBB) &&
854 <<
" is conflicting with regard to common "
855 <<
"predecessor " << IBB->
getName() <<
"\n");
882 if (!isa<UndefValue>(OldVal)) {
884 IncomingValues.
find(
BB)->second == OldVal) &&
885 "Expected OldVal to match incoming value from BB!");
887 IncomingValues.
insert(std::make_pair(
BB, OldVal));
892 if (It != IncomingValues.
end())
return It->second;
911 if (!isa<UndefValue>(V))
912 IncomingValues.
insert(std::make_pair(
BB, V));
927 if (!isa<UndefValue>(V))
continue;
936 if (It == IncomingValues.
end()) {
937 TrueUndefOps.push_back(
i);
949 unsigned PoisonCount =
count_if(TrueUndefOps, [&](
unsigned i) {
952 if (PoisonCount != 0 && PoisonCount != TrueUndefOps.size()) {
953 for (
unsigned i : TrueUndefOps)
969 assert(OldVal &&
"No entry in PHI for Pred BB!");
986 if (isa<PHINode>(OldVal) && cast<PHINode>(OldVal)->
getParent() ==
BB) {
987 PHINode *OldValPN = cast<PHINode>(OldVal);
1004 for (
unsigned i = 0,
e = BBPreds.size();
i !=
e; ++
i) {
1022 assert(
BB != &
BB->getParent()->getEntryBlock() &&
1023 "TryToSimplifyUncondBranchFromEmptyBlock called on entry block!");
1026 BasicBlock *Succ = cast<BranchInst>(
BB->getTerminator())->getSuccessor(0);
1027 if (
BB == Succ)
return false;
1047 while (isa<PHINode>(*BBI)) {
1049 if (
PHINode* PN = dyn_cast<PHINode>(U.getUser())) {
1050 if (PN->getIncomingBlock(U) !=
BB)
1063 if (
auto *CBI = dyn_cast<CallBrInst>(PredBB->getTerminator())) {
1064 if (Succ == CBI->getDefaultDest())
1066 for (
unsigned i = 0,
e = CBI->getNumIndirectDests();
i !=
e; ++
i)
1067 if (Succ == CBI->getIndirectDest(
i))
1079 Updates.
reserve(Updates.size() + 2 * PredsOfBB.
size() + 1);
1080 for (
auto *PredOfBB : PredsOfBB)
1082 if (!PredsOfSucc.
contains(PredOfBB))
1084 for (
auto *PredOfBB : PredsOfBB)
1089 if (isa<PHINode>(Succ->
begin())) {
1108 BB->getTerminator()->eraseFromParent();
1112 while (
PHINode *PN = dyn_cast<PHINode>(&
BB->front())) {
1114 assert(PN->use_empty() &&
"There shouldn't be any uses here!");
1115 PN->eraseFromParent();
1121 unsigned LoopMDKind =
BB->getContext().getMDKindID(
"llvm.loop");
1126 Pred->getTerminator()->setMetadata(LoopMDKind, LoopMD);
1135 BB->replaceAllUsesWith(Succ);
1139 if (
BB->getTerminator())
1140 BB->getInstList().pop_back();
1143 "applying corresponding DTU updates.");
1149 BB->eraseFromParent();
1159 bool Changed =
false;
1164 for (
auto I =
BB->begin();
PHINode *PN = dyn_cast<PHINode>(
I);) {
1169 for (
auto J =
I;
PHINode *DuplicatePN = dyn_cast<PHINode>(J); ++J) {
1191 struct PHIDenseMapInfo {
1192 static PHINode *getEmptyKey() {
1196 static PHINode *getTombstoneKey() {
1201 return PN == getEmptyKey() || PN == getTombstoneKey();
1215 static unsigned getHashValue(
PHINode *PN) {
1248 bool Changed =
false;
1249 for (
auto I =
BB->begin();
PHINode *PN = dyn_cast<PHINode>(
I++);) {
1250 auto Inserted = PHISet.
insert(PN);
1251 if (!Inserted.second) {
1254 PN->replaceAllUsesWith(*Inserted.first);
1255 PN->eraseFromParent();
1289 if (
AllocaInst *AI = dyn_cast<AllocaInst>(V)) {
1295 Align CurrentAlign = AI->getAlign();
1296 if (PrefAlign <= CurrentAlign)
1297 return CurrentAlign;
1301 if (
DL.exceedsNaturalStackAlignment(PrefAlign))
1302 return CurrentAlign;
1303 AI->setAlignment(PrefAlign);
1307 if (
auto *GO = dyn_cast<GlobalObject>(V)) {
1309 Align CurrentAlign = GO->getPointerAlignment(
DL);
1310 if (PrefAlign <= CurrentAlign)
1311 return CurrentAlign;
1317 if (!GO->canIncreaseAlignment())
1318 return CurrentAlign;
1320 GO->setAlignment(PrefAlign);
1333 "getOrEnforceKnownAlignment expects a pointer!");
1345 if (PrefAlign && *PrefAlign > Alignment)
1365 for (
auto *DVI : DbgValues) {
1367 if ((DVI->getVariable() == DIVar) && (DVI->getExpression() == DIExpr))
1384 TypeSize ValueSize =
DL.getTypeAllocSizeInBits(ValTy);
1387 "Fragments don't work on scalable types.");
1396 "address of variable must have exactly 1 location operand.");
1401 "Both sizes should agree on the scalable flag.");
1429 assert(DIVar &&
"Missing variable");
1431 Value *DV =
SI->getValueOperand();
1438 LLVM_DEBUG(
dbgs() <<
"Failed to convert dbg.declare to dbg.value: "
1444 Builder.insertDbgValueIntrinsic(DV, DIVar, DIExpr, NewLoc,
SI);
1448 Builder.insertDbgValueIntrinsic(DV, DIVar, DIExpr, NewLoc,
SI);
1457 assert(DIVar &&
"Missing variable");
1463 LLVM_DEBUG(
dbgs() <<
"Failed to convert dbg.declare to dbg.value: "
1475 LI, DIVar, DIExpr, NewLoc, (
Instruction *)
nullptr);
1485 assert(DIVar &&
"Missing variable");
1494 LLVM_DEBUG(
dbgs() <<
"Failed to convert dbg.declare to dbg.value: "
1500 auto InsertionPt =
BB->getFirstInsertionPt();
1507 if (InsertionPt !=
BB->end())
1508 Builder.insertDbgValueIntrinsic(APN, DIVar, DIExpr, NewLoc, &*InsertionPt);
1525 bool Changed =
false;
1530 if (
auto DDI = dyn_cast<DbgDeclareInst>(&BI))
1531 Dbgs.push_back(DDI);
1536 for (
auto &
I : Dbgs) {
1550 if (LoadInst *LI = dyn_cast<LoadInst>(U))
1551 return LI->isVolatile();
1552 if (StoreInst *SI = dyn_cast<StoreInst>(U))
1553 return SI->isVolatile();
1559 WorkList.push_back(AI);
1560 while (!WorkList.empty()) {
1562 for (
auto &AIUse : V->
uses()) {
1563 User *U = AIUse.getUser();
1565 if (AIUse.getOperandNo() == 1)
1567 }
else if (
LoadInst *LI = dyn_cast<LoadInst>(U)) {
1569 }
else if (
CallInst *CI = dyn_cast<CallInst>(U)) {
1573 if (!CI->isLifetimeStartOrEnd()) {
1577 DIB.insertDbgValueIntrinsic(AI, DDI->
getVariable(), DerefExpr,
1580 }
else if (
BitCastInst *BI = dyn_cast<BitCastInst>(U)) {
1581 if (BI->getType()->isPointerTy())
1582 WorkList.push_back(BI);
1600 assert(
BB &&
"No BasicBlock to clone dbg.value(s) from.");
1601 if (InsertedPHIs.size() == 0)
1606 for (
auto &
I : *
BB) {
1607 if (
auto DbgII = dyn_cast<DbgVariableIntrinsic>(&
I)) {
1608 for (
Value *V : DbgII->location_ops())
1609 if (
auto *Loc = dyn_cast_or_null<PHINode>(V))
1610 DbgValueMap.
insert({Loc, DbgII});
1613 if (DbgValueMap.
size() == 0)
1628 for (
auto PHI : InsertedPHIs) {
1633 for (
auto VI : PHI->operand_values()) {
1634 auto V = DbgValueMap.
find(
VI);
1635 if (V != DbgValueMap.
end()) {
1636 auto *DbgII = cast<DbgVariableIntrinsic>(V->second);
1637 auto NewDI = NewDbgValueMap.
find({Parent, DbgII});
1638 if (NewDI == NewDbgValueMap.
end()) {
1639 auto *NewDbgII = cast<DbgVariableIntrinsic>(DbgII->clone());
1640 NewDI = NewDbgValueMap.
insert({{Parent, DbgII}, NewDbgII}).first;
1651 for (
auto DI : NewDbgValueMap) {
1653 auto *NewDbgII = DI.second;
1655 assert(InsertionPt != Parent->
end() &&
"Ill-formed basic block");
1656 NewDbgII->insertBefore(&*InsertionPt);
1666 auto *DIVar = DII->getVariable();
1667 auto *DIExpr = DII->getExpression();
1668 assert(DIVar &&
"Missing variable");
1672 Builder.insertDeclare(NewAddress, DIVar, DIExpr, Loc, DII);
1673 DII->eraseFromParent();
1675 return !DbgAddrs.empty();
1683 assert(DIVar &&
"Missing variable");
1688 if (!DIExpr || DIExpr->getNumElements() < 1 ||
1689 DIExpr->getElement(0) != dwarf::DW_OP_deref)
1697 Builder.insertDbgValueIntrinsic(NewAddress, DIVar, DIExpr, Loc, DVI);
1706 if (
auto *DVI = dyn_cast<DbgValueInst>(U.getUser()))
1720 bool Salvaged =
false;
1722 for (
auto *DII : DbgUsers) {
1726 bool StackValue = isa<DbgValueInst>(DII);
1727 auto DIILocation = DII->location_ops();
1730 "DbgVariableIntrinsic must use salvaged instruction as its location");
1731 unsigned LocNo = std::distance(DIILocation.begin(),
find(DIILocation, &
I));
1741 DII->replaceVariableLocationOp(&
I,
I.getOperand(0));
1742 DII->setExpression(DIExpr);
1750 for (
auto *DII : DbgUsers) {
1752 DII->replaceVariableLocationOp(&
I,
Undef);
1758 unsigned BitWidth =
DL.getIndexSizeInBits(
GEP->getPointerAddressSpace());
1761 if (!
GEP->accumulateConstantOffset(
DL, ConstantOffset))
1770 return dwarf::DW_OP_plus;
1771 case Instruction::Sub:
1772 return dwarf::DW_OP_minus;
1773 case Instruction::Mul:
1774 return dwarf::DW_OP_mul;
1775 case Instruction::SDiv:
1776 return dwarf::DW_OP_div;
1777 case Instruction::SRem:
1778 return dwarf::DW_OP_mod;
1779 case Instruction::Or:
1780 return dwarf::DW_OP_or;
1781 case Instruction::And:
1782 return dwarf::DW_OP_and;
1783 case Instruction::Xor:
1784 return dwarf::DW_OP_xor;
1785 case Instruction::Shl:
1786 return dwarf::DW_OP_shl;
1787 case Instruction::LShr:
1788 return dwarf::DW_OP_shr;
1789 case Instruction::AShr:
1790 return dwarf::DW_OP_shra;
1800 auto *ConstInt = dyn_cast<ConstantInt>(BI->
getOperand(1));
1801 if (!ConstInt || ConstInt->getBitWidth() > 64)
1803 uint64_t Val = ConstInt->getSExtValue();
1813 Opcodes.
append({dwarf::DW_OP_constu, Val});
1820 Opcodes.push_back(DwarfBinOp);
1827 bool WithStackValue,
unsigned LocNo) {
1828 auto &
M = *
I.getModule();
1829 auto &
DL =
M.getDataLayout();
1843 return doSalvage(Ops);
1846 if (
auto *CI = dyn_cast<CastInst>(&
I)) {
1848 if (CI->isNoopCast(
DL))
1854 !(isa<TruncInst>(&
I) || isa<SExtInst>(&
I) || isa<ZExtInst>(&
I)))
1857 Value *FromValue = CI->getOperand(0);
1862 isa<SExtInst>(&
I)));
1866 if (
auto *
GEP = dyn_cast<GetElementPtrInst>(&
I)) {
1868 return doSalvage(Ops);
1869 }
else if (
auto *BI = dyn_cast<BinaryOperator>(&
I)) {
1871 return doSalvage(Ops);
1895 bool Changed =
false;
1897 if (isa<Instruction>(&To)) {
1898 bool DomPointAfterFrom =
From.getNextNonDebugInstruction() == &DomPoint;
1900 for (
auto *DII :
Users) {
1910 }
else if (!DT.
dominates(&DomPoint, DII)) {
1911 UndefOrSalvage.
insert(DII);
1917 for (
auto *DII :
Users) {
1918 if (UndefOrSalvage.
count(DII))
1931 if (!UndefOrSalvage.
empty()) {
1955 bool SameSize =
DL.getTypeSizeInBits(FromTy) ==
DL.getTypeSizeInBits(ToTy);
1956 bool LosslessConversion = !
DL.isNonIntegralPointerType(FromTy) &&
1957 !
DL.isNonIntegralPointerType(ToTy);
1958 return SameSize && LosslessConversion;
1968 if (!
From.isUsedByMetadata())
1971 assert(&
From != &To &&
"Can't replace something with itself");
1977 return DII.getExpression();
1991 assert(FromBits != ToBits &&
"Unexpected no-op conversion");
1995 if (FromBits < ToBits)
2019 std::pair<unsigned, unsigned>
2021 unsigned NumDeadInst = 0;
2022 unsigned NumDeadDbgInst = 0;
2026 while (EndInst != &
BB->front()) {
2035 if (isa<DbgInfoIntrinsic>(Inst))
2041 return {NumDeadInst, NumDeadDbgInst};
2070 UI->setDebugLoc(
I->getDebugLoc());
2073 unsigned NumInstrsRemoved = 0;
2075 while (BBI != BBE) {
2076 if (!BBI->use_empty())
2078 BB->getInstList().erase(BBI++);
2084 for (
BasicBlock *UniqueSuccessor : UniqueSuccessors)
2088 return NumInstrsRemoved;
2103 uint64_t TotalWeight;
2107 auto NewWeights =
uint32_t(TotalWeight) != TotalWeight
2110 NewCall->
setMetadata(LLVMContext::MD_prof, NewWeights);
2147 BB->getInstList().pop_back();
2161 UnwindEdge, InvokeArgs, OpBundles, CI->
getName(),
BB);
2183 Worklist.push_back(
BB);
2185 bool Changed =
false;
2193 if (
auto *CI = dyn_cast<CallInst>(&
I)) {
2197 auto IntrinsicID =
F->getIntrinsicID();
2202 if (IntrinsicID == Intrinsic::assume) {
2209 }
else if (IntrinsicID == Intrinsic::experimental_guard) {
2220 if (!isa<UnreachableInst>(CI->getNextNode())) {
2227 }
else if ((isa<ConstantPointerNull>(
Callee) &&
2229 isa<UndefValue>(
Callee)) {
2234 if (CI->doesNotReturn() && !CI->isMustTailCall()) {
2238 if (!isa<UnreachableInst>(CI->getNextNode())) {
2245 }
else if (
auto *
SI = dyn_cast<StoreInst>(&
I)) {
2251 if (
SI->isVolatile())
continue;
2253 Value *Ptr =
SI->getOperand(1);
2255 if (isa<UndefValue>(Ptr) ||
2256 (isa<ConstantPointerNull>(Ptr) &&
2258 SI->getPointerAddressSpace()))) {
2267 if (
auto *II = dyn_cast<InvokeInst>(
Terminator)) {
2270 if ((isa<ConstantPointerNull>(
Callee) &&
2272 isa<UndefValue>(
Callee)) {
2276 if (II->use_empty() && II->onlyReadsMemory()) {
2278 BasicBlock *NormalDestBB = II->getNormalDest();
2279 BasicBlock *UnwindDestBB = II->getUnwindDest();
2282 II->eraseFromParent();
2289 }
else if (
auto *CatchSwitch = dyn_cast<CatchSwitchInst>(
Terminator)) {
2291 struct CatchPadDenseMapInfo {
2306 if (LHS == getEmptyKey() || LHS == getTombstoneKey() ||
2307 RHS == getEmptyKey() || RHS == getTombstoneKey())
2320 E = CatchSwitch->handler_end();
2324 ++NumPerSuccessorCases[HandlerBB];
2325 auto *CatchPad = cast<CatchPadInst>(HandlerBB->
getFirstNonPHI());
2326 if (!HandlerSet.insert({CatchPad, Empty}).second) {
2328 --NumPerSuccessorCases[HandlerBB];
2329 CatchSwitch->removeHandler(
I);
2336 std::vector<DominatorTree::UpdateType> Updates;
2337 for (
const std::pair<BasicBlock *, int> &
I : NumPerSuccessorCases)
2340 DTU->applyUpdates(Updates);
2348 }
while (!Worklist.empty());
2355 if (
auto *II = dyn_cast<InvokeInst>(TI)) {
2363 if (
auto *CRI = dyn_cast<CleanupReturnInst>(TI)) {
2365 UnwindDest = CRI->getUnwindDest();
2366 }
else if (
auto *CatchSwitch = dyn_cast<CatchSwitchInst>(TI)) {
2368 CatchSwitch->getParentPad(),
nullptr, CatchSwitch->getNumHandlers(),
2369 CatchSwitch->getName(), CatchSwitch);
2370 for (
BasicBlock *PadBB : CatchSwitch->handlers())
2371 NewCatchSwitch->addHandler(PadBB);
2373 NewTI = NewCatchSwitch;
2374 UnwindDest = CatchSwitch->getUnwindDest();
2397 if (Reachable.
size() ==
F.size())
2414 if (BlocksToRemove.
empty())
2418 NumRemoved += BlocksToRemove.
size();
2425 std::vector<DominatorTree::UpdateType> Updates;
2426 for (
auto *
BB : BlocksToRemove) {
2435 BB->dropAllReferences();
2438 assert(TI &&
"Basic block should have a terminator");
2446 "applying corresponding DTU updates.");
2447 Updates.reserve(Updates.size() + UniqueSuccessors.
size());
2448 for (
auto *UniqueSuccessor : UniqueSuccessors)
2455 for (
auto *
BB : BlocksToRemove)
2458 for (
auto *
BB : BlocksToRemove)
2459 BB->eraseFromParent();
2471 unsigned Kind = MD.first;
2479 case LLVMContext::MD_dbg:
2481 case LLVMContext::MD_tbaa:
2484 case LLVMContext::MD_alias_scope:
2487 case LLVMContext::MD_noalias:
2488 case LLVMContext::MD_mem_parallel_loop_access:
2491 case LLVMContext::MD_access_group:
2495 case LLVMContext::MD_range:
2506 case LLVMContext::MD_fpmath:
2509 case LLVMContext::MD_invariant_load:
2513 case LLVMContext::MD_nonnull:
2518 case LLVMContext::MD_invariant_group:
2521 case LLVMContext::MD_align:
2525 case LLVMContext::MD_dereferenceable:
2526 case LLVMContext::MD_dereferenceable_or_null:
2530 case LLVMContext::MD_preserve_access_index:
2541 if (
auto *JMD = J->
getMetadata(LLVMContext::MD_invariant_group))
2542 if (isa<LoadInst>(K) || isa<StoreInst>(K))
2543 K->
setMetadata(LLVMContext::MD_invariant_group, JMD);
2548 unsigned KnownIDs[] = {
2549 LLVMContext::MD_tbaa, LLVMContext::MD_alias_scope,
2550 LLVMContext::MD_noalias, LLVMContext::MD_range,
2551 LLVMContext::MD_invariant_load, LLVMContext::MD_nonnull,
2552 LLVMContext::MD_invariant_group, LLVMContext::MD_align,
2553 LLVMContext::MD_dereferenceable,
2554 LLVMContext::MD_dereferenceable_or_null,
2555 LLVMContext::MD_access_group, LLVMContext::MD_preserve_access_index};
2561 Source.getAllMetadata(MD);
2565 for (
const auto &MDPair : MD) {
2566 unsigned ID = MDPair.first;
2576 case LLVMContext::MD_dbg:
2577 case LLVMContext::MD_tbaa:
2578 case LLVMContext::MD_prof:
2579 case LLVMContext::MD_fpmath:
2580 case LLVMContext::MD_tbaa_struct:
2581 case LLVMContext::MD_invariant_load:
2582 case LLVMContext::MD_alias_scope:
2583 case LLVMContext::MD_noalias:
2584 case LLVMContext::MD_nontemporal:
2585 case LLVMContext::MD_mem_parallel_loop_access:
2586 case LLVMContext::MD_access_group:
2591 case LLVMContext::MD_nonnull:
2595 case LLVMContext::MD_align:
2596 case LLVMContext::MD_dereferenceable:
2597 case LLVMContext::MD_dereferenceable_or_null:
2603 case LLVMContext::MD_range:
2611 auto *ReplInst = dyn_cast<Instruction>(Repl);
2621 if (!isa<LoadInst>(
I))
2622 ReplInst->andIRFlags(
I);
2633 static const unsigned KnownIDs[] = {
2634 LLVMContext::MD_tbaa, LLVMContext::MD_alias_scope,
2635 LLVMContext::MD_noalias, LLVMContext::MD_range,
2636 LLVMContext::MD_fpmath, LLVMContext::MD_invariant_load,
2637 LLVMContext::MD_invariant_group, LLVMContext::MD_nonnull,
2638 LLVMContext::MD_access_group, LLVMContext::MD_preserve_access_index};
2642 template <
typename RootType,
typename DominatesFn>
2644 const RootType &Root,
2645 const DominatesFn &Dominates) {
2652 if (!Dominates(Root, U))
2656 <<
"' as " << *To <<
" in " << *U <<
"\n");
2664 auto *
BB =
From->getParent();
2670 auto *
I = cast<Instruction>(U.
getUser());
2671 if (
I->getParent() ==
BB)
2700 if (Call->hasFnAttr(
"gc-leaf-function"))
2702 if (
const Function *
F = Call->getCalledFunction()) {
2703 if (
F->hasFnAttribute(
"gc-leaf-function"))
2706 if (
auto IID =
F->getIntrinsicID()) {
2708 return IID != Intrinsic::experimental_gc_statepoint &&
2709 IID != Intrinsic::experimental_deoptimize &&
2710 IID != Intrinsic::memcpy_element_unordered_atomic &&
2711 IID != Intrinsic::memmove_element_unordered_atomic;
2728 auto *NewTy = NewLI.
getType();
2731 if (NewTy->isPointerTy()) {
2738 if (!NewTy->isIntegerTy())
2743 auto *ITy = cast<IntegerType>(NewTy);
2753 auto *NewTy = NewLI.
getType();
2759 if (!NewTy->isPointerTy())
2762 unsigned BitWidth =
DL.getPointerTypeSizeInBits(NewTy);
2772 for (
auto *DII : DbgUsers)
2773 DII->eraseFromParent();
2808 I->dropUnknownNonDebugMetadata();
2809 if (
I->isUsedByMetadata())
2811 if (isa<DbgInfoIntrinsic>(
I)) {
2813 II =
I->eraseFromParent();
2821 BB->getTerminator()->getIterator());
2829 BitPart(
Value *
P,
unsigned BW) : Provider(
P) {
2830 Provenance.resize(BW);
2840 enum { Unset = -1 };
2875 auto I = BPS.find(V);
2879 auto &Result = BPS[V] =
None;
2888 LLVM_DEBUG(
dbgs() <<
"collectBitParts max recursion depth reached.\n");
2892 if (
auto *
I = dyn_cast<Instruction>(V)) {
2906 if (!A->Provider || A->Provider !=
B->Provider)
2909 Result = BitPart(A->Provider,
BitWidth);
2910 for (
unsigned BitIdx = 0; BitIdx <
BitWidth; ++BitIdx) {
2911 if (A->Provenance[BitIdx] != BitPart::Unset &&
2912 B->Provenance[BitIdx] != BitPart::Unset &&
2913 A->Provenance[BitIdx] !=
B->Provenance[BitIdx])
2914 return Result =
None;
2916 if (A->Provenance[BitIdx] == BitPart::Unset)
2917 Result->Provenance[BitIdx] =
B->Provenance[BitIdx];
2919 Result->Provenance[BitIdx] = A->Provenance[BitIdx];
2927 const APInt &BitShift = *
C;
2940 auto &
P = Result->Provenance;
2941 if (
I->getOpcode() == Instruction::Shl) {
2955 const APInt &AndMask = *
C;
2960 if (!MatchBitReversals && (NumMaskedBits % 8) != 0)
2969 for (
unsigned BitIdx = 0; BitIdx <
BitWidth; ++BitIdx)
2971 if (AndMask[BitIdx] == 0)
2972 Result->Provenance[BitIdx] = BitPart::Unset;
2983 Result = BitPart(Res->Provider,
BitWidth);
2984 auto NarrowBitWidth =
X->getType()->getScalarSizeInBits();
2985 for (
unsigned BitIdx = 0; BitIdx < NarrowBitWidth; ++BitIdx)
2986 Result->Provenance[BitIdx] = Res->Provenance[BitIdx];
2987 for (
unsigned BitIdx = NarrowBitWidth; BitIdx <
BitWidth; ++BitIdx)
2988 Result->Provenance[BitIdx] = BitPart::Unset;
2999 Result = BitPart(Res->Provider,
BitWidth);
3000 for (
unsigned BitIdx = 0; BitIdx <
BitWidth; ++BitIdx)
3001 Result->Provenance[BitIdx] = Res->Provenance[BitIdx];
3013 Result = BitPart(Res->Provider,
BitWidth);
3014 for (
unsigned BitIdx = 0; BitIdx <
BitWidth; ++BitIdx)
3015 Result->Provenance[(
BitWidth - 1) - BitIdx] = Res->Provenance[BitIdx];
3027 Result = BitPart(Res->Provider,
BitWidth);
3028 for (
unsigned ByteIdx = 0; ByteIdx < ByteWidth; ++ByteIdx) {
3029 unsigned ByteBitOfs = ByteIdx * 8;
3030 for (
unsigned BitIdx = 0; BitIdx < 8; ++BitIdx)
3031 Result->Provenance[(
BitWidth - 8 - ByteBitOfs) + BitIdx] =
3032 Res->Provenance[ByteBitOfs + BitIdx];
3054 if (!LHS || !RHS || !LHS->Provider || LHS->Provider != RHS->Provider)
3057 unsigned StartBitRHS =
BitWidth - ModAmt;
3058 Result = BitPart(LHS->Provider,
BitWidth);
3059 for (
unsigned BitIdx = 0; BitIdx < StartBitRHS; ++BitIdx)
3060 Result->Provenance[BitIdx + ModAmt] = LHS->Provenance[BitIdx];
3061 for (
unsigned BitIdx = 0; BitIdx < ModAmt; ++BitIdx)
3062 Result->Provenance[BitIdx] = RHS->Provenance[BitIdx + StartBitRHS];
3070 for (
unsigned BitIdx = 0; BitIdx <
BitWidth; ++BitIdx)
3071 Result->Provenance[BitIdx] = BitIdx;
3077 if (
From % 8 != To % 8)
3092 Instruction *
I,
bool MatchBSwaps,
bool MatchBitReversals,
3096 if (!MatchBSwaps && !MatchBitReversals)
3098 Type *ITy =
I->getType();
3102 Type *DemandedTy = ITy;
3104 if (
auto *Trunc = dyn_cast<TruncInst>(
I->user_back()))
3105 DemandedTy = Trunc->getType();
3108 std::map<Value *, Optional<BitPart>> BPS;
3114 [](int8_t
I) {
return I == BitPart::Unset || 0 <=
I; }) &&
3115 "Illegal bit provenance index");
3118 if (BitProvenance.
back() == BitPart::Unset) {
3119 while (!BitProvenance.
empty() && BitProvenance.
back() == BitPart::Unset)
3120 BitProvenance = BitProvenance.
drop_back();
3121 if (BitProvenance.
empty())
3124 if (
auto *IVecTy = dyn_cast<VectorType>(ITy))
3136 bool OKForBSwap = MatchBSwaps && (DemandedBW % 16) == 0;
3137 bool OKForBitReverse = MatchBitReversals;
3138 for (
unsigned BitIdx = 0;
3139 (BitIdx < DemandedBW) && (OKForBSwap || OKForBitReverse); ++BitIdx) {
3140 if (BitProvenance[BitIdx] == BitPart::Unset) {
3147 BitIdx, DemandedBW);
3152 Intrin = Intrinsic::bswap;
3153 else if (OKForBitReverse)
3154 Intrin = Intrinsic::bitreverse;
3159 Value *Provider = Res->Provider;
3162 if (DemandedTy != Provider->
getType()) {
3165 InsertedInsts.push_back(Trunc);
3170 InsertedInsts.push_back(Result);
3175 InsertedInsts.push_back(Result);
3179 if (ITy != Result->getType()) {
3181 InsertedInsts.push_back(ExtInst);
3196 if (
F && !
F->hasLocalLinkage() &&
F->hasName() &&
3198 !
F->doesNotAccessMemory())
3204 if (
I->getOperand(OpIdx)->getType()->isMetadataTy())
3208 if (!isa<Constant>(
I->getOperand(OpIdx)))
3211 switch (
I->getOpcode()) {
3215 case Instruction::Invoke: {
3216 const auto &CB = cast<CallBase>(*
I);
3219 if (CB.isInlineAsm())
3224 if (CB.isBundleOperand(OpIdx))
3227 if (OpIdx < CB.getNumArgOperands()) {
3230 if (isa<IntrinsicInst>(CB) &&
3231 OpIdx >= CB.getFunctionType()->getNumParams()) {
3233 return CB.getIntrinsicID() == Intrinsic::experimental_stackmap;
3238 if (CB.getIntrinsicID() == Intrinsic::gcroot)
3242 return !CB.paramHasAttr(OpIdx, Attribute::ImmArg);
3247 return !isa<IntrinsicInst>(CB);
3249 case Instruction::ShuffleVector:
3252 case Instruction::Switch:
3253 case Instruction::ExtractValue:
3256 case Instruction::InsertValue:
3259 case Instruction::Alloca:
3263 return !cast<AllocaInst>(
I)->isStaticAlloca();
3264 case Instruction::GetElementPtr:
3268 for (
auto E = std::next(It, OpIdx); It !=
E; ++It)
3277 if (
Constant *
C = dyn_cast<Constant>(Condition))
3281 Value *NotCondition;
3283 return NotCondition;
3286 Instruction *Inst = dyn_cast<Instruction>(Condition);
3289 else if (
Argument *
Arg = dyn_cast<Argument>(Condition))
3290 Parent = &
Arg->getParent()->getEntryBlock();
3291 assert(Parent &&
"Unsupported condition to invert");
3302 if (Inst && !isa<PHINode>(Inst))
3303 Inverted->insertAfter(Inst);
3313 bool Changed =
false;
3315 if (!
F.hasFnAttribute(Attribute::NoSync) &&
3316 F.doesNotAccessMemory() && !
F.isConvergent()) {
3322 if (!
F.hasFnAttribute(Attribute::NoFree) &&
F.onlyReadsMemory()) {
3323 F.setDoesNotFreeMemory();
3328 if (!
F.hasFnAttribute(Attribute::MustProgress) &&
F.willReturn()) {
3329 F.setMustProgress();
static DIExpression * prepend(const DIExpression *Expr, uint8_t Flags, int64_t Offset=0)
Prepend DIExpr with a deref and offset operation and optionally turn it into a stack value or/and an ...
BasicBlock * getNormalDest() const
bool hasNItemsOrLess(IterTy &&Begin, IterTy &&End, unsigned N, Pred &&ShouldBeCounted=[](const decltype(*std::declval< IterTy >()) &) { return true;})
Returns true if the sequence [Begin, End) has N or less items.
Value * invertCondition(Value *Condition)
Invert the given true/false value, possibly reusing an existing copy.
DIExpression * getExpression() const
bool RecursivelyDeleteTriviallyDeadInstructions(Value *V, const TargetLibraryInfo *TLI=nullptr, MemorySSAUpdater *MSSAU=nullptr, std::function< void(Value *)> AboutToDeleteCallback=std::function< void(Value *)>())
If the specified value is a trivially dead instruction, delete it.
This class represents an incoming formal argument to a Function.
m_Intrinsic_Ty< Opnd0, Opnd1, Opnd2 >::Ty m_FShr(const Opnd0 &Op0, const Opnd1 &Op1, const Opnd2 &Op2)
pred_range predecessors(BasicBlock *BB)
static Value * selectIncomingValueForBlock(Value *OldVal, BasicBlock *BB, IncomingValueMap &IncomingValues)
Determines the value to use as the phi node input for a block.
static CatchSwitchInst * Create(Value *ParentPad, BasicBlock *UnwindDest, unsigned NumHandlers, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
ArrayRef< T > drop_back(size_t N=1) const
Drop the last N elements of the array.
void combineMetadata(Instruction *K, const Instruction *J, ArrayRef< unsigned > KnownIDs, bool DoesKMove)
Combine the metadata of two instructions so that K can replace J.
Value * getAddress() const
void getOperandBundlesAsDefs(SmallVectorImpl< OperandBundleDef > &Defs) const
Return the list of operand bundles attached to this instruction as a vector of OperandBundleDefs.
static InvokeInst * Create(FunctionType *Ty, Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, const Twine &NameStr, Instruction *InsertBefore=nullptr)
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
void ConvertDebugDeclareToDebugValue(DbgVariableIntrinsic *DII, StoreInst *SI, DIBuilder &Builder)
===------------------------------------------------------------------—===// Dbg Intrinsic utilities
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
bool moveAndDanglePseudoProbes(BasicBlock *From, Instruction *To)
A block emptied (i.e., with all instructions moved out of it) won't be sampled at run time.
void reserve(size_t Size)
Grow the DenseSet so that it can contain at least NumEntries items before resizing again.
void deleteBB(BasicBlock *DelBB)
Delete DelBB.
static Constant * getNot(Constant *C)
A parsed version of the target data layout string in and methods for querying it.
const Instruction * getFirstNonPHIOrDbg(bool SkipPseudoOp=false) const
Returns a pointer to the first instruction in this block that is not a PHINode or a debug intrinsic,...
Function * getDeclaration(Module *M, ID id, ArrayRef< Type * > Tys=None)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
static void replaceOneDbgValueForAlloca(DbgValueInst *DVI, Value *NewAddress, DIBuilder &Builder, int Offset)
InstListType::iterator iterator
Instruction iterators...
const Function * getParent() const
Return the enclosing method, or null if none.
bool isPointerTy() const
True if this is an instance of PointerType.
static unsigned getHashValueImpl(SimpleValue Val)
void applyUpdates(ArrayRef< DominatorTree::UpdateType > Updates)
Submit updates to all available trees.
const Instruction * getNextNonDebugInstruction(bool SkipPseudoOp=false) const
Return a pointer to the next non-debug instruction in the same basic block as 'this',...
ScalarTy getFixedSize() const
bool callsGCLeafFunction(const CallBase *Call, const TargetLibraryInfo &TLI)
Return true if this call calls a gc leaf function.
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
static BinaryOperator * CreateNot(Value *Op, const Twine &Name="", Instruction *InsertBefore=nullptr)
static Align tryEnforceAlignment(Value *V, Align PrefAlign, const DataLayout &DL)
If the specified pointer points to an object that we control, try to modify the object's alignment to...
size_type size() const
Determine the number of elements in the SetVector.
This class represents a no-op cast from one type to another.
void getAllMetadataOtherThanDebugLoc(SmallVectorImpl< std::pair< unsigned, MDNode * >> &MDs) const
This does the same thing as getAllMetadata, except that it filters out the debug location.
const APInt & getValue() const
Return the constant as an APInt value reference.
unsigned replaceNonLocalUsesWith(Instruction *From, Value *To)
static bool areAllUsesEqual(Instruction *I)
areAllUsesEqual - Check whether the uses of a value are all the same.
int64_t getSExtValue() const
Get sign extended value.
match_combine_or< LTy, RTy > m_CombineOr(const LTy &L, const RTy &R)
Combine two pattern matchers matching L || R.
const BasicBlock & getEntryBlock() const
static void gatherIncomingValuesToPhi(PHINode *PN, IncomingValueMap &IncomingValues)
Create a map from block to value for the operands of a given phi.
DIExpression * salvageDebugInfoImpl(Instruction &I, DIExpression *DIExpr, bool StackVal, unsigned LocNo)
Given an instruction I and DIExpression DIExpr operating on it, write the effects of I into the retur...
void findDbgUsers(SmallVectorImpl< DbgVariableIntrinsic * > &DbgInsts, Value *V)
Finds the debug info intrinsics describing a value.
Value * removeIncomingValue(unsigned Idx, bool DeletePHIIfEmpty=true)
Remove an incoming value.
void dropDebugUsers(Instruction &I)
Remove the debug intrinsic instructions for the given instruction.
bool isAssumeWithEmptyBundle(AssumeInst &Assume)
Return true iff the operand bundles of the provided llvm.assume doesn't contain any valuable informat...
void insertBefore(Instruction *InsertPos)
Insert an unlinked instruction into a basic block immediately before the specified instruction.
void removeBlocks(const SmallSetVector< BasicBlock *, 8 > &DeadBlocks)
Remove all MemoryAcceses in a set of BasicBlocks about to be deleted.
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,...
void replaceVariableLocationOp(Value *OldValue, Value *NewValue)
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
m_Intrinsic_Ty< Opnd0 >::Ty m_BitReverse(const Opnd0 &Op0)
The instances of the Type class are immutable: once they are created, they are never changed.
bool removeUnreachableBlocks(Function &F, DomTreeUpdater *DTU=nullptr, MemorySSAUpdater *MSSAU=nullptr)
Remove all blocks that can not be reached from the function's entry.
SymbolTableList< BasicBlock >::iterator eraseFromParent()
Unlink 'this' from the containing function and delete it.
DILocation * getInlinedAt() const
Align getOrEnforceKnownAlignment(Value *V, MaybeAlign PrefAlign, const DataLayout &DL, const Instruction *CxtI=nullptr, AssumptionCache *AC=nullptr, const DominatorTree *DT=nullptr)
Try to ensure that the alignment of V is at least PrefAlign bytes.
AttributeList getAttributes() const
Return the parameter attributes for this call.
uint64_t getDwarfOpForBinOp(Instruction::BinaryOps Opcode)
FunctionType * getFunctionType() const
value_op_iterator value_op_begin()
static constexpr UpdateKind Insert
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
DILocalVariable * getVariable() const
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
This class implements a map that also provides access to all stored values in a deterministic order.
TinyPtrVector< DbgVariableIntrinsic * > FindDbgAddrUses(Value *V)
Finds all intrinsics declaring local variables as living in the memory that 'V' points to.
void copyMetadata(const Instruction &SrcInst, ArrayRef< unsigned > WL=ArrayRef< unsigned >())
Copy metadata from SrcInst to this instruction.
const BasicBlock * getSinglePredecessor() const
Return the predecessor of this block if it has a single predecessor block.
static CastInst * CreateIntegerCast(Value *S, Type *Ty, bool isSigned, const Twine &Name="", Instruction *InsertBefore=nullptr)
Create a ZExt, BitCast, or Trunc for int -> int casts.
static const unsigned BitPartRecursionMaxDepth
LLVM_NODISCARD T pop_back_val()
Value * getPointerOperand()
ConstantRange getConstantRangeFromMetadata(const MDNode &RangeMD)
Parse out a conservative ConstantRange from !range metadata.
gep_type_iterator gep_type_begin(const User *GEP)
succ_range successors(Instruction *I)
BinaryOp_match< ValTy, cst_pred_ty< is_all_ones >, Instruction::Xor, true > m_Not(const ValTy &V)
Matches a 'Not' as 'xor V, -1' or 'xor -1, V'.
bool succ_empty(const Instruction *I)
static bool isSentinel(const DWARFDebugNames::AttributeEncoding &AE)
std::pair< iterator, bool > insert(const ValueT &V)
std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
void setIncomingValue(unsigned i, Value *V)
auto count_if(R &&Range, UnaryPredicate P)
Wrapper function around std::count_if to count the number of times an element satisfying a given pred...
bool isScalable() const
Returns whether the size is scaled by a runtime quantity (vscale).
void combineMetadataForCSE(Instruction *K, const Instruction *J, bool DoesKMove)
Combine the metadata of two instructions so that K can replace J.
__FakeVCSRevision h endif() endif() set(generated_files "$
static IntegerType * getInt32Ty(LLVMContext &C)
bool isEqual(const GCNRPTracker::LiveRegSet &S1, const GCNRPTracker::LiveRegSet &S2)
Value * getVariableLocationOp(unsigned OpIdx) const
bool empty() const
empty - Check if the array is empty.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
unsigned countPopulation() const
Count the number of bits set.
void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
bool RecursivelyDeleteDeadPHINode(PHINode *PN, const TargetLibraryInfo *TLI=nullptr, MemorySSAUpdater *MSSAU=nullptr)
If the specified value is an effectively dead PHI node, due to being a def-use chain of single-use no...
LLVM Basic Block Representation.
unsigned countMinTrailingZeros() const
Returns the minimum number of trailing zero bits.
unsigned getNumOperands() const
Return number of MDNode operands.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool dominates(const BasicBlock *BB, const Use &U) const
Return true if the (end of the) basic block BB dominates the use U.
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
apint_match m_APInt(const APInt *&Res)
Match a ConstantInt or splatted ConstantVector, binding the specified pointer to the contained APInt.
bool uge(const APInt &RHS) const
Unsigned greater or equal comparison.
This is the shared class of boolean and integer constants.
bool isArrayTy() const
True if this is an instance of ArrayType.
static bool rewriteDebugUsers(Instruction &From, Value &To, Instruction &DomPoint, DominatorTree &DT, function_ref< DbgValReplacement(DbgVariableIntrinsic &DII)> RewriteExpr)
Point debug users of From to To using exprs given by RewriteExpr, possibly moving/undefing users to p...
static bool valueCoversEntireFragment(Type *ValTy, DbgVariableIntrinsic *DII)
Check if the alloc size of ValTy is large enough to cover the variable (or fragment of the variable) ...
void insertAfter(Instruction *InsertPos)
Insert an unlinked instruction into a basic block immediately after the specified instruction.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
static DIExpression * appendOpsToArg(const DIExpression *Expr, ArrayRef< uint64_t > Ops, unsigned ArgNo, bool StackValue=false)
Create a copy of Expr by appending the given list of Ops to each instance of the operand DW_OP_LLVM_a...
const T & back() const
back - Get the last element.
bool SimplifyInstructionsInBlock(BasicBlock *BB, const TargetLibraryInfo *TLI=nullptr)
Scan the specified basic block and try to simplify any instructions in it and recursively delete dead...
bool extractProfTotalWeight(uint64_t &TotalVal) const
Retrieve total raw weight values of a branch.
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 match(Val *V, const Pattern &P)
Value * getIncomingValue(unsigned i) const
Return incoming value number x.
use_iterator_impl< Use > use_iterator
bool isBBPendingDeletion(BasicBlock *DelBB) const
Returns true if DelBB is awaiting deletion.
This represents the llvm.dbg.value instruction.
Optional< DIExpression * > DbgValReplacement
A replacement for a dbg.value expression.
Type * getAllocatedType() const
Return the type that is being allocated by the instruction.
m_Intrinsic_Ty< Opnd0, Opnd1, Opnd2 >::Ty m_FShl(const Opnd0 &Op0, const Opnd1 &Op1, const Opnd2 &Op2)
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
bool isAddressOfVariable() const
Does this describe the address of a local variable.
static bool CanPropagatePredecessorsForPHIs(BasicBlock *BB, BasicBlock *Succ)
Return true if we can fold BB, an almost-empty BB ending in an unconditional branch to Succ,...
(vector float) vec_cmpeq(*A, *B) C
static Constant * getIntToPtr(Constant *C, Type *Ty, bool OnlyIfReduced=false)
static CleanupReturnInst * Create(Value *CleanupPad, BasicBlock *UnwindBB=nullptr, Instruction *InsertBefore=nullptr)
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation.
void setAttributes(AttributeList A)
Set the parameter attributes for this call.
iterator begin()
Instruction iterator methods.
bool canReplaceOperandWithVariable(const Instruction *I, unsigned OpIdx)
Given an instruction, is it legal to set operand OpIdx to a non-constant value?
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
MDNode * createBranchWeights(uint32_t TrueWeight, uint32_t FalseWeight)
Return metadata containing two branch weights.
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
bool isIdenticalToWhenDefined(const Instruction *I) const
This is like isIdenticalTo, except that it ignores the SubclassOptionalData flags,...
static Constant * getPtrToInt(Constant *C, Type *Ty, bool OnlyIfReduced=false)
void recalculate(Function &F)
Notify DTU that the entry block was replaced.
bool isVectorTy() const
True if this is an instance of VectorType.
iterator_range< use_iterator > uses()
const_iterator getFirstInsertionPt() const
Returns an iterator to the first instruction in this block that is suitable for inserting a non-PHI i...
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
CastClass_match< OpTy, Instruction::ZExt > m_ZExt(const OpTy &Op)
Matches ZExt.
bool inferAttributesFromOthers(Function &F)
If we can infer one attribute from another on the declaration of a function, explicitly materialize t...
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
into llvm powi allowing the code generator to produce balanced multiplication trees First
void setExpression(DIExpression *NewExpr)
std::pair< unsigned, unsigned > removeAllNonTerminatorAndEHPadInstructions(BasicBlock *BB)
Remove all instructions from a basic block other than its terminator and any present EH pad instructi...
Value * getIncomingValueForBlock(const BasicBlock *BB) const
bool getLibFunc(StringRef funcName, LibFunc &F) const
Searches for a particular function name.
BinaryOps getOpcode() const
bool isTokenTy() const
Return true if this is 'token'.
static unsigned replaceDominatedUsesWith(Value *From, Value *To, const RootType &Root, const DominatesFn &Dominates)
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
static bool bitTransformIsCorrectForBSwap(unsigned From, unsigned To, unsigned BitWidth)
unsigned getOpcode() const
Return the opcode for this Instruction or ConstantExpr.
Value * SimplifyInstruction(Instruction *I, const SimplifyQuery &Q, OptimizationRemarkEmitter *ORE=nullptr)
See if we can compute a simplified version of this instruction.
static bool isStructure(AllocaInst *AI)
Determine whether this alloca is a structure.
uint64_t getZExtValue() const
Get zero extended value.
STATISTIC(NumFunctions, "Total number of functions")
void copyRangeMetadata(const DataLayout &DL, const LoadInst &OldLI, MDNode *N, LoadInst &NewLI)
Copy a range metadata node to a new load instruction.
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
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.
User * getUser() const
Returns the User that contains this Use.
const Instruction * getFirstNonPHI() const
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
static bool bitTransformIsCorrectForBitReverse(unsigned From, unsigned To, unsigned BitWidth)
This struct is a compact representation of a valid (non-zero power of two) alignment.
CallingConv::ID getCallingConv() const
bool empty() const
Determine if the SetVector is empty or not.
unsigned getNumIncomingValues() const
Return the number of incoming edges.
unsigned getNumVariableLocationOps() const
bool hasDomTree() const
Returns true if it holds a DominatorTree.
bool isAllOnesValue() const
Determine if all bits are set.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
static DIExpression * append(const DIExpression *Expr, ArrayRef< uint64_t > Ops)
Append the opcodes Ops to DIExpr.
bool isIntegerTy() const
True if this is an instance of IntegerType.
An efficient, type-erasing, non-owning reference to a callable.
const MDOperand & getOperand(unsigned I) const
bool isMathLibCallNoop(const CallBase *Call, const TargetLibraryInfo *TLI)
Check whether the given call has no side-effects.
Implements a dense probed hash-table based set.
bool wouldInstructionBeTriviallyDead(Instruction *I, const TargetLibraryInfo *TLI=nullptr)
Return true if the result produced by the instruction would have no side effects if it was not used.
void copyNonnullMetadata(const LoadInst &OldLI, MDNode *N, LoadInst &NewLI)
Copy a nonnull metadata node to a new load instruction.
void copyMetadataForLoad(LoadInst &Dest, const LoadInst &Source)
Copy the metadata from the source instruction to the destination (the replacement for the source inst...
bool hasAddressTaken() const
Returns true if there are any uses of this basic block other than direct branches,...
void removeUnwindEdge(BasicBlock *BB, DomTreeUpdater *DTU=nullptr)
Replace 'BB's terminator with one that does not have an unwind successor block.
This is the common base class for debug info intrinsics for variables.
bool TryToSimplifyUncondBranchFromEmptyBlock(BasicBlock *BB, DomTreeUpdater *DTU=nullptr)
BB is known to contain an unconditional branch, and contains no instructions other than PHI nodes,...
is_zero m_Zero()
Match any null constant or a vector with all elements equal to 0.
An instruction for storing to memory.
This is an important base class in LLVM.
static MDNode * intersect(MDNode *A, MDNode *B)
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
iterator find(const KeyT &Key)
This represents the llvm.dbg.declare instruction.
auto find(R &&Range, const T &Val)
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly.
void changeToUnreachable(const Instruction *I)
Instruction I will be changed to an unreachable.
This represents the llvm.dbg.label instruction.
bool isIntOrPtrTy() const
Return true if this is an integer type or a pointer type.
bool getSalvageOpsForGEP(GetElementPtrInst *GEP, const DataLayout &DL, SmallVectorImpl< uint64_t > &Opcodes)
bool canSimplifyInvokeNoUnwind(const Function *F)
static ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
unsigned changeToUnreachable(Instruction *I, bool UseLLVMTrap, bool PreserveLCSSA=false, DomTreeUpdater *DTU=nullptr, MemorySSAUpdater *MSSAU=nullptr)
Insert an unreachable instruction before the specified instruction, making it and the rest of the cod...
void addIncoming(Value *V, BasicBlock *BB)
Add an incoming value to the end of the PHI list.
BinaryOp_match< LHS, RHS, Instruction::Or > m_Or(const LHS &L, const RHS &R)
bool isIdenticalTo(const Instruction *I) const
Return true if the specified instruction is exactly identical to the current one.
void moveAfter(Instruction *MovePos)
Unlink this instruction from its current basic block and insert it into the basic block that MovePos ...
static BranchInst * Create(BasicBlock *IfTrue, Instruction *InsertBefore=nullptr)
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...
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
initializer< Ty > init(const Ty &Val)
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
BinaryOp_match< LHS, RHS, Instruction::And > m_And(const LHS &L, const RHS &R)
void insertDebugValuesForPHIs(BasicBlock *BB, SmallVectorImpl< PHINode * > &InsertedPHIs)
Propagate dbg.value intrinsics through the newly inserted PHIs.
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.
void findDbgValues(SmallVectorImpl< DbgValueInst * > &DbgValues, Value *V)
Finds the llvm.dbg.value intrinsics describing a value.
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
static MDNode * getMostGenericTBAA(MDNode *A, MDNode *B)
void hoistAllInstructionsInto(BasicBlock *DomBlock, Instruction *InsertPt, BasicBlock *BB)
Hoist all of the instructions in the IfBlock to the dominant block DomBlock, by moving its instructio...
iterator find(const_arg_type_t< KeyT > Val)
void computeKnownBits(const Value *V, KnownBits &Known, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, OptimizationRemarkEmitter *ORE=nullptr, bool UseInstrInfo=true)
Determine which bits of V are known to be either zero or one and return them in the KnownZero/KnownOn...
static MDNode * getMostGenericAlignmentOrDereferenceable(MDNode *A, MDNode *B)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static cl::opt< unsigned > PHICSENumPHISmallSize("phicse-num-phi-smallsize", cl::init(32), cl::Hidden, cl::desc("When the basic block contains not more than this number of PHI nodes, " "perform a (faster!) exhaustive search instead of set-driven one."))
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
void salvageDebugInfoForDbgValues(Instruction &I, ArrayRef< DbgVariableIntrinsic * > Insns)
Implementation of salvageDebugInfo, applying only to instructions in Insns, rather than all debug use...
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
static bool isKnownGE(const LinearPolySize &LHS, const LinearPolySize &RHS)
bool has(LibFunc F) const
Tests whether a library function is available.
print Print MemDeps of function
A Module instance is used to store all the information related to an LLVM module.
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.
bool replaceAllDbgUsesWith(Instruction &From, Value &To, Instruction &DomPoint, DominatorTree &DT)
Point debug users of From to To or salvage them.
BasicBlock * changeToInvokeAndSplitBasicBlock(CallInst *CI, BasicBlock *UnwindEdge, DomTreeUpdater *DTU=nullptr)
Convert the CallInst to InvokeInst with the specified unwind edge basic block.
block_iterator block_begin()
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
Optional< DIBasicType::Signedness > getSignedness() const
Return the signedness of this variable's type, or None if this type is neither signed nor unsigned.
class_match< Value > m_Value()
Match an arbitrary value and ignore it.
Class for arbitrary precision integers.
bool insert(const value_type &X)
Insert a new element into the SetVector.
MDNode * intersectAccessGroups(const Instruction *Inst1, const Instruction *Inst2)
Compute the access-group list of access groups that Inst1 and Inst2 are both in.
The address of a basic block.
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 has no side ef...
Scope
Defines the scope in which this symbol should be visible: Default – Visible in the public interface o...
static APInt getAllOnesValue(unsigned numBits)
Get the all-ones value.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Expected< ExpressionValue > min(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
void moveAfter(BasicBlock *MovePos)
Unlink this basic block from its current function and insert it right after MovePos in the function M...
SmallVector< MachineOperand, 4 > Cond
auto m_Undef()
Match an arbitrary undef constant.
A cache of @llvm.assume calls within a function.
#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 replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
static const Function * getParent(const Value *V)
bool getSalvageOpsForBinOp(BinaryOperator *BI, SmallVectorImpl< uint64_t > &Opcodes)
LLVMContext & getContext() const
All values hold a context through their type.
static MDNode * getMostGenericAliasScope(MDNode *A, MDNode *B)
static bool PhiHasDebugValue(DILocalVariable *DIVar, DIExpression *DIExpr, PHINode *APN)
===------------------------------------------------------------------—===// Dbg Intrinsic utilities
bool isArrayAllocation() const
Return true if there is an allocation size parameter to the allocation instruction that is not 1.
self_iterator getIterator()
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
bool recognizeBSwapOrBitReverseIdiom(Instruction *I, bool MatchBSwaps, bool MatchBitReversals, SmallVectorImpl< Instruction * > &InsertedInsts)
Try to match a bswap or bitreverse idiom.
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
static bool isEqualImpl(SimpleValue LHS, SimpleValue RHS)
Optional< uint64_t > getFragmentSizeInBits() const
Get the size (in bits) of the variable, or fragment of the variable that is described.
void maybeMarkSanitizerLibraryCallNoBuiltin(CallInst *CI, const TargetLibraryInfo *TLI)
Given a CallInst, check if it calls a string function known to CodeGen, and mark it with NoBuiltin if...
std::pair< NoneType, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
StringRef getName() const
Return a constant reference to the value's name.
this could be done in SelectionDAGISel along with other special for
An instruction for reading from memory.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
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...
static bool isBitCastSemanticsPreserving(const DataLayout &DL, Type *FromTy, Type *ToTy)
Check if a bitcast between a value of type FromTy to type ToTy would losslessly preserve the bits and...
static bool isArray(AllocaInst *AI)
Determine whether this alloca is either a VLA or an array.
void clearBit(unsigned BitPosition)
Set a given bit to 0.
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
void replaceDbgValueForAlloca(AllocaInst *AI, Value *NewAllocaAddress, DIBuilder &Builder, int Offset=0)
Replaces multiple llvm.dbg.value instructions when the alloca it describes is replaced with a new val...
static const Optional< BitPart > & collectBitParts(Value *V, bool MatchBSwaps, bool MatchBitReversals, std::map< Value *, Optional< BitPart >> &BPS, int Depth)
Analyze the specified subexpression and see if it is capable of providing pieces of a bswap or bitrev...
block_iterator block_end()
amdgpu Simplify well known AMD library false FunctionCallee Callee
LLVMContext & getContext() const
Get the context in which this basic block lives.
bool EliminateDuplicatePHINodes(BasicBlock *BB)
Check for and eliminate duplicate PHI nodes in this block.
value_op_iterator value_op_end()
static void appendOffset(SmallVectorImpl< uint64_t > &Ops, int64_t Offset)
Append Ops with operations to apply the Offset.
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...
void dropUnknownNonDebugMetadata(ArrayRef< unsigned > KnownIDs)
Drop all unknown metadata except for debug locations.
static DIExpression * appendExt(const DIExpression *Expr, unsigned FromSize, unsigned ToSize, bool Signed)
Append a zero- or sign-extension to Expr.
static IntegerType * getIntNTy(LLVMContext &C, unsigned N)
user_iterator_impl< User > user_iterator
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...
static bool CanMergeValues(Value *First, Value *Second)
Return true if we can choose one of these values to use in place of the other.
static Constant * getAdd(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
@ Undef
Value of the register doesn't matter.
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
Interval::pred_iterator pred_end(Interval *I)
static const unsigned MaxAlignmentExponent
The maximum alignment for instructions.
static bool markAliveBlocks(Function &F, SmallPtrSetImpl< BasicBlock * > &Reachable, DomTreeUpdater *DTU=nullptr)
constexpr unsigned BitWidth
m_Intrinsic_Ty< Opnd0 >::Ty m_BSwap(const Opnd0 &Op0)
size_type count(const key_type &key) const
Count the number of elements of a given key in the SetVector.
void salvageDebugInfo(Instruction &I)
Assuming the instruction I is going to be deleted, attempt to salvage debug users of I by writing the...
Provides information about what library functions are available for the current target.
iterator find(const KeyT &Val)
bool isEHPad() const
Return true if the instruction is a variety of EH-block.
bool contains(const APInt &Val) const
Return true if the specified value is in the set.
static ExtOps getExtOps(unsigned FromSize, unsigned ToSize, bool Signed)
Returns the ops for a zero- or sign-extension in a DIExpression.
Value * getCalledOperand() const
bool LowerDbgDeclare(Function &F)
Lowers llvm.dbg.declare intrinsics into appropriate set of llvm.dbg.value intrinsics.
bool replaceDbgUsesWithUndef(Instruction *I)
Replace all the uses of an SSA value in @llvm.dbg intrinsics with undef.
static bool EliminateDuplicatePHINodesSetBasedImpl(BasicBlock *BB)
A wrapper class for inspecting calls to intrinsic functions.
BinOpPred_match< LHS, RHS, is_logical_shift_op > m_LogicalShift(const LHS &L, const RHS &R)
Matches logical shift operations.
unsigned getIntrinsicID(const MachineInstr &MI)
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 InstListType & getInstList() const
Return the underlying instruction list container.
static MDNode * getMostGenericRange(MDNode *A, MDNode *B)
bool isStructTy() const
True if this is an instance of StructType.
specificval_ty m_Specific(const Value *V)
Match if we have a specific specified value.
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
static MDNode * getMostGenericFPMath(MDNode *A, MDNode *B)
MDNode * createRange(const APInt &Lo, const APInt &Hi)
Return metadata describing the range [Lo, Hi).
LLVM_NODISCARD bool empty() const
void changeToCall(InvokeInst *II, DomTreeUpdater *DTU=nullptr)
This function converts the specified invoek into a normall call.
Value handle that asserts if the Value is deleted.
hash_code hash_combine_range(InputIteratorT first, InputIteratorT last)
Compute a hash_code for a sequence of values.
iterator_range< location_op_iterator > location_ops() const
Get the locations corresponding to the variable referenced by the debug info intrinsic.
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.
size_t size() const
size - Get the array size.
Align max(MaybeAlign Lhs, Align Rhs)
iv Induction Variable Users
bool RemoveRedundantDbgInstrs(BasicBlock *BB, bool RemovePseudoOp=false)
Try to remove redundant dbg.value instructions from given basic block.
void removePredecessor(BasicBlock *Pred, bool KeepOneInputPHIs=false)
Update PHI nodes in this BasicBlock before removal of predecessor Pred.
void addAttribute(unsigned i, Attribute::AttrKind Kind)
adds the attribute to the list of attributes.
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 templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
A SetVector that performs no allocations if smaller than a certain size.
This class represents a function call, abstracting a target machine's calling convention.
static bool EliminateDuplicatePHINodesNaiveImpl(BasicBlock *BB)
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.
bool hasOptimizedCodeGen(LibFunc F) const
Tests if the function is both available and a candidate for optimized code generation.
CallInst * createCallMatchingInvoke(InvokeInst *II)
Create a call that matches the invoke II in terms of arguments, attributes, debug information,...
void patchReplacementInstruction(Instruction *I, Value *Repl)
Patch the replacement so that it is not more restrictive than the value being replaced.
unsigned getBitWidth() const
Get the bit width of this value.
void MergeBasicBlockIntoOnlyPred(BasicBlock *BB, DomTreeUpdater *DTU=nullptr)
BB is a block with one predecessor and its predecessor is known to have one successor (BB!...
BlockVerifier::State From
void takeName(Value *V)
Transfer the name from V to this value.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
an instruction to allocate memory on the stack
MDNode * getScope() const
Value * getOperand(unsigned i) const
static bool simplifyAndDCEInstruction(Instruction *I, SmallSetVector< Instruction *, 16 > &WorkList, const DataLayout &DL, const TargetLibraryInfo *TLI)
Conditional or Unconditional Branch instruction.
CastClass_match< OpTy, Instruction::Trunc > m_Trunc(const OpTy &Op)
Matches Trunc.
bool NullPointerIsDefined(const Function *F, unsigned AS=0)
Check whether null pointer dereferencing is considered undefined behavior for a given function or an ...
bool contains(ConstPtrType Ptr) const
void reserve(size_type N)
static BinaryOperator * Create(BinaryOps Op, Value *S1, Value *S2, const Twine &Name=Twine(), Instruction *InsertBefore=nullptr)
Construct a binary instruction, given the opcode and the two operands.
bool replaceDbgDeclare(Value *Address, Value *NewAddress, DIBuilder &Builder, uint8_t DIExprFlags, int Offset)
Replaces llvm.dbg.declare instruction when the address it describes is replaced with a new value.
BasicBlock * SplitBlock(BasicBlock *Old, Instruction *SplitPt, DominatorTree *DT, LoopInfo *LI=nullptr, MemorySSAUpdater *MSSAU=nullptr, const Twine &BBName="", bool Before=false)
Split the specified block at the specified instruction.
BasicBlock * getUnwindDest() const
void applyUpdatesPermissive(ArrayRef< DominatorTree::UpdateType > Updates)
Submit updates to all available trees.
LLVM_NODISCARD T pop_back_val()
bool RecursivelyDeleteTriviallyDeadInstructionsPermissive(SmallVectorImpl< WeakTrackingVH > &DeadInsts, const TargetLibraryInfo *TLI=nullptr, MemorySSAUpdater *MSSAU=nullptr, std::function< void(Value *)> AboutToDeleteCallback=std::function< void(Value *)>())
Same functionality as RecursivelyDeleteTriviallyDeadInstructions, but allow instructions that are not...
LLVM Value Representation.
static VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
iterator_range< user_iterator > users()
static cl::opt< bool > PHICSEDebugHash("phicse-debug-hash", cl::init(false), cl::Hidden, cl::desc("Perform extra assertion checking to verify that PHINodes's hash " "function is well-behaved w.r.t. its isEqual predicate"))
static DebugLoc getDebugValueLoc(DbgVariableIntrinsic *DII, Instruction *Src)
Produce a DebugLoc to use for each dbg.declare/inst pair that are promoted to a dbg....
void destroyConstant()
Called if some element of this constant is no longer valid.
iterator_range< User::op_iterator > args()
Iteration adapter for range-for loops.
const CallInst * isFreeCall(const Value *I, const TargetLibraryInfo *TLI)
isFreeCall - Returns non-null if the value is a call to the builtin free()
void removeMemoryAccess(MemoryAccess *, bool OptimizePhis=false)
Remove a MemoryAccess from MemorySSA, including updating all definitions and uses.
static constexpr UpdateKind Delete
void setCallingConv(CallingConv::ID CC)
A Use represents the edge between a Value definition and its users.
TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.