diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp index c22cf5f81ee5ac..37c71e245c5b69 100644 --- a/llvm/lib/CodeGen/CodeGenPrepare.cpp +++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp @@ -268,7 +268,7 @@ class TypePromotionTransaction; const TargetMachine *TM = nullptr; const TargetSubtargetInfo *SubtargetInfo; const TargetLowering *TLI = nullptr; - const TargetRegisterInfo *TRI; + const TargetRegisterInfo *TRI = nullptr; const TargetTransformInfo *TTI = nullptr; const TargetLibraryInfo *TLInfo; const LoopInfo *LI; @@ -786,7 +786,7 @@ bool CodeGenPrepare::isMergingEmptyBlockProfitable(BasicBlock *BB, BlockFrequency PredFreq = BFI->getBlockFreq(Pred); BlockFrequency BBFreq = BFI->getBlockFreq(BB); - for (auto SameValueBB : SameIncomingValueBBs) + for (auto *SameValueBB : SameIncomingValueBBs) if (SameValueBB->getUniquePredecessor() == Pred && DestBB == findDestBlockOfMergeableEmptyBlock(SameValueBB)) BBFreq += BFI->getBlockFreq(SameValueBB); @@ -962,7 +962,7 @@ static bool getGEPSmallConstantIntOffsetV(GetElementPtrInst *GEP, SmallVectorImpl &OffsetV) { for (unsigned i = 1; i < GEP->getNumOperands(); i++) { // Only accept small constant integer operands - auto Op = dyn_cast(GEP->getOperand(i)); + auto *Op = dyn_cast(GEP->getOperand(i)); if (!Op || Op->getZExtValue() > 20) return false; } @@ -986,7 +986,7 @@ simplifyRelocatesOffABase(GCRelocateInst *RelocatedBase, // be skipped by optimization and we do not care about them. for (auto R = RelocatedBase->getParent()->getFirstInsertionPt(); &*R != RelocatedBase; ++R) - if (auto RI = dyn_cast(R)) + if (auto *RI = dyn_cast(R)) if (RI->getStatepoint() == RelocatedBase->getStatepoint()) if (RI->getBasePtrIndex() == RelocatedBase->getBasePtrIndex()) { RelocatedBase->moveBefore(RI); @@ -1010,7 +1010,7 @@ simplifyRelocatesOffABase(GCRelocateInst *RelocatedBase, } Value *Base = ToReplace->getBasePtr(); - auto Derived = dyn_cast(ToReplace->getDerivedPtr()); + auto *Derived = dyn_cast(ToReplace->getDerivedPtr()); if (!Derived || Derived->getPointerOperand() != Base) continue; @@ -2074,8 +2074,8 @@ bool CodeGenPrepare::optimizeCallInst(CallInst *CI, bool &ModifiedDT) { Type *ScalableVectorTy = VectorType::get(Type::getInt8Ty(II->getContext()), 1, true); if (DL->getTypeAllocSize(ScalableVectorTy).getKnownMinSize() == 8) { - auto Null = Constant::getNullValue(ScalableVectorTy->getPointerTo()); - auto One = ConstantInt::getSigned(II->getType(), 1); + auto *Null = Constant::getNullValue(ScalableVectorTy->getPointerTo()); + auto *One = ConstantInt::getSigned(II->getType(), 1); auto *CGep = ConstantExpr::getGetElementPtr(ScalableVectorTy, Null, One); II->replaceAllUsesWith(ConstantExpr::getPtrToInt(CGep, II->getType())); @@ -3205,7 +3205,7 @@ class SimplificationTracker { SmallPtrSet Visited; WorkList.push_back(Val); while (!WorkList.empty()) { - auto P = WorkList.pop_back_val(); + auto *P = WorkList.pop_back_val(); if (!Visited.insert(P).second) continue; if (auto *PI = dyn_cast(P)) @@ -3254,13 +3254,13 @@ class SimplificationTracker { void destroyNewNodes(Type *CommonType) { // For safe erasing, replace the uses with dummy value first. - auto Dummy = UndefValue::get(CommonType); - for (auto I : AllPhiNodes) { + auto *Dummy = UndefValue::get(CommonType); + for (auto *I : AllPhiNodes) { I->replaceAllUsesWith(Dummy); I->eraseFromParent(); } AllPhiNodes.clear(); - for (auto I : AllSelectNodes) { + for (auto *I : AllSelectNodes) { I->replaceAllUsesWith(Dummy); I->eraseFromParent(); } @@ -3601,7 +3601,7 @@ class AddressingModeCombiner { // Must be a Phi node then. auto *PHI = cast(V); // Fill the Phi node with values from predecessors. - for (auto B : predecessors(PHI->getParent())) { + for (auto *B : predecessors(PHI->getParent())) { Value *PV = cast(Current)->getIncomingValueForBlock(B); assert(Map.find(PV) != Map.end() && "No predecessor Value!"); PHI->addIncoming(ST.Get(Map[PV]), B); @@ -3940,7 +3940,7 @@ bool TypePromotionHelper::canGetThrough(const Instruction *Inst, // We can get through binary operator, if it is legal. In other words, the // binary operator must have a nuw or nsw flag. const BinaryOperator *BinOp = dyn_cast(Inst); - if (BinOp && isa(BinOp) && + if (isa_and_nonnull(BinOp) && ((!IsSExt && BinOp->hasNoUnsignedWrap()) || (IsSExt && BinOp->hasNoSignedWrap()))) return true; @@ -5438,7 +5438,7 @@ bool CodeGenPrepare::tryToPromoteExts( bool Promoted = false; // Iterate over all the extensions to try to promote them. - for (auto I : Exts) { + for (auto *I : Exts) { // Early check if we directly have ext(load). if (isa(I->getOperand(0))) { ProfitablyMovedExts.push_back(I); @@ -5499,7 +5499,7 @@ bool CodeGenPrepare::tryToPromoteExts( SmallVector NewlyMovedExts; (void)tryToPromoteExts(TPT, NewExts, NewlyMovedExts, TotalCreatedInstsCost); bool NewPromoted = false; - for (auto ExtInst : NewlyMovedExts) { + for (auto *ExtInst : NewlyMovedExts) { Instruction *MovedExt = cast(ExtInst); Value *ExtOperand = MovedExt->getOperand(0); // If we have reached to a load, we need this extra profitability check @@ -5628,7 +5628,7 @@ bool CodeGenPrepare::splitLargeGEPOffsets() { int64_t BaseOffset = LargeOffsetGEPs.begin()->second; Value *NewBaseGEP = nullptr; - auto LargeOffsetGEP = LargeOffsetGEPs.begin(); + auto *LargeOffsetGEP = LargeOffsetGEPs.begin(); while (LargeOffsetGEP != LargeOffsetGEPs.end()) { GetElementPtrInst *GEP = LargeOffsetGEP->first; int64_t Offset = LargeOffsetGEP->second; @@ -5835,7 +5835,7 @@ bool CodeGenPrepare::performAddressTypePromotion( bool Promoted = false; SmallPtrSet UnhandledExts; bool AllSeenFirst = true; - for (auto I : SpeculativelyMovedExts) { + for (auto *I : SpeculativelyMovedExts) { Value *HeadOfChain = I->getOperand(0); DenseMap::iterator AlreadySeen = SeenChainsForSExt.find(HeadOfChain); @@ -5853,7 +5853,7 @@ bool CodeGenPrepare::performAddressTypePromotion( TPT.commit(); if (HasPromoted) Promoted = true; - for (auto I : SpeculativelyMovedExts) { + for (auto *I : SpeculativelyMovedExts) { Value *HeadOfChain = I->getOperand(0); SeenChainsForSExt[HeadOfChain] = nullptr; ValToSExtendedUses[HeadOfChain].push_back(I); @@ -5864,7 +5864,7 @@ bool CodeGenPrepare::performAddressTypePromotion( // This is the first chain visited from the header, keep the current chain // as unhandled. Defer to promote this until we encounter another SExt // chain derived from the same header. - for (auto I : SpeculativelyMovedExts) { + for (auto *I : SpeculativelyMovedExts) { Value *HeadOfChain = I->getOperand(0); SeenChainsForSExt[HeadOfChain] = Inst; } @@ -5872,7 +5872,7 @@ bool CodeGenPrepare::performAddressTypePromotion( } if (!AllSeenFirst && !UnhandledExts.empty()) - for (auto VisitedSExt : UnhandledExts) { + for (auto *VisitedSExt : UnhandledExts) { if (RemovedInsts.count(VisitedSExt)) continue; TypePromotionTransaction TPT(RemovedInsts); @@ -5883,7 +5883,7 @@ bool CodeGenPrepare::performAddressTypePromotion( TPT.commit(); if (HasPromoted) Promoted = true; - for (auto I : Chains) { + for (auto *I : Chains) { Value *HeadOfChain = I->getOperand(0); // Mark this as handled. SeenChainsForSExt[HeadOfChain] = nullptr; @@ -6429,7 +6429,7 @@ bool CodeGenPrepare::optimizeSelectInst(SelectInst *SI) { FT = FalseBlock; } IRBuilder<> IB(SI); - auto CondFr = IB.CreateFreeze(SI->getCondition(), SI->getName() + ".frozen"); + auto *CondFr = IB.CreateFreeze(SI->getCondition(), SI->getName() + ".frozen"); IB.CreateCondBr(CondFr, TT, FT, SI); SmallPtrSet INS; @@ -7627,7 +7627,7 @@ bool CodeGenPrepare::splitBranchCondition(Function &F, bool &ModifiedDT) { LLVM_DEBUG(dbgs() << "Before branch condition splitting\n"; BB.dump()); // Create a new BB. - auto TmpBB = + auto *TmpBB = BasicBlock::Create(BB.getContext(), BB.getName() + ".cond.split", BB.getParent(), BB.getNextNode());