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 @@ -608,13 +608,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; @@ -624,13 +622,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; @@ -643,11 +639,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 @@ -505,10 +505,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. @@ -582,8 +582,6 @@ /// Set of all accesses. PtrAccessSet Accesses; - const DataLayout &DL; - /// The loop being checked. const Loop *TheLoop; @@ -932,7 +930,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) { @@ -1136,7 +1134,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) { @@ -1147,7 +1145,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; @@ -1941,8 +1939,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 @@ -4149,8 +4149,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) { @@ -4197,14 +4196,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; @@ -4269,15 +4267,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 @@ -1382,7 +1382,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 @@ -6631,7 +6631,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 @@ -5418,8 +5418,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 @@ -1257,7 +1257,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 @@ -5911,7 +5911,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