diff --git a/llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h b/llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h --- a/llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h +++ b/llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h @@ -64,10 +64,9 @@ /// This is a wrapper around getUnderlyingObject which also knows how to /// look through objc_retain and objc_autorelease calls, which we know to return /// their argument verbatim. -inline const Value *GetUnderlyingObjCPtr(const Value *V, - const DataLayout &DL) { +inline const Value *GetUnderlyingObjCPtr(const Value *V) { for (;;) { - V = getUnderlyingObject(V, DL); + V = getUnderlyingObject(V); if (!IsForwarding(GetBasicARCInstKind(V))) break; V = cast(V)->getArgOperand(0); @@ -78,12 +77,12 @@ /// A wrapper for GetUnderlyingObjCPtr used for results memoization. inline const Value * -GetUnderlyingObjCPtrCached(const Value *V, const DataLayout &DL, +GetUnderlyingObjCPtrCached(const Value *V, DenseMap &Cache) { if (auto InCache = Cache.lookup(V)) return InCache; - const Value *Computed = GetUnderlyingObjCPtr(V, DL); + const Value *Computed = GetUnderlyingObjCPtr(V); Cache[V] = const_cast(Computed); return Computed; } diff --git a/llvm/include/llvm/Analysis/ValueTracking.h b/llvm/include/llvm/Analysis/ValueTracking.h --- a/llvm/include/llvm/Analysis/ValueTracking.h +++ b/llvm/include/llvm/Analysis/ValueTracking.h @@ -368,11 +368,10 @@ /// that the returned value has pointer type if the specified value does. If /// the MaxLookup value is non-zero, it limits the number of instructions to /// be stripped off. - Value *getUnderlyingObject(Value *V, const DataLayout &DL, - unsigned MaxLookup = 6); - inline const Value *getUnderlyingObject(const Value *V, const DataLayout &DL, + Value *getUnderlyingObject(Value *V, unsigned MaxLookup = 6); + inline const Value *getUnderlyingObject(const Value *V, unsigned MaxLookup = 6) { - return getUnderlyingObject(const_cast(V), DL, MaxLookup); + return getUnderlyingObject(const_cast(V), MaxLookup); } /// This method is similar to getUnderlyingObject except that it can @@ -405,14 +404,12 @@ /// it shouldn't look through the phi above. void getUnderlyingObjects(const Value *V, SmallVectorImpl &Objects, - const DataLayout &DL, LoopInfo *LI = nullptr, - unsigned MaxLookup = 6); + LoopInfo *LI = nullptr, unsigned MaxLookup = 6); /// This is a wrapper around getUnderlyingObjects and adds support for basic /// ptrtoint+arithmetic+inttoptr sequences. bool getUnderlyingObjectsForCodeGen(const Value *V, - SmallVectorImpl &Objects, - const DataLayout &DL); + SmallVectorImpl &Objects); /// Finds alloca where the value comes from. AllocaInst *findAllocaForValue(Value *V); diff --git a/llvm/lib/Analysis/AliasAnalysis.cpp b/llvm/lib/Analysis/AliasAnalysis.cpp --- a/llvm/lib/Analysis/AliasAnalysis.cpp +++ b/llvm/lib/Analysis/AliasAnalysis.cpp @@ -641,8 +641,7 @@ if (!DT) return ModRefInfo::ModRef; - const Value *Object = - getUnderlyingObject(MemLoc.Ptr, I->getModule()->getDataLayout()); + const Value *Object = getUnderlyingObject(MemLoc.Ptr); if (!isIdentifiedObject(Object) || isa(Object) || isa(Object)) return ModRefInfo::ModRef; diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp --- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp +++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp @@ -661,7 +661,7 @@ SmallVector Worklist; Worklist.push_back(Loc.Ptr); do { - const Value *V = getUnderlyingObject(Worklist.pop_back_val(), DL); + const Value *V = getUnderlyingObject(Worklist.pop_back_val()); if (!Visited.insert(V).second) { Visited.clear(); return AAResultBase::pointsToConstantMemory(Loc, AAQI, OrLocal); @@ -875,7 +875,7 @@ assert(notDifferentParent(Call, Loc.Ptr) && "AliasAnalysis query involving multiple functions!"); - const Value *Object = getUnderlyingObject(Loc.Ptr, DL); + const Value *Object = getUnderlyingObject(Loc.Ptr); // Calls marked 'tail' cannot read or write allocas from the current frame // because the current frame might be destroyed by the time they run. However, @@ -1309,7 +1309,7 @@ /// another pointer. /// /// We know that V1 is a GEP, but we don't know anything about V2. -/// UnderlyingV1 is getUnderlyingObject(GEP1, DL), UnderlyingV2 is the same for +/// UnderlyingV1 is getUnderlyingObject(GEP1), UnderlyingV2 is the same for /// V2. AliasResult BasicAAResult::aliasGEP( const GEPOperator *GEP1, LocationSize V1Size, const AAMDNodes &V1AAInfo, @@ -1782,10 +1782,10 @@ // Figure out what objects these things are pointing to if we can. if (O1 == nullptr) - O1 = getUnderlyingObject(V1, DL, MaxLookupSearchDepth); + O1 = getUnderlyingObject(V1, MaxLookupSearchDepth); if (O2 == nullptr) - O2 = getUnderlyingObject(V2, DL, MaxLookupSearchDepth); + O2 = getUnderlyingObject(V2, MaxLookupSearchDepth); // Null values in the default address space don't point to any object, so they // don't alias any other pointer. diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp --- a/llvm/lib/Analysis/ConstantFolding.cpp +++ b/llvm/lib/Analysis/ConstantFolding.cpp @@ -718,7 +718,7 @@ // If this load comes from anywhere in a constant global, and if the global // is all undef or zero, we know what it loads. - if (auto *GV = dyn_cast(getUnderlyingObject(CE, DL))) { + if (auto *GV = dyn_cast(getUnderlyingObject(CE))) { if (GV->isConstant() && GV->hasDefinitiveInitializer()) { if (GV->getInitializer()->isNullValue()) return Constant::getNullValue(Ty); diff --git a/llvm/lib/Analysis/DependenceAnalysis.cpp b/llvm/lib/Analysis/DependenceAnalysis.cpp --- a/llvm/lib/Analysis/DependenceAnalysis.cpp +++ b/llvm/lib/Analysis/DependenceAnalysis.cpp @@ -659,8 +659,8 @@ return NoAlias; // Check the underlying objects are the same - const Value *AObj = getUnderlyingObject(LocA.Ptr, DL); - const Value *BObj = getUnderlyingObject(LocB.Ptr, DL); + const Value *AObj = getUnderlyingObject(LocA.Ptr); + const Value *BObj = getUnderlyingObject(LocB.Ptr); // If the underlying objects are the same, they must alias if (AObj == BObj) diff --git a/llvm/lib/Analysis/GlobalsModRef.cpp b/llvm/lib/Analysis/GlobalsModRef.cpp --- a/llvm/lib/Analysis/GlobalsModRef.cpp +++ b/llvm/lib/Analysis/GlobalsModRef.cpp @@ -435,8 +435,7 @@ continue; // Check the value being stored. - Value *Ptr = getUnderlyingObject(SI->getOperand(0), - GV->getParent()->getDataLayout()); + Value *Ptr = getUnderlyingObject(SI->getOperand(0)); if (!isAllocLikeFn(Ptr, &GetTLI(*SI->getFunction()))) return false; // Too hard to analyze. @@ -661,12 +660,12 @@ return false; if (auto *LI = dyn_cast(Input)) { - Inputs.push_back(getUnderlyingObject(LI->getPointerOperand(), DL)); + Inputs.push_back(getUnderlyingObject(LI->getPointerOperand())); continue; } if (auto *SI = dyn_cast(Input)) { - const Value *LHS = getUnderlyingObject(SI->getTrueValue(), DL); - const Value *RHS = getUnderlyingObject(SI->getFalseValue(), DL); + const Value *LHS = getUnderlyingObject(SI->getTrueValue()); + const Value *RHS = getUnderlyingObject(SI->getFalseValue()); if (Visited.insert(LHS).second) Inputs.push_back(LHS); if (Visited.insert(RHS).second) @@ -675,7 +674,7 @@ } if (auto *PN = dyn_cast(Input)) { for (const Value *Op : PN->incoming_values()) { - Op = getUnderlyingObject(Op, DL); + Op = getUnderlyingObject(Op); if (Visited.insert(Op).second) Inputs.push_back(Op); } @@ -774,7 +773,7 @@ if (auto *LI = dyn_cast(Input)) { // A pointer loaded from a global would have been captured, and we know // that the global is non-escaping, so no alias. - const Value *Ptr = getUnderlyingObject(LI->getPointerOperand(), DL); + const Value *Ptr = getUnderlyingObject(LI->getPointerOperand()); if (isNonEscapingGlobalNoAliasWithLoad(GV, Ptr, Depth, DL)) // The load does not alias with GV. continue; @@ -782,8 +781,8 @@ return false; } if (auto *SI = dyn_cast(Input)) { - const Value *LHS = getUnderlyingObject(SI->getTrueValue(), DL); - const Value *RHS = getUnderlyingObject(SI->getFalseValue(), DL); + const Value *LHS = getUnderlyingObject(SI->getTrueValue()); + const Value *RHS = getUnderlyingObject(SI->getFalseValue()); if (Visited.insert(LHS).second) Inputs.push_back(LHS); if (Visited.insert(RHS).second) @@ -792,7 +791,7 @@ } if (auto *PN = dyn_cast(Input)) { for (const Value *Op : PN->incoming_values()) { - Op = getUnderlyingObject(Op, DL); + Op = getUnderlyingObject(Op); if (Visited.insert(Op).second) Inputs.push_back(Op); } @@ -827,8 +826,8 @@ const MemoryLocation &LocB, AAQueryInfo &AAQI) { // Get the base object these pointers point to. - const Value *UV1 = getUnderlyingObject(LocA.Ptr, DL); - const Value *UV2 = getUnderlyingObject(LocB.Ptr, DL); + const Value *UV1 = getUnderlyingObject(LocA.Ptr); + const Value *UV2 = getUnderlyingObject(LocB.Ptr); // If either of the underlying values is a global, they may be non-addr-taken // globals, which we can answer queries about. @@ -915,7 +914,7 @@ // is based on GV, return the conservative result. for (auto &A : Call->args()) { SmallVector Objects; - getUnderlyingObjects(A, Objects, DL); + getUnderlyingObjects(A, Objects); // All objects must be identified. if (!all_of(Objects, isIdentifiedObject) && @@ -942,7 +941,7 @@ // If we are asking for mod/ref info of a direct call with a pointer to a // global we are tracking, return information if we have it. if (const GlobalValue *GV = - dyn_cast(getUnderlyingObject(Loc.Ptr, DL))) + dyn_cast(getUnderlyingObject(Loc.Ptr))) // If GV is internal to this IR and there is no function with local linkage // that has had their address taken, keep looking for a tighter ModRefInfo. if (GV->hasLocalLinkage() && !UnknownFunctionsWithLocalLinkage) diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -2524,8 +2524,8 @@ // memory within the lifetime of the current function (allocas, byval // arguments, globals), then determine the comparison result here. SmallVector LHSUObjs, RHSUObjs; - getUnderlyingObjects(LHS, LHSUObjs, DL); - getUnderlyingObjects(RHS, RHSUObjs, DL); + getUnderlyingObjects(LHS, LHSUObjs); + getUnderlyingObjects(RHS, RHSUObjs); // Is the set of underlying objects all noalias calls? auto IsNAC = [](ArrayRef Objects) { diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp --- a/llvm/lib/Analysis/LazyValueInfo.cpp +++ b/llvm/lib/Analysis/LazyValueInfo.cpp @@ -606,13 +606,11 @@ static bool InstructionDereferencesPointer(Instruction *I, Value *Ptr) { if (LoadInst *L = dyn_cast(I)) { return L->getPointerAddressSpace() == 0 && - getUnderlyingObject(L->getPointerOperand(), - L->getModule()->getDataLayout()) == Ptr; + getUnderlyingObject(L->getPointerOperand()) == Ptr; } if (StoreInst *S = dyn_cast(I)) { return S->getPointerAddressSpace() == 0 && - getUnderlyingObject(S->getPointerOperand(), - S->getModule()->getDataLayout()) == Ptr; + getUnderlyingObject(S->getPointerOperand()) == Ptr; } if (MemIntrinsic *MI = dyn_cast(I)) { if (MI->isVolatile()) return false; @@ -622,13 +620,11 @@ if (!Len || Len->isZero()) return false; if (MI->getDestAddressSpace() == 0) - if (getUnderlyingObject(MI->getRawDest(), - MI->getModule()->getDataLayout()) == Ptr) + if (getUnderlyingObject(MI->getRawDest()) == Ptr) return true; if (MemTransferInst *MTI = dyn_cast(MI)) if (MTI->getSourceAddressSpace() == 0) - if (getUnderlyingObject(MTI->getRawSource(), - MTI->getModule()->getDataLayout()) == Ptr) + if (getUnderlyingObject(MTI->getRawSource()) == Ptr) return true; } return false; @@ -641,11 +637,10 @@ static bool isObjectDereferencedInBlock(Value *Val, BasicBlock *BB) { assert(Val->getType()->isPointerTy()); - const DataLayout &DL = BB->getModule()->getDataLayout(); - Value *UnderlyingVal = getUnderlyingObject(Val, DL); + Value *UnderlyingVal = getUnderlyingObject(Val); // If 'getUnderlyingObject' didn't converge, skip it. It won't converge // inside InstructionDereferencesPointer either. - if (UnderlyingVal == getUnderlyingObject(UnderlyingVal, DL, 1)) + if (UnderlyingVal == getUnderlyingObject(UnderlyingVal, 1)) for (Instruction &I : *BB) if (InstructionDereferencesPointer(&I, UnderlyingVal)) return true; diff --git a/llvm/lib/Analysis/Lint.cpp b/llvm/lib/Analysis/Lint.cpp --- a/llvm/lib/Analysis/Lint.cpp +++ b/llvm/lib/Analysis/Lint.cpp @@ -673,7 +673,7 @@ // TODO: Look through eliminable cast pairs. // TODO: Look through calls with unique return values. // TODO: Look through vector insert/extract/shuffle. - V = OffsetOk ? getUnderlyingObject(V, *DL) : V->stripPointerCasts(); + V = OffsetOk ? getUnderlyingObject(V) : V->stripPointerCasts(); if (LoadInst *L = dyn_cast(V)) { BasicBlock::iterator BBI = L->getIterator(); BasicBlock *BB = L->getParent(); diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp --- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp +++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp @@ -508,10 +508,10 @@ typedef PointerIntPair MemAccessInfo; typedef SmallVector MemAccessInfoList; - AccessAnalysis(const DataLayout &Dl, Loop *TheLoop, AAResults *AA, - LoopInfo *LI, MemoryDepChecker::DepCandidates &DA, + AccessAnalysis(Loop *TheLoop, AAResults *AA, LoopInfo *LI, + MemoryDepChecker::DepCandidates &DA, PredicatedScalarEvolution &PSE) - : DL(Dl), TheLoop(TheLoop), AST(*AA), LI(LI), DepCands(DA), + : TheLoop(TheLoop), AST(*AA), LI(LI), DepCands(DA), IsRTCheckAnalysisNeeded(false), PSE(PSE) {} /// Register a load and whether it is only read from. @@ -585,8 +585,6 @@ /// Set of all accesses. PtrAccessSet Accesses; - const DataLayout &DL; - /// The loop being checked. const Loop *TheLoop; @@ -938,7 +936,7 @@ typedef SmallVector ValueVector; ValueVector TempObjects; - getUnderlyingObjects(Ptr, TempObjects, DL, LI); + getUnderlyingObjects(Ptr, TempObjects, LI); LLVM_DEBUG(dbgs() << "Underlying objects for pointer " << *Ptr << "\n"); for (const Value *UnderlyingObj : TempObjects) { @@ -1142,7 +1140,7 @@ // first pointer in the array. Value *Ptr0 = VL[0]; const SCEV *Scev0 = SE.getSCEV(Ptr0); - Value *Obj0 = getUnderlyingObject(Ptr0, DL); + Value *Obj0 = getUnderlyingObject(Ptr0); llvm::SmallSet Offsets; for (auto *Ptr : VL) { @@ -1153,7 +1151,7 @@ return false; // If a pointer refers to a different underlying object, bail - the // pointers are by definition incomparable. - Value *CurrObj = getUnderlyingObject(Ptr, DL); + Value *CurrObj = getUnderlyingObject(Ptr); if (CurrObj != Obj0) return false; @@ -1947,8 +1945,7 @@ } MemoryDepChecker::DepCandidates DependentAccesses; - AccessAnalysis Accesses(TheLoop->getHeader()->getModule()->getDataLayout(), - TheLoop, AA, LI, DependentAccesses, *PSE); + AccessAnalysis Accesses(TheLoop, AA, LI, DependentAccesses, *PSE); // Holds the analyzed pointers. We don't want to call getUnderlyingObjects // multiple times on the same object. If the ptr is accessed twice, once diff --git a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp --- a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp +++ b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp @@ -406,8 +406,6 @@ isInvariantLoad = true; } - const DataLayout &DL = BB->getModule()->getDataLayout(); - // Return "true" if and only if the instruction I is either a non-simple // load or a non-simple store. auto isNonSimpleLoadOrStore = [](Instruction *I) -> bool { @@ -576,7 +574,7 @@ // looking for a clobber in many cases; that's an alias property and is // handled by BasicAA. if (isa(Inst) || isNoAliasFn(Inst, &TLI)) { - const Value *AccessPtr = getUnderlyingObject(MemLoc.Ptr, DL); + const Value *AccessPtr = getUnderlyingObject(MemLoc.Ptr); if (AccessPtr == Inst || AA.isMustAlias(Inst, AccessPtr)) return MemDepResult::getDef(Inst); } diff --git a/llvm/lib/Analysis/ObjCARCAliasAnalysis.cpp b/llvm/lib/Analysis/ObjCARCAliasAnalysis.cpp --- a/llvm/lib/Analysis/ObjCARCAliasAnalysis.cpp +++ b/llvm/lib/Analysis/ObjCARCAliasAnalysis.cpp @@ -54,8 +54,8 @@ // If that failed, climb to the underlying object, including climbing through // ObjC-specific no-ops, and try making an imprecise alias query. - const Value *UA = GetUnderlyingObjCPtr(SA, DL); - const Value *UB = GetUnderlyingObjCPtr(SB, DL); + const Value *UA = GetUnderlyingObjCPtr(SA); + const Value *UB = GetUnderlyingObjCPtr(SB); if (UA != SA || UB != SB) { Result = AAResultBase::alias(MemoryLocation(UA), MemoryLocation(UB), AAQI); // We can't use MustAlias or PartialAlias results here because @@ -83,7 +83,7 @@ // If that failed, climb to the underlying object, including climbing through // ObjC-specific no-ops, and try making an imprecise alias query. - const Value *U = GetUnderlyingObjCPtr(S, DL); + const Value *U = GetUnderlyingObjCPtr(S); if (U != S) return AAResultBase::pointsToConstantMemory(MemoryLocation(U), AAQI, OrLocal); diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -4160,8 +4160,7 @@ return true; } -Value *llvm::getUnderlyingObject(Value *V, const DataLayout &DL, - unsigned MaxLookup) { +Value *llvm::getUnderlyingObject(Value *V, unsigned MaxLookup) { if (!V->getType()->isPointerTy()) return V; for (unsigned Count = 0; MaxLookup == 0 || Count < MaxLookup; ++Count) { @@ -4208,14 +4207,13 @@ void llvm::getUnderlyingObjects(const Value *V, SmallVectorImpl &Objects, - const DataLayout &DL, LoopInfo *LI, - unsigned MaxLookup) { + LoopInfo *LI, unsigned MaxLookup) { SmallPtrSet Visited; SmallVector Worklist; Worklist.push_back(V); do { const Value *P = Worklist.pop_back_val(); - P = getUnderlyingObject(P, DL, MaxLookup); + P = getUnderlyingObject(P, MaxLookup); if (!Visited.insert(P).second) continue; @@ -4280,15 +4278,14 @@ /// ptrtoint+arithmetic+inttoptr sequences. /// It returns false if unidentified object is found in getUnderlyingObjects. bool llvm::getUnderlyingObjectsForCodeGen(const Value *V, - SmallVectorImpl &Objects, - const DataLayout &DL) { + SmallVectorImpl &Objects) { SmallPtrSet Visited; SmallVector Working(1, V); do { V = Working.pop_back_val(); SmallVector Objs; - getUnderlyingObjects(V, Objs, DL); + getUnderlyingObjects(V, Objs); for (const Value *V : Objs) { if (!Visited.insert(V).second) diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp --- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp +++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp @@ -1387,7 +1387,7 @@ // Get the underlying objects for the location passed on the lifetime // marker. SmallVector Allocas; - getUnderlyingObjects(CI.getArgOperand(1), Allocas, *DL); + getUnderlyingObjects(CI.getArgOperand(1), Allocas); // Iterate over each underlying object, creating lifetime markers for each // static alloca. Quit if we find a non-static alloca. diff --git a/llvm/lib/CodeGen/MachinePipeliner.cpp b/llvm/lib/CodeGen/MachinePipeliner.cpp --- a/llvm/lib/CodeGen/MachinePipeliner.cpp +++ b/llvm/lib/CodeGen/MachinePipeliner.cpp @@ -705,14 +705,13 @@ /// This function calls the code in ValueTracking, but first checks that the /// instruction has a memory operand. static void getUnderlyingObjects(const MachineInstr *MI, - SmallVectorImpl &Objs, - const DataLayout &DL) { + SmallVectorImpl &Objs) { if (!MI->hasOneMemOperand()) return; MachineMemOperand *MM = *MI->memoperands_begin(); if (!MM->getValue()) return; - getUnderlyingObjects(MM->getValue(), Objs, DL); + getUnderlyingObjects(MM->getValue(), Objs); for (const Value *V : Objs) { if (!isIdentifiedObject(V)) { Objs.clear(); @@ -736,7 +735,7 @@ PendingLoads.clear(); else if (MI.mayLoad()) { SmallVector Objs; - ::getUnderlyingObjects(&MI, Objs, MF.getDataLayout()); + ::getUnderlyingObjects(&MI, Objs); if (Objs.empty()) Objs.push_back(UnknownValue); for (auto V : Objs) { @@ -745,7 +744,7 @@ } } else if (MI.mayStore()) { SmallVector Objs; - ::getUnderlyingObjects(&MI, Objs, MF.getDataLayout()); + ::getUnderlyingObjects(&MI, Objs); if (Objs.empty()) Objs.push_back(UnknownValue); for (auto V : Objs) { diff --git a/llvm/lib/CodeGen/ScheduleDAGInstrs.cpp b/llvm/lib/CodeGen/ScheduleDAGInstrs.cpp --- a/llvm/lib/CodeGen/ScheduleDAGInstrs.cpp +++ b/llvm/lib/CodeGen/ScheduleDAGInstrs.cpp @@ -154,7 +154,7 @@ Objects.push_back(UnderlyingObjectsVector::value_type(PSV, MayAlias)); } else if (const Value *V = MMO->getValue()) { SmallVector Objs; - if (!getUnderlyingObjectsForCodeGen(V, Objs, DL)) + if (!getUnderlyingObjectsForCodeGen(V, Objs)) return false; for (Value *V : Objs) { diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -6636,7 +6636,7 @@ cast(I.getArgOperand(0))->getSExtValue(); Value *const ObjectPtr = I.getArgOperand(1); SmallVector Allocas; - getUnderlyingObjects(ObjectPtr, Allocas, *DL); + getUnderlyingObjects(ObjectPtr, Allocas); for (SmallVectorImpl::iterator Object = Allocas.begin(), E = Allocas.end(); Object != E; ++Object) { diff --git a/llvm/lib/CodeGen/StackColoring.cpp b/llvm/lib/CodeGen/StackColoring.cpp --- a/llvm/lib/CodeGen/StackColoring.cpp +++ b/llvm/lib/CodeGen/StackColoring.cpp @@ -1048,7 +1048,7 @@ if (MMO->getAAInfo()) { if (const Value *MMOV = MMO->getValue()) { SmallVector Objs; - getUnderlyingObjectsForCodeGen(MMOV, Objs, MF->getDataLayout()); + getUnderlyingObjectsForCodeGen(MMOV, Objs); if (Objs.empty()) MayHaveConflictingAAMD = true; diff --git a/llvm/lib/Target/AMDGPU/AMDGPUAliasAnalysis.cpp b/llvm/lib/Target/AMDGPU/AMDGPUAliasAnalysis.cpp --- a/llvm/lib/Target/AMDGPU/AMDGPUAliasAnalysis.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUAliasAnalysis.cpp @@ -96,7 +96,7 @@ AS == AMDGPUAS::CONSTANT_ADDRESS_32BIT) return true; - const Value *Base = getUnderlyingObject(Loc.Ptr, DL); + const Value *Base = getUnderlyingObject(Loc.Ptr); AS = Base->getType()->getPointerAddressSpace(); if (AS == AMDGPUAS::CONSTANT_ADDRESS || AS == AMDGPUAS::CONSTANT_ADDRESS_32BIT) diff --git a/llvm/lib/Target/AMDGPU/AMDGPUInline.cpp b/llvm/lib/Target/AMDGPU/AMDGPUInline.cpp --- a/llvm/lib/Target/AMDGPU/AMDGPUInline.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUInline.cpp @@ -134,7 +134,7 @@ Ty->getAddressSpace() != AMDGPUAS::FLAT_ADDRESS)) continue; - PtrArg = getUnderlyingObject(PtrArg, DL); + PtrArg = getUnderlyingObject(PtrArg); if (const AllocaInst *AI = dyn_cast(PtrArg)) { if (!AI->isStaticAlloca() || !AIVisited.insert(AI).second) continue; diff --git a/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp b/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp --- a/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp @@ -605,7 +605,7 @@ if (isa(OtherOp)) return true; - Value *OtherObj = getUnderlyingObject(OtherOp, *DL); + Value *OtherObj = getUnderlyingObject(OtherOp); if (!isa(OtherObj)) return false; diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp b/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp --- a/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp @@ -169,7 +169,7 @@ if (AS == AMDGPUAS::PRIVATE_ADDRESS) { const Value *Ptr = GEP->getPointerOperand(); const AllocaInst *Alloca = - dyn_cast(getUnderlyingObject(Ptr, DL)); + dyn_cast(getUnderlyingObject(Ptr)); if (!Alloca || !Alloca->isStaticAlloca()) continue; Type *Ty = Alloca->getAllocatedType(); diff --git a/llvm/lib/Target/AMDGPU/R600Instructions.td b/llvm/lib/Target/AMDGPU/R600Instructions.td --- a/llvm/lib/Target/AMDGPU/R600Instructions.td +++ b/llvm/lib/Target/AMDGPU/R600Instructions.td @@ -354,7 +354,7 @@ return LD->getAddressSpace() == AMDGPUAS::GLOBAL_ADDRESS || (LD->getAddressSpace() == AMDGPUAS::CONSTANT_ADDRESS && !isa(getUnderlyingObject( - LD->getMemOperand()->getValue(), CurDAG->getDataLayout()))); + LD->getMemOperand()->getValue()))); }]>; def vtx_id1_az_extloadi8 : LoadVtxId1 ; @@ -366,7 +366,7 @@ const MemSDNode *LD = cast(N); return LD->getAddressSpace() == AMDGPUAS::CONSTANT_ADDRESS && isa(getUnderlyingObject( - LD->getMemOperand()->getValue(), CurDAG->getDataLayout())); + LD->getMemOperand()->getValue())); }]>; def vtx_id2_az_extloadi8 : LoadVtxId2 ; diff --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp --- a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp +++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp @@ -459,10 +459,8 @@ auto Base2 = MO2->getValue(); if (!Base1 || !Base2) return false; - const MachineFunction &MF = *MI1.getParent()->getParent(); - const DataLayout &DL = MF.getFunction().getParent()->getDataLayout(); - Base1 = getUnderlyingObject(Base1, DL); - Base2 = getUnderlyingObject(Base2, DL); + Base1 = getUnderlyingObject(Base1); + Base2 = getUnderlyingObject(Base2); if (isa(Base1) || isa(Base2)) return false; diff --git a/llvm/lib/Target/Mips/MipsDelaySlotFiller.cpp b/llvm/lib/Target/Mips/MipsDelaySlotFiller.cpp --- a/llvm/lib/Target/Mips/MipsDelaySlotFiller.cpp +++ b/llvm/lib/Target/Mips/MipsDelaySlotFiller.cpp @@ -182,7 +182,7 @@ /// memory instruction can be moved to a delay slot. class MemDefsUses : public InspectMemInstr { public: - MemDefsUses(const DataLayout &DL, const MachineFrameInfo *MFI); + explicit MemDefsUses(const MachineFrameInfo *MFI); private: using ValueType = PointerUnion; @@ -200,7 +200,6 @@ const MachineFrameInfo *MFI; SmallPtrSet Uses, Defs; - const DataLayout &DL; /// Flags indicating whether loads or stores with no underlying objects have /// been seen. @@ -492,8 +491,8 @@ return true; } -MemDefsUses::MemDefsUses(const DataLayout &DL, const MachineFrameInfo *MFI_) - : InspectMemInstr(false), MFI(MFI_), DL(DL) {} +MemDefsUses::MemDefsUses(const MachineFrameInfo *MFI_) + : InspectMemInstr(false), MFI(MFI_) {} bool MemDefsUses::hasHazard_(const MachineInstr &MI) { bool HasHazard = false; @@ -542,7 +541,7 @@ if (const Value *V = MMO.getValue()) { SmallVector Objs; - ::getUnderlyingObjects(V, Objs, DL); + ::getUnderlyingObjects(V, Objs); for (const Value *UValue : Objs) { if (!isIdentifiedObject(V)) @@ -775,7 +774,7 @@ auto *Fn = MBB.getParent(); RegDefsUses RegDU(*Fn->getSubtarget().getRegisterInfo()); - MemDefsUses MemDU(Fn->getDataLayout(), &Fn->getFrameInfo()); + MemDefsUses MemDU(&Fn->getFrameInfo()); ReverseIter Filler; RegDU.init(Slot); @@ -851,7 +850,7 @@ IM.reset(new LoadFromStackOrConst()); } else { const MachineFrameInfo &MFI = Fn->getFrameInfo(); - IM.reset(new MemDefsUses(Fn->getDataLayout(), &MFI)); + IM.reset(new MemDefsUses(&MFI)); } if (!searchRange(MBB, SuccBB->begin(), SuccBB->end(), RegDU, *IM, Slot, diff --git a/llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp b/llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp --- a/llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp +++ b/llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp @@ -704,8 +704,7 @@ // because the former looks through phi nodes while the latter does not. We // need to look through phi nodes to handle pointer induction variables. SmallVector Objs; - getUnderlyingObjects(N->getMemOperand()->getValue(), Objs, - F->getDataLayout()); + getUnderlyingObjects(N->getMemOperand()->getValue(), Objs); return all_of(Objs, [&](const Value *V) { if (auto *A = dyn_cast(V)) diff --git a/llvm/lib/Target/NVPTX/NVPTXLowerArgs.cpp b/llvm/lib/Target/NVPTX/NVPTXLowerArgs.cpp --- a/llvm/lib/Target/NVPTX/NVPTXLowerArgs.cpp +++ b/llvm/lib/Target/NVPTX/NVPTXLowerArgs.cpp @@ -214,8 +214,7 @@ for (auto &I : B) { if (LoadInst *LI = dyn_cast(&I)) { if (LI->getType()->isPointerTy()) { - Value *UO = getUnderlyingObject(LI->getPointerOperand(), - F.getParent()->getDataLayout()); + Value *UO = getUnderlyingObject(LI->getPointerOperand()); if (Argument *Arg = dyn_cast(UO)) { if (Arg->hasByValAttr()) { // LI is a load from a pointer within a byval kernel parameter. diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp --- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp +++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp @@ -5421,8 +5421,7 @@ /// See AAPrivatizablePtrImpl::identifyPrivatizableType(...) Optional identifyPrivatizableType(Attributor &A) override { - Value *Obj = - getUnderlyingObject(&getAssociatedValue(), A.getInfoCache().getDL()); + Value *Obj = getUnderlyingObject(&getAssociatedValue()); if (!Obj) { LLVM_DEBUG(dbgs() << "[AAPrivatizablePtr] No underlying object found!\n"); return nullptr; diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -5643,10 +5643,10 @@ // Try to optimize equality comparisons against alloca-based pointers. if (Op0->getType()->isPointerTy() && I.isEquality()) { assert(Op1->getType()->isPointerTy() && "Comparing pointer with non-pointer?"); - if (auto *Alloca = dyn_cast(getUnderlyingObject(Op0, DL))) + if (auto *Alloca = dyn_cast(getUnderlyingObject(Op0))) if (Instruction *New = foldAllocaCmp(I, Alloca, Op1)) return New; - if (auto *Alloca = dyn_cast(getUnderlyingObject(Op1, DL))) + if (auto *Alloca = dyn_cast(getUnderlyingObject(Op1))) if (Instruction *New = foldAllocaCmp(I, Alloca, Op0)) return New; } diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp --- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -1556,7 +1556,7 @@ if (ClOpt && ClOptGlobals) { // If initialization order checking is disabled, a simple access to a // dynamically initialized global is always valid. - GlobalVariable *G = dyn_cast(getUnderlyingObject(Addr, DL)); + GlobalVariable *G = dyn_cast(getUnderlyingObject(Addr)); if (G && (!ClInitializers || GlobalIsLinkerInitialized(G)) && isSafeAccess(ObjSizeVis, Addr, O.TypeSize)) { NumOptimizedAccessesToGlobalVar++; @@ -1566,7 +1566,7 @@ if (ClOpt && ClOptStack) { // A direct inbounds access to a stack variable is always valid. - if (isa(getUnderlyingObject(Addr, DL)) && + if (isa(getUnderlyingObject(Addr)) && isSafeAccess(ObjSizeVis, Addr, O.TypeSize)) { NumOptimizedAccessesToStackVar++; return; diff --git a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp --- a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp @@ -1246,7 +1246,7 @@ const llvm::Align ShadowAlign(Align * DFS.ShadowWidthBytes); SmallVector Objs; - getUnderlyingObjects(Addr, Objs, Pos->getModule()->getDataLayout()); + getUnderlyingObjects(Addr, Objs); bool AllConstants = true; for (const Value *Obj : Objs) { if (isa(Obj) || isa(Obj)) diff --git a/llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp --- a/llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp @@ -478,7 +478,7 @@ } } - if (isa(getUnderlyingObject(Addr, DL)) && + if (isa(getUnderlyingObject(Addr)) && !PointerMayBeCaptured(Addr, true, true)) { // The variable is addressable but not captured, so it cannot be // referenced from a different thread and participate in a data race diff --git a/llvm/lib/Transforms/ObjCARC/DependencyAnalysis.cpp b/llvm/lib/Transforms/ObjCARC/DependencyAnalysis.cpp --- a/llvm/lib/Transforms/ObjCARC/DependencyAnalysis.cpp +++ b/llvm/lib/Transforms/ObjCARC/DependencyAnalysis.cpp @@ -107,7 +107,7 @@ } else if (const StoreInst *SI = dyn_cast(Inst)) { // Special-case stores, because we don't care about the stored value, just // the store address. - const Value *Op = GetUnderlyingObjCPtr(SI->getPointerOperand(), DL); + const Value *Op = GetUnderlyingObjCPtr(SI->getPointerOperand()); // If we can't tell what the underlying object was, assume there is a // dependence. return IsPotentialRetainableObjPtr(Op, *PA.getAA()) && diff --git a/llvm/lib/Transforms/ObjCARC/ProvenanceAnalysis.cpp b/llvm/lib/Transforms/ObjCARC/ProvenanceAnalysis.cpp --- a/llvm/lib/Transforms/ObjCARC/ProvenanceAnalysis.cpp +++ b/llvm/lib/Transforms/ObjCARC/ProvenanceAnalysis.cpp @@ -162,8 +162,8 @@ bool ProvenanceAnalysis::related(const Value *A, const Value *B, const DataLayout &DL) { - A = GetUnderlyingObjCPtrCached(A, DL, UnderlyingObjCPtrCache); - B = GetUnderlyingObjCPtrCached(B, DL, UnderlyingObjCPtrCache); + A = GetUnderlyingObjCPtrCached(A, UnderlyingObjCPtrCache); + B = GetUnderlyingObjCPtrCached(B, UnderlyingObjCPtrCache); // Quick check. if (A == B) diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp --- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp +++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp @@ -415,8 +415,7 @@ // Check to see if the later store is to the entire object (either a global, // an alloca, or a byval/inalloca argument). If so, then it clearly // overwrites any other store to the same object. - const Value *UO1 = getUnderlyingObject(P1, DL), - *UO2 = getUnderlyingObject(P2, DL); + const Value *UO1 = getUnderlyingObject(P1), *UO2 = getUnderlyingObject(P2); // If we can't resolve the same pointers to the same object, then we can't // analyze them at all. @@ -739,7 +738,6 @@ MemoryLocation Loc = MemoryLocation(F->getOperand(0)); SmallVector Blocks; Blocks.push_back(F->getParent()); - const DataLayout &DL = F->getModule()->getDataLayout(); while (!Blocks.empty()) { BasicBlock *BB = Blocks.pop_back_val(); @@ -755,7 +753,7 @@ break; Value *DepPointer = - getUnderlyingObject(getStoredPointerOperand(Dependency), DL); + getUnderlyingObject(getStoredPointerOperand(Dependency)); // Check for aliasing. if (!AA->isMustAlias(F->getArgOperand(0), DepPointer)) @@ -795,7 +793,7 @@ const DataLayout &DL, AliasAnalysis *AA, const TargetLibraryInfo *TLI, const Function *F) { - const Value *UnderlyingPointer = getUnderlyingObject(LoadedLoc.Ptr, DL); + const Value *UnderlyingPointer = getUnderlyingObject(LoadedLoc.Ptr); // A constant can't be in the dead pointer set. if (isa(UnderlyingPointer)) @@ -861,7 +859,7 @@ if (hasAnalyzableMemoryWrite(&*BBI, *TLI) && isRemovable(&*BBI)) { // See through pointer-to-pointer bitcasts SmallVector Pointers; - getUnderlyingObjects(getStoredPointerOperand(&*BBI), Pointers, DL); + getUnderlyingObjects(getStoredPointerOperand(&*BBI), Pointers); // Stores to stack values are valid candidates for removal. bool AllDead = true; @@ -1134,7 +1132,7 @@ Constant *StoredConstant = dyn_cast(SI->getValueOperand()); if (StoredConstant && StoredConstant->isNullValue() && isRemovable(SI)) { Instruction *UnderlyingPointer = - dyn_cast(getUnderlyingObject(SI->getPointerOperand(), DL)); + dyn_cast(getUnderlyingObject(SI->getPointerOperand())); if (UnderlyingPointer && isCallocLikeFn(UnderlyingPointer, TLI) && memoryIsNotModifiedBetween(UnderlyingPointer, SI, AA, DL, DT)) { @@ -1289,7 +1287,7 @@ // to it is dead along the unwind edge. Otherwise, we need to preserve // the store. if (LastThrowing && DepWrite->comesBefore(LastThrowing)) { - const Value *Underlying = getUnderlyingObject(DepLoc.Ptr, DL); + const Value *Underlying = getUnderlyingObject(DepLoc.Ptr); bool IsStoreDeadOnUnwind = isa(Underlying); if (!IsStoreDeadOnUnwind) { // We're looking for a call to an allocation function @@ -1715,7 +1713,7 @@ // object can be considered terminated. if (MaybeTermLoc->second) { DataLayout DL = MaybeTerm->getParent()->getModule()->getDataLayout(); - DefLoc = MemoryLocation(getUnderlyingObject(DefLoc.Ptr, DL)); + DefLoc = MemoryLocation(getUnderlyingObject(DefLoc.Ptr)); } return AA.isMustAlias(MaybeTermLoc->first, DefLoc); } @@ -2030,7 +2028,6 @@ /// Eliminate writes to objects that are not visible in the caller and are not /// accessed before returning from the function. bool eliminateDeadWritesAtEndOfFunction() { - const DataLayout &DL = F.getParent()->getDataLayout(); bool MadeChange = false; LLVM_DEBUG( dbgs() @@ -2047,7 +2044,7 @@ Instruction *DefI = Def->getMemoryInst(); // See through pointer-to-pointer bitcasts SmallVector Pointers; - getUnderlyingObjects(getLocForWriteEx(DefI)->Ptr, Pointers, DL); + getUnderlyingObjects(getLocForWriteEx(DefI)->Ptr, Pointers); LLVM_DEBUG(dbgs() << " ... MemoryDef is not accessed until the end " "of the function\n"); @@ -2130,7 +2127,7 @@ } MemoryLocation SILoc = *MaybeSILoc; assert(SILoc.Ptr && "SILoc should not be null"); - const Value *SILocUnd = getUnderlyingObject(SILoc.Ptr, DL); + const Value *SILocUnd = getUnderlyingObject(SILoc.Ptr); // Check if the store is a no-op. if (isRemovable(SI) && State.storeIsNoop(KillingDef, SILoc, SILocUnd)) { @@ -2231,7 +2228,7 @@ MemoryLocation NILoc = *State.getLocForWriteEx(NI); if (State.isMemTerminatorInst(SI)) { - const Value *NIUnd = getUnderlyingObject(NILoc.Ptr, DL); + const Value *NIUnd = getUnderlyingObject(NILoc.Ptr); if (!SILocUnd || SILocUnd != NIUnd) continue; LLVM_DEBUG(dbgs() << "DSE: Remove Dead Store:\n DEAD: " << *NI diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp --- a/llvm/lib/Transforms/Scalar/LICM.cpp +++ b/llvm/lib/Transforms/Scalar/LICM.cpp @@ -1909,7 +1909,7 @@ // we have to prove that the store is dead along the unwind edge. We do // this by proving that the caller can't have a reference to the object // after return and thus can't possibly load from the object. - Value *Object = getUnderlyingObject(SomePtr, MDL); + Value *Object = getUnderlyingObject(SomePtr); if (!isKnownNonEscaping(Object, TLI)) return false; // Subtlety: Alloca's aren't visible to callers, but *are* potentially @@ -2041,7 +2041,7 @@ if (IsKnownThreadLocalObject) SafeToInsertStore = true; else { - Value *Object = getUnderlyingObject(SomePtr, MDL); + Value *Object = getUnderlyingObject(SomePtr); SafeToInsertStore = (isAllocLikeFn(Object, TLI) || isa(Object)) && !PointerMayBeCaptured(Object, true, true); diff --git a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp --- a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp +++ b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp @@ -564,12 +564,12 @@ break; case LegalStoreKind::Memset: { // Find the base pointer. - Value *Ptr = getUnderlyingObject(SI->getPointerOperand(), *DL); + Value *Ptr = getUnderlyingObject(SI->getPointerOperand()); StoreRefsForMemset[Ptr].push_back(SI); } break; case LegalStoreKind::MemsetPattern: { // Find the base pointer. - Value *Ptr = getUnderlyingObject(SI->getPointerOperand(), *DL); + Value *Ptr = getUnderlyingObject(SI->getPointerOperand()); StoreRefsForMemsetPattern[Ptr].push_back(SI); } break; case LegalStoreKind::Memcpy: diff --git a/llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp b/llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp --- a/llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp +++ b/llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp @@ -1562,7 +1562,7 @@ if (Value *Ptr = getPointerOperand(V)) return getUnderlyingObjectThroughLoads(Ptr); else if (V->getType()->isPointerTy()) - return getUnderlyingObject(V, DL); + return getUnderlyingObject(V); return V; } diff --git a/llvm/lib/Transforms/Utils/AssumeBundleBuilder.cpp b/llvm/lib/Transforms/Utils/AssumeBundleBuilder.cpp --- a/llvm/lib/Transforms/Utils/AssumeBundleBuilder.cpp +++ b/llvm/lib/Transforms/Utils/AssumeBundleBuilder.cpp @@ -69,7 +69,7 @@ default: return RK; case Attribute::NonNull: - RK.WasOn = getUnderlyingObject(RK.WasOn, M->getDataLayout()); + RK.WasOn = getUnderlyingObject(RK.WasOn); return RK; case Attribute::Alignment: { Value *V = RK.WasOn->stripInBoundsOffsets([&](const Value *Strip) { @@ -145,7 +145,7 @@ if (!RK.WasOn) return true; if (RK.WasOn->getType()->isPointerTy()) { - Value *UnderlyingPtr = getUnderlyingObject(RK.WasOn, M->getDataLayout()); + Value *UnderlyingPtr = getUnderlyingObject(RK.WasOn); if (isa(UnderlyingPtr) || isa(UnderlyingPtr)) return false; } diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp --- a/llvm/lib/Transforms/Utils/InlineFunction.cpp +++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp @@ -1037,7 +1037,7 @@ SmallSetVector NAPtrArgs; for (const Value *V : PtrArgs) { SmallVector Objects; - getUnderlyingObjects(V, Objects, DL, /* LI = */ nullptr); + getUnderlyingObjects(V, Objects, /* LI = */ nullptr); for (const Value *O : Objects) ObjSet.insert(O); diff --git a/llvm/lib/Transforms/Utils/VNCoercion.cpp b/llvm/lib/Transforms/Utils/VNCoercion.cpp --- a/llvm/lib/Transforms/Utils/VNCoercion.cpp +++ b/llvm/lib/Transforms/Utils/VNCoercion.cpp @@ -393,7 +393,7 @@ if (!Src) return -1; - GlobalVariable *GV = dyn_cast(getUnderlyingObject(Src, DL)); + GlobalVariable *GV = dyn_cast(getUnderlyingObject(Src)); if (!GV || !GV->isConstant() || !GV->hasDefinitiveInitializer()) return -1; diff --git a/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp b/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp --- a/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp @@ -762,8 +762,8 @@ return Chain.slice(0, ChainIdx); } -static ChainID getChainID(const Value *Ptr, const DataLayout &DL) { - const Value *ObjPtr = getUnderlyingObject(Ptr, DL); +static ChainID getChainID(const Value *Ptr) { + const Value *ObjPtr = getUnderlyingObject(Ptr); if (const auto *Sel = dyn_cast(ObjPtr)) { // The select's themselves are distinct instructions even if they share the // same condition and evaluate to consecutive pointers for true and false @@ -830,7 +830,7 @@ continue; // Save the load locations. - const ChainID ID = getChainID(Ptr, DL); + const ChainID ID = getChainID(Ptr); LoadRefs[ID].push_back(LI); } else if (StoreInst *SI = dyn_cast(&I)) { if (!SI->isSimple()) @@ -876,7 +876,7 @@ continue; // Save store location. - const ChainID ID = getChainID(Ptr, DL); + const ChainID ID = getChainID(Ptr); StoreRefs[ID].push_back(SI); } } diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -5912,7 +5912,7 @@ continue; if (!isValidElementType(SI->getValueOperand()->getType())) continue; - Stores[getUnderlyingObject(SI->getPointerOperand(), *DL)].push_back(SI); + Stores[getUnderlyingObject(SI->getPointerOperand())].push_back(SI); } // Ignore getelementptr instructions that have more than one index, a