79 #define DEBUG_TYPE "licm" 81 STATISTIC(NumCreatedBlocks,
"Number of blocks created");
82 STATISTIC(NumClonedBranches,
"Number of branches cloned");
83 STATISTIC(NumSunk,
"Number of instructions sunk out of loop");
84 STATISTIC(NumHoisted,
"Number of instructions hoisted out of loop");
85 STATISTIC(NumMovedLoads,
"Number of load insts hoisted or sunk");
86 STATISTIC(NumMovedCalls,
"Number of call insts hoisted or sunk");
87 STATISTIC(NumPromoted,
"Number of memory locations promoted to registers");
92 cl::desc(
"Disable memory promotion in LICM pass"));
96 cl::desc(
"Enable control flow (and PHI) hoisting in LICM"));
100 cl::desc(
"Max num uses visited for identifying load " 101 "invariance in loop using invariant start (default = 8)"));
108 cl::desc(
"How many instruction to cross product using AA"));
119 cl::desc(
"Enable imprecision in LICM (uses MemorySSA cap) in " 120 "pathological cases, in exchange for faster compile"));
155 struct LoopInvariantCodeMotion {
162 ASTrackerMapTy &getLoopToAliasSetMap() {
return LoopToAliasSetMap; }
165 ASTrackerMapTy LoopToAliasSetMap;
167 std::unique_ptr<AliasSetTracker>
171 struct LegacyLICMPass :
public LoopPass {
182 LICM.getLoopToAliasSetMap().clear();
186 auto *SE = getAnalysisIfAvailable<ScalarEvolutionWrapperPass>();
188 ? (&getAnalysis<MemorySSAWrapperPass>().getMSSA())
194 return LICM.runOnLoop(L,
195 &getAnalysis<AAResultsWrapperPass>().getAAResults(),
196 &getAnalysis<LoopInfoWrapperPass>().getLoopInfo(),
197 &getAnalysis<DominatorTreeWrapperPass>().getDomTree(),
198 &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(),
199 &getAnalysis<TargetTransformInfoWrapperPass>().getTTI(
201 SE ? &SE->getSE() :
nullptr, MSSA, &ORE,
false);
221 bool doFinalization()
override {
223 "Didn't free loop alias sets");
228 LoopInvariantCodeMotion
LICM;
236 void deleteAnalysisValue(
Value *V,
Loop *L)
override;
239 void deleteAnalysisLoop(
Loop *L)
override;
247 Function *
F = L.getHeader()->getParent();
253 "cached at a higher level");
255 LoopInvariantCodeMotion
LICM;
256 if (!LICM.runOnLoop(&L, &AR.
AA, &AR.
LI, &AR.
DT, &AR.
TLI, &AR.
TTI, &AR.
SE,
286 bool LoopInvariantCodeMotion::runOnLoop(
290 bool Changed =
false;
294 std::unique_ptr<AliasSetTracker> CurAST;
295 std::unique_ptr<MemorySSAUpdater> MSSAU;
298 CurAST = collectAliasInfoForLoop(L, LI, AA);
300 LLVM_DEBUG(
dbgs() <<
"LICM: Using MemorySSA. Promotion disabled.\n");
301 MSSAU = make_unique<MemorySSAUpdater>(MSSA);
323 CurAST.get(), MSSAU.get(), &SafetyInfo, ORE);
326 CurAST.get(), MSSAU.get(), &SafetyInfo, ORE);
345 if (!HasCatchSwitch) {
349 InsertPts.
push_back(&*ExitBlock->getFirstInsertionPt());
353 bool Promoted =
false;
361 if (AS.isForwardingAliasSet() || !AS.isMod() || !AS.isMustAlias() ||
367 "Must alias set should have at least one pointer element in it!");
370 for (
const auto &ASI : AS)
371 PointerMustAliases.
insert(ASI.getValue());
374 PointerMustAliases, ExitBlocks, InsertPts, PIC, LI, DT, TLI, L,
375 CurAST.get(), &SafetyInfo, ORE);
398 "Parent loop not left in LCSSA form after LICM!");
403 LoopToAliasSetMap[L] = std::move(CurAST);
406 MSSAU->getMemorySSA()->verifyMemorySSA();
426 assert(N !=
nullptr && AA !=
nullptr && LI !=
nullptr && DT !=
nullptr &&
427 CurLoop !=
nullptr && SafetyInfo !=
nullptr &&
428 "Unexpected input to sinkRegion.");
429 assert(((CurAST !=
nullptr) ^ (MSSAU !=
nullptr)) &&
430 "Either AliasSetTracker or MemorySSA should be initialized.");
437 bool Changed =
false;
464 bool FreeInLoop =
false;
468 if (
sink(I, LI, DT, CurLoop, SafetyInfo, MSSAU, ORE, FreeInLoop)) {
491 class ControlFlowHoister {
510 : LI(LI), DT(DT), CurLoop(CurLoop), MSSAU(MSSAU) {}
512 void registerPossiblyHoistableBranch(
BranchInst *BI) {
524 TrueDest == FalseDest)
536 if (TrueDestSucc.
count(FalseDest)) {
537 CommonSucc = FalseDest;
538 }
else if (FalseDestSucc.
count(TrueDest)) {
539 CommonSucc = TrueDest;
543 if (TrueDestSucc.
size() == 1)
544 CommonSucc = *TrueDestSucc.
begin();
548 else if (!TrueDestSucc.
empty()) {
552 assert(It != F->
end() &&
"Could not find successor in function");
564 if (CommonSucc && DT->
dominates(BI, CommonSucc))
565 HoistableBranches[BI] = CommonSucc;
568 bool canHoistPHI(
PHINode *PN) {
577 PredecessorBlocks.
insert(PredBB);
585 for (
auto &Pair : HoistableBranches) {
586 if (Pair.second == BB) {
589 if (Pair.first->getSuccessor(0) == BB) {
590 PredecessorBlocks.
erase(Pair.first->getParent());
591 PredecessorBlocks.
erase(Pair.first->getSuccessor(1));
592 }
else if (Pair.first->getSuccessor(1) == BB) {
593 PredecessorBlocks.
erase(Pair.first->getParent());
594 PredecessorBlocks.
erase(Pair.first->getSuccessor(0));
596 PredecessorBlocks.
erase(Pair.first->getSuccessor(0));
597 PredecessorBlocks.
erase(Pair.first->getSuccessor(1));
603 return PredecessorBlocks.
empty();
610 if (HoistDestinationMap.
count(BB))
611 return HoistDestinationMap[BB];
614 auto HasBBAsSuccessor =
616 return BB != Pair.second && (Pair.first->getSuccessor(0) == BB ||
617 Pair.first->getSuccessor(1) == BB);
624 if (It == HoistableBranches.
end()) {
626 <<
" as hoist destination for " << BB->
getName()
628 HoistDestinationMap[BB] = InitialPreheader;
629 return InitialPreheader;
633 HoistableBranches.
end() &&
634 "BB is expected to be the target of at most one branch");
639 BasicBlock *CommonSucc = HoistableBranches[BI];
643 auto CreateHoistedBlock = [&](
BasicBlock *Orig) {
644 if (HoistDestinationMap.
count(Orig))
645 return HoistDestinationMap[Orig];
648 HoistDestinationMap[Orig] = New;
654 <<
" as hoist destination for " << Orig->getName()
658 BasicBlock *HoistTrueDest = CreateHoistedBlock(TrueDest);
659 BasicBlock *HoistFalseDest = CreateHoistedBlock(FalseDest);
660 BasicBlock *HoistCommonSucc = CreateHoistedBlock(CommonSucc);
667 assert(TargetSucc &&
"Expected hoist target to have a single successor");
682 if (HoistTarget == InitialPreheader) {
684 InitialPreheader->replaceSuccessorsPhiUsesWith(HoistCommonSucc);
694 for (
auto &Pair : HoistDestinationMap)
695 if (Pair.second == InitialPreheader && Pair.first != BI->
getParent())
696 Pair.second = HoistCommonSucc;
706 "Hoisting blocks should not have destroyed preheader");
707 return HoistDestinationMap[BB];
723 assert(N !=
nullptr && AA !=
nullptr && LI !=
nullptr && DT !=
nullptr &&
724 CurLoop !=
nullptr && SafetyInfo !=
nullptr &&
725 "Unexpected input to hoistRegion.");
726 assert(((CurAST !=
nullptr) ^ (MSSAU !=
nullptr)) &&
727 "Either AliasSetTracker or MemorySSA should be initialized.");
729 ControlFlowHoister CFH(LI, DT, CurLoop, MSSAU);
740 bool Changed =
false;
775 I, DT, CurLoop, SafetyInfo, ORE,
777 hoist(I, DT, CurLoop, CFH.getOrCreateHoistedBlock(BB), SafetyInfo,
786 if (I.
getOpcode() == Instruction::FDiv &&
791 auto ReciprocalDivisor = BinaryOperator::CreateFDiv(One, Divisor);
794 ReciprocalDivisor->insertBefore(&I);
797 BinaryOperator::CreateFMul(I.
getOperand(0), ReciprocalDivisor);
800 Product->insertAfter(&I);
804 hoist(*ReciprocalDivisor, DT, CurLoop, CFH.getOrCreateHoistedBlock(BB),
805 SafetyInfo, MSSAU, ORE);
806 HoistedInstructions.
push_back(ReciprocalDivisor);
813 match(&I, m_Intrinsic<Intrinsic::invariant_start>())) ||
818 hoist(I, DT, CurLoop, CFH.getOrCreateHoistedBlock(BB), SafetyInfo,
825 if (
PHINode *PN = dyn_cast<PHINode>(&I)) {
826 if (CFH.canHoistPHI(PN)) {
829 for (
unsigned int i = 0; i < PN->getNumIncomingValues(); ++i)
830 PN->setIncomingBlock(
831 i, CFH.getOrCreateHoistedBlock(PN->getIncomingBlock(i)));
832 hoist(*PN, DT, CurLoop, CFH.getOrCreateHoistedBlock(BB), SafetyInfo,
842 if (
BranchInst *BI = dyn_cast<BranchInst>(&I))
843 CFH.registerPossiblyHoistableBranch(BI);
864 "New hoist point expected to dominate old hoist point");
869 <<
": " << *
I <<
"\n");
884 "Dominator tree verification failed");
901 cast<PointerType>(Addr->
getType())->getElementType());
907 unsigned BitcastsVisited = 0;
910 while (Addr->
getType() != PtrInt8Ty) {
915 Addr = BC->getOperand(0);
918 unsigned UsesVisited = 0;
921 for (
auto *U : Addr->
users()) {
931 unsigned InvariantSizeInBits =
937 if (LocSizeInBits <= InvariantSizeInBits &&
951 return (isa<LoadInst>(I) || isa<StoreInst>(I) ||
952 isa<CallInst>(I) || isa<FenceInst>(I) ||
953 isa<BinaryOperator>(I) || isa<CastInst>(I) ||
954 isa<SelectInst>(I) || isa<GetElementPtrInst>(I) ||
955 isa<CmpInst>(I) || isa<InsertElementInst>(I) ||
956 isa<ExtractElementInst>(I) || isa<ShuffleVectorInst>(I) ||
957 isa<ExtractValueInst>(I) || isa<InsertValueInst>(I));
965 if (!AS.isForwardingAliasSet() && AS.isMod()) {
984 for (
const auto &Acc : *Accs) {
985 if (isa<MemoryPhi>(&Acc))
987 const auto *MUD = cast<MemoryUseOrDef>(&Acc);
988 if (MUD->getMemoryInst() != I || NotAPhi++ == 1)
999 bool TargetExecutesOncePerLoop,
1002 if (!isHoistableAndSinkableInst(I))
1008 if (
LoadInst *LI = dyn_cast<LoadInst>(&I)) {
1009 if (!LI->isUnordered())
1019 if (LI->isAtomic() && !TargetExecutesOncePerLoop)
1035 if (ORE && Invalidated && CurLoop->
isLoopInvariant(LI->getPointerOperand()))
1038 DEBUG_TYPE,
"LoadWithLoopInvariantAddressInvalidated", LI)
1039 <<
"failed to move load with loop-invariant address " 1040 "because the loop may invalidate its value";
1043 return !Invalidated;
1044 }
else if (
CallInst *CI = dyn_cast<CallInst>(&I)) {
1046 if (isa<DbgInfoIntrinsic>(I))
1054 if (
match(CI, m_Intrinsic<Intrinsic::assume>()))
1068 for (
Value *
Op : CI->arg_operands())
1069 if (
Op->getType()->isPointerTy()) {
1074 CurAST, CurLoop, AA);
1086 if (isReadOnly(CurAST, MSSAU, CurLoop))
1094 }
else if (
auto *FI = dyn_cast<FenceInst>(&I)) {
1098 auto Begin = CurAST->
begin();
1099 assert(Begin != CurAST->
end() &&
"must contain FI");
1100 if (std::next(Begin) != CurAST->
end())
1103 auto *UniqueI = Begin->getUniqueInstruction();
1108 assert(UniqueI == FI &&
"AS must contain FI");
1111 return isOnlyMemoryAccess(FI, CurLoop, MSSAU);
1112 }
else if (
auto *
SI = dyn_cast<StoreInst>(&I)) {
1113 if (!
SI->isUnordered())
1124 if (AS.isRef() || !AS.isMustAlias())
1131 assert(UniqueI ==
SI &&
"AS must contain SI");
1134 if (isOnlyMemoryAccess(
SI, CurLoop, MSSAU))
1177 for (
const User *U :
GEP->users()) {
1181 (!isa<StoreInst>(UI) && !isa<LoadInst>(UI))))
1202 if (
const PHINode *PN = dyn_cast<PHINode>(UI)) {
1210 if (isa<CallInst>(I))
1211 if (!BlockColors.empty() &&
1212 BlockColors.find(const_cast<BasicBlock *>(BB))->second.size() != 1)
1231 if (
auto *CI = dyn_cast<CallInst>(&I)) {
1238 for (
unsigned BundleIdx = 0, BundleEnd = CI->getNumOperandBundles();
1239 BundleIdx != BundleEnd; ++BundleIdx) {
1247 if (!BlockColors.empty()) {
1248 const ColorVector &CV = BlockColors.find(&ExitBlock)->second;
1249 assert(CV.
size() == 1 &&
"non-unique color for exit block!");
1271 if (
auto *MemDef = dyn_cast<MemoryDef>(NewMemAcc))
1274 auto *MemUse = cast<MemoryUse>(NewMemAcc);
1289 if (
Instruction *OInst = dyn_cast<Instruction>(*OI))
1291 if (!OLoop->contains(&PN)) {
1294 OInst->getName() +
".lcssa", &ExitBlock.
front());
1325 "Expect only trivially replaceable PHI");
1328 auto It = SunkCopies.
find(ExitBlock);
1329 if (It != SunkCopies.
end())
1333 *I, *ExitBlock, *TPN, LI, SafetyInfo, MSSAU);
1366 assert(ExitBlockSet.count(ExitBB) &&
"Expect the PHI is in an exit block.");
1402 while (!PredBBs.
empty()) {
1405 "Expect all predecessors are in the loop");
1408 ExitBB, PredBB,
".split.loop.exit", DT, LI, MSSAU,
true);
1412 if (!BlockColors.empty())
1434 <<
"sinking " <<
ore::NV(
"Inst", &I);
1436 bool Changed =
false;
1437 if (isa<LoadInst>(I))
1439 else if (isa<CallInst>(I))
1447 auto *
User = cast<Instruction>(*UI);
1448 Use &U = UI.getUse();
1490 if (VisitedUsers.
empty())
1507 for (
auto *UI :
Users) {
1508 auto *
User = cast<Instruction>(UI);
1515 "The LCSSA PHI is not in an exit block!");
1518 PN, &I, LI, SunkCopies, SafetyInfo, CurLoop, MSSAU);
1550 if (isa<PHINode>(I))
1569 if (!isa<CallInst>(I))
1572 if (isa<LoadInst>(I))
1574 else if (isa<CallInst>(I))
1584 const Loop *CurLoop,
1591 bool GuaranteedToExecute =
1594 if (!GuaranteedToExecute) {
1599 DEBUG_TYPE,
"LoadWithLoopInvariantAddressCondExecuted", LI)
1600 <<
"failed to hoist load with loop-invariant address " 1601 "because load is conditionally executed";
1605 return GuaranteedToExecute;
1619 bool UnorderedAtomic;
1630 I->getName() +
".lcssa", &BB->
front());
1644 bool UnorderedAtomic,
const AAMDNodes &AATags,
1647 LoopExitBlocks(LEB), LoopInsertPts(LIP), PredCache(PIC), AST(ast),
1648 LI(li), DL(std::move(dl)), Alignment(alignment),
1649 UnorderedAtomic(UnorderedAtomic), AATags(AATags), SafetyInfo(SafetyInfo)
1655 if (
LoadInst *LI = dyn_cast<LoadInst>(I))
1656 Ptr = LI->getOperand(0);
1659 return PointerMustAliases.
count(Ptr);
1662 void doExtraRewritesBeforeFinalDeletion()
const override {
1667 for (
unsigned i = 0, e = LoopExitBlocks.
size(); i != e; ++i) {
1669 Value *LiveInValue =
SSA.GetValueInMiddleOfBlock(ExitBlock);
1670 LiveInValue = maybeInsertLCSSAPHI(LiveInValue, ExitBlock);
1671 Value *Ptr = maybeInsertLCSSAPHI(SomePtr, ExitBlock);
1674 if (UnorderedAtomic)
1683 void replaceLoadWithValue(
LoadInst *LI,
Value *V)
const override {
1687 void instructionDeleted(
Instruction *I)
const override {
1697 if (isa<AllocaInst>(Object))
1731 assert(LI !=
nullptr && DT !=
nullptr && CurLoop !=
nullptr &&
1732 CurAST !=
nullptr && SafetyInfo !=
nullptr &&
1733 "Unexpected Input to promoteLoopAccessesToScalars");
1735 Value *SomePtr = *PointerMustAliases.
begin();
1775 bool DereferenceableInPH =
false;
1776 bool SafeToInsertStore =
false;
1782 unsigned Alignment = 1;
1784 bool SawUnorderedAtomic =
false;
1785 bool SawNotAtomic =
false;
1790 bool IsKnownThreadLocalObject =
false;
1798 if (!isKnownNonEscaping(Object, TLI))
1802 IsKnownThreadLocalObject = !isa<AllocaInst>(Object);
1808 for (
Value *ASIV : PointerMustAliases) {
1812 if (SomePtr->
getType() != ASIV->getType())
1824 if (!
Load->isUnordered())
1827 SawUnorderedAtomic |=
Load->isAtomic();
1828 SawNotAtomic |= !
Load->isAtomic();
1830 if (!DereferenceableInPH)
1838 if (!
Store->isUnordered())
1841 SawUnorderedAtomic |=
Store->isAtomic();
1842 SawNotAtomic |= !
Store->isAtomic();
1849 unsigned InstAlignment =
Store->getAlignment();
1854 if (!DereferenceableInPH || !SafeToInsertStore ||
1855 (InstAlignment > Alignment)) {
1857 DereferenceableInPH =
true;
1858 SafeToInsertStore =
true;
1859 Alignment =
std::max(Alignment, InstAlignment);
1869 if (!SafeToInsertStore)
1876 if (!DereferenceableInPH) {
1878 Store->getPointerOperand(),
Store->getAlignment(), MDL,
1885 if (LoopUses.
empty()) {
1888 }
else if (AATags) {
1900 if (SawUnorderedAtomic && SawNotAtomic)
1904 if (!DereferenceableInPH)
1911 if (!SafeToInsertStore) {
1912 if (IsKnownThreadLocalObject)
1913 SafeToInsertStore =
true;
1923 if (!SafeToInsertStore)
1927 LLVM_DEBUG(
dbgs() <<
"LICM: Promoting value stored to in loop: " << *SomePtr
1932 <<
"Moving accesses to memory location out of the loop";
1940 DebugLoc DL = LoopUses[0]->getDebugLoc();
1945 LoopPromoter Promoter(SomePtr, LoopUses, SSA, PointerMustAliases, ExitBlocks,
1946 InsertPts, PIC, *CurAST, *LI, DL, Alignment,
1947 SawUnorderedAtomic, AATags, *SafetyInfo);
1953 if (SawUnorderedAtomic)
1963 Promoter.run(LoopUses);
1978 std::unique_ptr<AliasSetTracker>
1979 LoopInvariantCodeMotion::collectAliasInfoForLoop(
Loop *L,
LoopInfo *LI,
1981 std::unique_ptr<AliasSetTracker> CurAST;
1984 auto MapI = LoopToAliasSetMap.find(InnerL);
1988 if (MapI == LoopToAliasSetMap.end()) {
1992 std::unique_ptr<AliasSetTracker> InnerAST = std::move(MapI->second);
1998 CurAST->add(*InnerAST);
2000 CurAST = std::move(InnerAST);
2002 LoopToAliasSetMap.erase(MapI);
2005 CurAST = make_unique<AliasSetTracker>(*AA);
2008 for (
Loop *InnerL : RecomputeLoops)
2024 auto ASTIt =
LICM.getLoopToAliasSetMap().find(L);
2025 if (ASTIt ==
LICM.getLoopToAliasSetMap().
end())
2028 ASTIt->second->copyValue(From, To);
2033 void LegacyLICMPass::deleteAnalysisValue(
Value *V,
Loop *L) {
2034 auto ASTIt =
LICM.getLoopToAliasSetMap().find(L);
2035 if (ASTIt ==
LICM.getLoopToAliasSetMap().
end())
2038 ASTIt->second->deleteValue(V);
2043 void LegacyLICMPass::deleteAnalysisLoop(
Loop *L) {
2044 if (!
LICM.getLoopToAliasSetMap().count(L))
2047 LICM.getLoopToAliasSetMap().erase(L);
2057 return isInvalidatedAccordingToAST;
2074 if (CurLoop->
begin() != CurLoop->
end())
2082 << *(MemLoc.
Ptr) <<
"\n");
2089 << *(MemLoc.
Ptr) <<
"\n");
2113 assert(CurLoop->
contains(BB) &&
"Only valid if BB is IN the loop");
Pass interface - Implemented by all 'passes'.
static void eraseInstruction(Instruction &I, ICFLoopSafetyInfo &SafetyInfo, AliasSetTracker *AST, MemorySSAUpdater *MSSAU)
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
bool canSplitPredecessors() const
void insertInstructionTo(const Instruction *Inst, const BasicBlock *BB)
Inform the safety info that we are planning to insert a new instruction Inst into the basic block BB...
A parsed version of the target data layout string in and methods for querying it. ...
void ReplaceInstWithInst(BasicBlock::InstListType &BIL, BasicBlock::iterator &BI, Instruction *I)
Replace the instruction specified by BI with the instruction specified by I.
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
static bool isTriviallyReplaceablePHI(const PHINode &PN, const Instruction &I)
Returns true if a PHINode is a trivially replaceable with an Instruction.
Helper class for SSA formation on a set of values defined in multiple blocks.
void addIncoming(Value *V, BasicBlock *BB)
Add an incoming value to the end of the PHI list.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Value * getPointerOperand(Value *V)
A helper function that returns the pointer operand of a load, store or GEP instruction.
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
PreservedAnalyses getLoopPassPreservedAnalyses()
Returns the minimum set of Analyses that all loop passes must preserve.
DiagnosticInfoOptimizationBase::Argument NV
bool VerifyMemorySSA
Enables verification of MemorySSA.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
This class represents lattice values for constants.
This header provides classes for managing a pipeline of passes over loops in LLVM IR...
MemoryAccess * getDefiningAccess() const
Get the access that produces the memory state used by this Use.
This is the interface for a simple mod/ref and alias analysis over globals.
const_iterator end() const
bool hasMetadataOtherThanDebugLoc() const
Return true if this instruction has metadata attached to it other than a debug location.
void dropUnknownNonDebugMetadata(ArrayRef< unsigned > KnownIDs)
Drop all unknown metadata except for debug locations.
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
static constexpr LocationSize unknown()
bool hasDedicatedExits() const
Return true if no exit block for the loop has a predecessor that is outside the loop.
bool isLCSSAForm(DominatorTree &DT) const
Return true if the Loop is in LCSSA form.
void push_back(const T &Elt)
const AccessList * getBlockAccesses(const BasicBlock *BB) const
Return the list of MemoryAccess's for a given basic block.
void AddAvailableValue(BasicBlock *BB, Value *V)
Indicate that a rewritten value is available in the specified block with the specified value...
The main scalar evolution driver.
static void splitPredecessorsOfLoopExit(PHINode *PN, DominatorTree *DT, LoopInfo *LI, const Loop *CurLoop, LoopSafetyInfo *SafetyInfo, MemorySSAUpdater *MSSAU)
This class represents a function call, abstracting a target machine's calling convention.
void setOrdering(AtomicOrdering Ordering)
Sets the ordering constraint of this load instruction.
BlockT * getLoopPreheader() const
If there is a preheader for this loop, return it.
static PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space...
bool salvageDebugInfo(Instruction &I)
Assuming the instruction I is going to be deleted, attempt to salvage debug users of I by writing the...
LLVMContext & getContext() const
All values hold a context through their type.
void insertUse(MemoryUse *Use)
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly...
BasicBlock * getSuccessor(unsigned i) const
bool properlyDominates(const DomTreeNodeBase< NodeT > *A, const DomTreeNodeBase< NodeT > *B) const
properlyDominates - Returns true iff A dominates B and A != B.
static bool isFreeInLoop(const Instruction &I, const Loop *CurLoop, const TargetTransformInfo *TTI)
Return true if the instruction is free in the loop.
STATISTIC(NumFunctions, "Total number of functions")
The adaptor from a function pass to a loop pass computes these analyses and makes them available to t...
Analysis pass which computes a DominatorTree.
An instruction for reading from memory.
Value * getCondition() const
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...
iv Induction Variable Users
void reserve(size_type N)
TinyPtrVector - This class is specialized for cases where there are normally 0 or 1 element in a vect...
LLVMContext & getContext() const
Get the context in which this basic block lives.
bool isReachableFromEntry(const Use &U) const
Provide an overload for a Use.
bool hasLoopInvariantOperands(const Instruction *I) const
Return true if all the operands of the specified instruction are loop invariant.
void verify(const DominatorTreeBase< BlockT, false > &DomTree) const
static bool pointerInvalidatedByLoop(MemoryLocation MemLoc, AliasSetTracker *CurAST, Loop *CurLoop, AliasAnalysis *AA)
iterator begin()
Instruction iterator methods.
Loop Invariant Code Motion
Value * getArgOperand(unsigned i) const
bool formLCSSARecursively(Loop &L, DominatorTree &DT, LoopInfo *LI, ScalarEvolution *SE)
Put a loop nest into LCSSA form.
Represents read-only accesses to memory.
bool match(Val *V, const Pattern &P)
AnalysisUsage & addRequired()
const Module * getModule() const
Return the module owning the function this basic block belongs to, or nullptr if the function does no...
ArrayRef< BasicBlock * > get(BasicBlock *BB)
#define INITIALIZE_PASS_DEPENDENCY(depName)
Legacy analysis pass which computes MemorySSA.
virtual void computeLoopSafetyInfo(const Loop *CurLoop)
Computes safety information for a loop checks loop body & header for the possibility of may throw exc...
This is the interface for a SCEV-based alias analysis.
MemorySSA * getMemorySSA() const
Get handle on MemorySSA.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
bool verify(VerificationLevel VL=VerificationLevel::Full) const
verify - checks if the tree is correct.
int getBasicBlockIndex(const BasicBlock *BB) const
Return the first index of the specified basic block in the value list for this PHI.
LoopT * getLoopFor(const BlockT *BB) const
Return the inner most loop that BB lives in.
This implementation of LoopSafetyInfo use ImplicitControlFlowTracking to give precise answers on "may...
bool hasAllowReciprocal() const
Determine whether the allow-reciprocal flag is set.
A Use represents the edge between a Value definition and its users.
virtual bool doFinalization(Module &)
doFinalization - Virtual method overriden by subclasses to do any necessary clean up after all passes...
Encapsulates MemorySSA, including all data associated with memory accesses.
static bool pointerInvalidatedByLoopWithMSSA(MemorySSA *MSSA, MemoryUse *MU, Loop *CurLoop)
uint32_t getTagID() const
Return the tag of this operand bundle as an integer.
const DefsList * getBlockDefs(const BasicBlock *BB) const
Return the list of MemoryDef's and MemoryPhi's for a given basic block.
void setName(const Twine &Name)
Change the name of the value.
Analysis pass that exposes the LoopInfo for a function.
bool remove(const value_type &X)
Remove an item from the set vector.
virtual bool anyBlockMayThrow() const
Returns true iff any block of the loop for which this info is contains an instruction that may throw ...
BlockT * getHeader() const
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...
FunctionModRefBehavior getModRefBehavior(const CallBase *Call)
Return the behavior of the given call site.
auto reverse(ContainerTy &&C, typename std::enable_if< has_rbegin< ContainerTy >::value >::type *=nullptr) -> decltype(make_range(C.rbegin(), C.rend()))
INITIALIZE_PASS_BEGIN(LegacyLICMPass, "licm", "Loop Invariant Code Motion", false, false) INITIALIZE_PASS_END(LegacyLICMPass
Instruction * clone() const
Create a copy of 'this' instruction that is identical in all ways except the following: ...
void removeMemoryAccess(MemoryAccess *)
Remove a MemoryAccess from MemorySSA, including updating all definitions and uses.
Fast - This calling convention attempts to make calls as fast as possible (e.g.
FastMathFlags getFastMathFlags() const
Convenience function for getting all the fast-math flags, which must be an operator which supports th...
Type * getType() const
All values are typed, get the type of this value.
bool insert(const value_type &X)
Insert a new element into the SetVector.
MemoryUseOrDef * getMemoryAccess(const Instruction *I) const
Given a memory Mod/Ref'ing instruction, get the MemorySSA access associated with it.
void addBasicBlockToLoop(BlockT *NewBB, LoopInfoBase< BlockT, LoopT > &LI)
This method is used by other analyses to update loop information.
PredIteratorCache - This class is an extremely trivial cache for predecessor iterator queries...
FunctionModRefBehavior
Summary of how a function affects memory in the program.
const BasicBlock * getSingleSuccessor() const
Return the successor of this block if it has a single successor.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
Instruction * getUniqueInstruction()
If this alias set is known to contain a single instruction and only a single unique instruction...
iterator begin()
Get an iterator to the beginning of the SetVector.
This class represents a no-op cast from one type to another.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
An instruction for storing to memory.
static cl::opt< bool > DisablePromotion("disable-licm-promotion", cl::Hidden, cl::init(false), cl::desc("Disable memory promotion in LICM pass"))
Memory promotion is enabled by default.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
void copyColors(BasicBlock *New, BasicBlock *Old)
Copy colors of block Old into the block New.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
Value * getOperand(unsigned i) const
size_type count(const key_type &key) const
Count the number of elements of a given key in the SetVector.
void forgetLoopDispositions(const Loop *L)
Called when the client has changed the disposition of values in this loop.
Interval::succ_iterator succ_end(Interval *I)
iterator find(const_arg_type_t< KeyT > Val)
bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal=false)
Checks whether the given location points to constant memory, or if OrLocal is true whether it points ...
an instruction for type-safe pointer arithmetic to access elements of arrays and structs ...
void getAAMetadata(AAMDNodes &N, bool Merge=false) const
Fills the AAMDNodes structure with AA metadata from this instruction.
static Instruction * sinkThroughTriviallyReplaceablePHI(PHINode *TPN, Instruction *I, LoopInfo *LI, SmallDenseMap< BasicBlock *, Instruction *, 32 > &SunkCopies, const LoopSafetyInfo *SafetyInfo, const Loop *CurLoop, MemorySSAUpdater *MSSAU)
static MemoryLocation get(const LoadInst *LI)
Return a location with information about the memory reference by the given instruction.
BasicBlock * SplitBlockPredecessors(BasicBlock *BB, ArrayRef< BasicBlock *> Preds, const char *Suffix, DominatorTree *DT=nullptr, LoopInfo *LI=nullptr, MemorySSAUpdater *MSSAU=nullptr, bool PreserveLCSSA=false)
This method introduces at least one new basic block into the function and moves some of the predecess...
initializer< Ty > init(const Ty &Val)
virtual bool isGuaranteedToExecute(const Instruction &Inst, const DominatorTree *DT, const Loop *CurLoop) const
Returns true if the instruction in a loop is guaranteed to execute at least once (under the assumptio...
static cl::opt< int > LICMN2Theshold("licm-n2-threshold", cl::Hidden, cl::init(0), cl::desc("How many instruction to cross product using AA"))
const Instruction * getFirstNonPHI() const
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
A set of analyses that are preserved following a run of a transformation pass.
const_iterator getFirstInsertionPt() const
Returns an iterator to the first instruction in this block that is suitable for inserting a non-PHI i...
virtual bool isGuaranteedToExecute(const Instruction &Inst, const DominatorTree *DT, const Loop *CurLoop) const =0
Returns true if the instruction in a loop is guaranteed to execute at least once (under the assumptio...
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
MemorySSAWalker * getSkipSelfWalker()
void set_intersect(S1Ty &S1, const S2Ty &S2)
set_intersect(A, B) - Compute A := A ^ B Identical to set_intersection, except that it works on set<>...
void setAAMetadata(const AAMDNodes &N)
Sets the metadata on this instruction from the AAMDNodes structure.
LLVM Basic Block Representation.
This is an important class for using LLVM in a threaded context.
static cl::opt< bool > EnableLicmCap("enable-licm-cap", cl::init(false), cl::Hidden, cl::desc("Enable imprecision in LICM (uses MemorySSA cap) in " "pathological cases, in exchange for faster compile"))
Conditional or Unconditional Branch instruction.
size_t size(BasicBlock *BB) const
void changeImmediateDominator(DomTreeNodeBase< NodeT > *N, DomTreeNodeBase< NodeT > *NewIDom)
changeImmediateDominator - This method is used to update the dominator tree information when a node's...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
LLVM_NODISCARD bool empty() const
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
This file contains the declarations for the subclasses of Constant, which represent the different fla...
const Instruction & front() const
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
bool mayHaveSideEffects() const
Return true if the instruction may have side effects.
Constant * ConstantFoldInstruction(Instruction *I, const DataLayout &DL, const TargetLibraryInfo *TLI=nullptr)
ConstantFoldInstruction - Try to constant fold the specified instruction.
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...
Represent the analysis usage information of a pass.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly...
PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM, LoopStandardAnalysisResults &AR, LPMUpdater &U)
bool canSinkOrHoistInst(Instruction &I, AAResults *AA, DominatorTree *DT, Loop *CurLoop, AliasSetTracker *CurAST, MemorySSAUpdater *MSSAU, bool TargetExecutesOncePerLoop, OptimizationRemarkEmitter *ORE=nullptr)
Returns true if is legal to hoist or sink this instruction disregarding the possible introduction of ...
AliasSet & getAliasSetFor(const MemoryLocation &MemLoc)
Return the alias set which contains the specified memory location.
Interval::pred_iterator pred_end(Interval *I)
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
static bool canSplitPredecessors(PHINode *PN, LoopSafetyInfo *SafetyInfo)
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
auto find_if(R &&Range, UnaryPredicate P) -> decltype(adl_begin(Range))
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly...
void setAlignment(unsigned Align)
bool onlyReadsMemory(const CallBase *Call)
Checks if the specified call is known to only read from non-volatile memory (or not access memory at ...
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
MemoryAccess * createMemoryAccessInBB(Instruction *I, MemoryAccess *Definition, const BasicBlock *BB, MemorySSA::InsertionPlace Point)
Create a MemoryAccess in MemorySSA at a specified point in a block, with a specified clobbering defin...
bool sinkRegion(DomTreeNode *, AliasAnalysis *, LoopInfo *, DominatorTree *, TargetLibraryInfo *, TargetTransformInfo *, Loop *, AliasSetTracker *, MemorySSAUpdater *, ICFLoopSafetyInfo *, OptimizationRemarkEmitter *ORE)
Walk the specified region of the CFG (defined by all blocks dominated by the specified block...
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
static bool isLoadInvariantInLoop(LoadInst *LI, DominatorTree *DT, Loop *CurLoop)
DomTreeNodeBase< NodeT > * getNode(const NodeT *BB) const
getNode - return the (Post)DominatorTree node for the specified basic block.
Value * GetUnderlyingObject(Value *V, const DataLayout &DL, unsigned MaxLookup=6)
This method strips off any GEP address adjustments and pointer casts from the specified value...
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
This function does not perform any non-local loads or stores to memory.
void moveToPlace(MemoryUseOrDef *What, BasicBlock *BB, MemorySSA::InsertionPlace Where)
bool isLoopInvariant(const Value *V) const
Return true if the specified value is loop invariant.
TargetTransformInfo & TTI
static cl::opt< uint32_t > MaxNumUsesTraversed("licm-max-num-uses-traversed", cl::Hidden, cl::init(8), cl::desc("Max num uses visited for identifying load " "invariance in loop using invariant start (default = 8)"))
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of this intrinsic.
const Value * Ptr
The address of the start of the location.
Representation for a specific memory location.
This class provides an interface for updating the loop pass manager based on mutations to the loop ne...
const InstListType & getInstList() const
Return the underlying instruction list container.
bool contains(const LoopT *L) const
Return true if the specified loop is contained within in this loop.
A SetVector that performs no allocations if smaller than a certain size.
static void hoist(Instruction &I, const DominatorTree *DT, const Loop *CurLoop, BasicBlock *Dest, ICFLoopSafetyInfo *SafetyInfo, MemorySSAUpdater *MSSAU, OptimizationRemarkEmitter *ORE)
When an instruction is found to only use loop invariant operands that is safe to hoist, this instruction is called to do the dirty work.
Iterator for intrusive lists based on ilist_node.
void removeInstruction(const Instruction *Inst)
Inform safety info that we are planning to remove the instruction Inst from its block.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
bool doesNotWriteMemoryBefore(const BasicBlock *BB, const Loop *CurLoop) const
Returns true if we could not execute a memory-modifying instruction before we enter BB under assumpti...
BlockVerifier::State From
static cl::opt< bool > ControlFlowHoisting("licm-control-flow-hoisting", cl::Hidden, cl::init(false), cl::desc("Enable control flow (and PHI) hoisting in LICM"))
void verifyMemorySSA() const
Verify that MemorySSA is self consistent (IE definitions dominate all uses, uses appear in the right ...
bool erase(PtrType Ptr)
erase - If the set contains the specified pointer, remove it and return true, otherwise return false...
An analysis over an "inner" IR unit that provides access to an analysis manager over a "outer" IR uni...
void copyValue(Value *From, Value *To)
This method should be used whenever a preexisting value in the program is copied or cloned...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
bool dominates(const Instruction *Def, const Use &U) const
Return true if Def dominates a use in User.
Provides information about what library functions are available for the current target.
unsigned getABITypeAlignment(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
void wireOldPredecessorsToNewImmediatePredecessor(BasicBlock *Old, BasicBlock *New, ArrayRef< BasicBlock *> Preds, bool IdenticalEdgesWereMerged=true)
A new empty BasicBlock (New) now branches directly to Old.
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
BasicBlock * getBlock() const
static BranchInst * Create(BasicBlock *IfTrue, Instruction *InsertBefore=nullptr)
bool isConditional() const
static bool isNotUsedOrFreeInLoop(const Instruction &I, const Loop *CurLoop, const LoopSafetyInfo *SafetyInfo, TargetTransformInfo *TTI, bool &FreeInLoop)
Return true if the only users of this instruction are outside of the loop.
static PHINode * Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructors - NumReservedValues is a hint for the number of incoming edges that this phi node will h...
pred_range predecessors(BasicBlock *BB)
static Constant * get(Type *Ty, double V)
This returns a ConstantFP, or a vector containing a splat of a ConstantFP, for the specified value in...
unsigned getNumIncomingValues() const
Return the number of incoming edges.
static bool sink(Instruction &I, LoopInfo *LI, DominatorTree *DT, const Loop *CurLoop, ICFLoopSafetyInfo *SafetyInfo, MemorySSAUpdater *MSSAU, OptimizationRemarkEmitter *ORE, bool FreeInLoop)
When an instruction is found to only be used outside of the loop, this function moves it to the exit ...
bool isGuard(const User *U)
Returns true iff U has semantics of a guard.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
Class that has the common methods + fields of memory uses/defs.
A lightweight accessor for an operand bundle meant to be passed around by value.
iterator_range< user_iterator > users()
static bool isSafeToExecuteUnconditionally(Instruction &Inst, const DominatorTree *DT, const Loop *CurLoop, const LoopSafetyInfo *SafetyInfo, OptimizationRemarkEmitter *ORE, const Instruction *CtxI=nullptr)
Only sink or hoist an instruction if it is not a trapping instruction, or if the instruction is known...
uint64_t getTypeSizeInBits(Type *Ty) const
Size examples:
LoopT * getParentLoop() const
const std::vector< LoopT * > & getSubLoops() const
Return the loops contained entirely within this loop.
LLVM_NODISCARD bool isModSet(const ModRefInfo MRI)
void setOrdering(AtomicOrdering Ordering)
Sets the ordering constraint of this store instruction.
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
static bool onlyAccessesArgPointees(FunctionModRefBehavior MRB)
Checks if functions with the specified behavior are known to read and write at most from objects poin...
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
iterator insert(iterator where, pointer New)
void emplace_back(ArgTypes &&... Args)
LLVM_NODISCARD bool empty() const
Represents a single loop in the control flow graph.
ArrayRef< BlockT * > getBlocks() const
Get a list of the basic blocks which make up this loop.
StringRef getName() const
Return a constant reference to the value's name.
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
const Function * getParent() const
Return the enclosing method, or null if none.
unsigned pred_size(const BasicBlock *BB)
Get the number of predecessors of BB.
DomTreeNodeBase< NodeT > * addNewBlock(NodeT *BB, NodeT *DomBB)
Add a new node to the dominator tree information.
bool empty() const
Determine if the SetVector is empty or not.
user_iterator_impl< User > user_iterator
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 getLoopAnalysisUsage(AnalysisUsage &AU)
Helper to consistently add the set of standard passes to a loop pass's AnalysisUsage.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
bool isLiveOnEntryDef(const MemoryAccess *MA) const
Return true if MA represents the live on entry value.
Captures loop safety information.
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
const_iterator begin() const
Wrapper class to LoopBlocksDFS that provides a standard begin()/end() interface for the DFS reverse p...
SmallVector< DomTreeNode *, 16 > collectChildrenInLoop(DomTreeNode *N, const Loop *CurLoop)
Does a BFS from a given node to all of its children inside a given loop.
bool hoistRegion(DomTreeNode *, AliasAnalysis *, LoopInfo *, DominatorTree *, TargetLibraryInfo *, Loop *, AliasSetTracker *, MemorySSAUpdater *, ICFLoopSafetyInfo *, OptimizationRemarkEmitter *ORE)
Walk the specified region of the CFG (defined by all blocks dominated by the specified block...
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
MemoryAccess * getClobberingMemoryAccess(const Instruction *I)
Given a memory Mod/Ref/ModRef'ing instruction, calling this will give you the nearest dominating Memo...
static bool inSubLoop(BasicBlock *BB, Loop *CurLoop, LoopInfo *LI)
Little predicate that returns true if the specified basic block is in a subloop of the current one...
bool promoteLoopAccessesToScalars(const SmallSetVector< Value *, 8 > &, SmallVectorImpl< BasicBlock *> &, SmallVectorImpl< Instruction *> &, PredIteratorCache &, LoopInfo *, DominatorTree *, const TargetLibraryInfo *, Loop *, AliasSetTracker *, ICFLoopSafetyInfo *, OptimizationRemarkEmitter *)
Try to promote memory values to scalars by sinking stores out of the loop and moving loads to before ...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
user_iterator user_begin()
bool isSafeToSpeculativelyExecute(const Value *V, const Instruction *CtxI=nullptr, const DominatorTree *DT=nullptr)
Return true if the instruction does not have any effects besides calculating the result and does not ...
void insertDef(MemoryDef *Def, bool RenameUses=false)
Insert a definition into the MemorySSA IR.
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...
LLVM Value Representation.
void setAlignment(unsigned Align)
void moveBefore(Instruction *MovePos)
Unlink this instruction from its current basic block and insert it into the basic block that MovePos ...
void initializeLegacyLICMPassPass(PassRegistry &)
bool isEHPad() const
Return true if the instruction is a variety of EH-block.
This file exposes an interface to building/using memory SSA to walk memory instructions using a use/d...
The legacy pass manager's analysis pass to compute loop information.
void getUniqueExitBlocks(SmallVectorImpl< BlockT *> &ExitBlocks) const
Return all unique successor blocks of this loop.
This is the interface for LLVM's primary stateless and local alias analysis.
A container for analyses that lazily runs them and caches their results.
static Instruction * CloneInstructionInExitBlock(Instruction &I, BasicBlock &ExitBlock, PHINode &PN, const LoopInfo *LI, const LoopSafetyInfo *SafetyInfo, MemorySSAUpdater *MSSAU)
Legacy analysis pass which computes a DominatorTree.
bool isDereferenceableAndAlignedPointer(const Value *V, unsigned Align, const DataLayout &DL, const Instruction *CtxI=nullptr, const DominatorTree *DT=nullptr)
Returns true if V is always a dereferenceable pointer with alignment greater or equal than requested...
void perform(LoopInfo *LI)
Traverse the loop blocks and store the DFS result.
ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc)
getModRefInfo (for call sites) - Return information about whether a particular call site modifies or ...
op_range incoming_values()
iterator_range< block_iterator > blocks() const
static IntegerType * getInt8Ty(LLVMContext &C)
void moveBefore(BasicBlock *MovePos)
Unlink this basic block from its current function and insert it into the function that MovePos lives ...
static void moveInstructionBefore(Instruction &I, Instruction &Dest, ICFLoopSafetyInfo &SafetyInfo)
void deleteValue(Value *PtrVal)
This method is used to remove a pointer value from the AliasSetTracker entirely.
loop versioning Loop Versioning For LICM
A wrapper class for inspecting calls to intrinsic functions.
const BasicBlock * getParent() const
cl::opt< bool > EnableMSSALoopDependency
Enables memory ssa as a dependency for loop passes.
bool PointerMayBeCaptured(const Value *V, bool ReturnCaptures, bool StoreCaptures, unsigned MaxUsesToExplore=DefaultMaxUsesToExplore)
PointerMayBeCaptured - Return true if this pointer value may be captured by the enclosing function (w...
bool mayReadOrWriteMemory() const
Return true if this instruction may read or write memory.
const DenseMap< BasicBlock *, ColorVector > & getBlockColors() const
Returns block colors map that is used to update funclet operand bundles.