Skip to content

Commit 2d209d9

Browse files
authored
[IR] Add getDataLayout() helpers to BasicBlock and Instruction (#96902)
This is a helper to avoid writing `getModule()->getDataLayout()`. I regularly try to use this method only to remember it doesn't exist... `getModule()->getDataLayout()` is also a common (the most common?) reason why code has to include the Module.h header.
1 parent 2641975 commit 2d209d9

File tree

100 files changed

+244
-223
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+244
-223
lines changed

llvm/include/llvm/Analysis/MemorySSA.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1269,7 +1269,7 @@ class upward_defs_iterator
12691269
if (WalkingPhi && Location.Ptr) {
12701270
PHITransAddr Translator(
12711271
const_cast<Value *>(Location.Ptr),
1272-
OriginalAccess->getBlock()->getModule()->getDataLayout(), nullptr);
1272+
OriginalAccess->getBlock()->getDataLayout(), nullptr);
12731273

12741274
if (Value *Addr =
12751275
Translator.translateValue(OriginalAccess->getBlock(),

llvm/include/llvm/IR/BasicBlock.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ namespace llvm {
3232

3333
class AssemblyAnnotationWriter;
3434
class CallInst;
35+
class DataLayout;
3536
class Function;
3637
class LandingPadInst;
3738
class LLVMContext;
@@ -218,6 +219,11 @@ class BasicBlock final : public Value, // Basic blocks are data objects also
218219
static_cast<const BasicBlock *>(this)->getModule());
219220
}
220221

222+
/// Get the data layout of the module this basic block belongs to.
223+
///
224+
/// Requires the basic block to have a parent module.
225+
const DataLayout &getDataLayout() const;
226+
221227
/// Returns the terminator instruction if the block is well formed or null
222228
/// if the block is not well formed.
223229
const Instruction *getTerminator() const LLVM_READONLY {

llvm/include/llvm/IR/IRBuilder.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,7 @@ class IRBuilderBase {
10491049

10501050
/// Create a call to llvm.stacksave
10511051
CallInst *CreateStackSave(const Twine &Name = "") {
1052-
const DataLayout &DL = BB->getModule()->getDataLayout();
1052+
const DataLayout &DL = BB->getDataLayout();
10531053
return CreateIntrinsic(Intrinsic::stacksave, {DL.getAllocaPtrType(Context)},
10541054
{}, nullptr, Name);
10551055
}
@@ -1770,14 +1770,14 @@ class IRBuilderBase {
17701770

17711771
AllocaInst *CreateAlloca(Type *Ty, unsigned AddrSpace,
17721772
Value *ArraySize = nullptr, const Twine &Name = "") {
1773-
const DataLayout &DL = BB->getModule()->getDataLayout();
1773+
const DataLayout &DL = BB->getDataLayout();
17741774
Align AllocaAlign = DL.getPrefTypeAlign(Ty);
17751775
return Insert(new AllocaInst(Ty, AddrSpace, ArraySize, AllocaAlign), Name);
17761776
}
17771777

17781778
AllocaInst *CreateAlloca(Type *Ty, Value *ArraySize = nullptr,
17791779
const Twine &Name = "") {
1780-
const DataLayout &DL = BB->getModule()->getDataLayout();
1780+
const DataLayout &DL = BB->getDataLayout();
17811781
Align AllocaAlign = DL.getPrefTypeAlign(Ty);
17821782
unsigned AddrSpace = DL.getAllocaAddrSpace();
17831783
return Insert(new AllocaInst(Ty, AddrSpace, ArraySize, AllocaAlign), Name);
@@ -1815,7 +1815,7 @@ class IRBuilderBase {
18151815
LoadInst *CreateAlignedLoad(Type *Ty, Value *Ptr, MaybeAlign Align,
18161816
bool isVolatile, const Twine &Name = "") {
18171817
if (!Align) {
1818-
const DataLayout &DL = BB->getModule()->getDataLayout();
1818+
const DataLayout &DL = BB->getDataLayout();
18191819
Align = DL.getABITypeAlign(Ty);
18201820
}
18211821
return Insert(new LoadInst(Ty, Ptr, Twine(), isVolatile, *Align), Name);
@@ -1824,7 +1824,7 @@ class IRBuilderBase {
18241824
StoreInst *CreateAlignedStore(Value *Val, Value *Ptr, MaybeAlign Align,
18251825
bool isVolatile = false) {
18261826
if (!Align) {
1827-
const DataLayout &DL = BB->getModule()->getDataLayout();
1827+
const DataLayout &DL = BB->getDataLayout();
18281828
Align = DL.getABITypeAlign(Val->getType());
18291829
}
18301830
return Insert(new StoreInst(Val, Ptr, isVolatile, *Align));
@@ -1841,7 +1841,7 @@ class IRBuilderBase {
18411841
AtomicOrdering FailureOrdering,
18421842
SyncScope::ID SSID = SyncScope::System) {
18431843
if (!Align) {
1844-
const DataLayout &DL = BB->getModule()->getDataLayout();
1844+
const DataLayout &DL = BB->getDataLayout();
18451845
Align = llvm::Align(DL.getTypeStoreSize(New->getType()));
18461846
}
18471847

@@ -1854,7 +1854,7 @@ class IRBuilderBase {
18541854
AtomicOrdering Ordering,
18551855
SyncScope::ID SSID = SyncScope::System) {
18561856
if (!Align) {
1857-
const DataLayout &DL = BB->getModule()->getDataLayout();
1857+
const DataLayout &DL = BB->getDataLayout();
18581858
Align = llvm::Align(DL.getTypeStoreSize(Val->getType()));
18591859
}
18601860

llvm/include/llvm/IR/Instruction.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
namespace llvm {
3030

3131
class BasicBlock;
32+
class DataLayout;
3233
class DbgMarker;
3334
class FastMathFlags;
3435
class MDNode;
@@ -189,6 +190,11 @@ class Instruction : public User,
189190
static_cast<const Instruction *>(this)->getFunction());
190191
}
191192

193+
/// Get the data layout of the module this instruction belongs to.
194+
///
195+
/// Requires the instruction to have a parent module.
196+
const DataLayout &getDataLayout() const;
197+
192198
/// This method unlinks 'this' from the containing basic block, but does not
193199
/// delete it.
194200
void removeFromParent();

llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class InterestingMemoryOperand {
4343
Value *MaybeStride = nullptr)
4444
: IsWrite(IsWrite), OpType(OpType), Alignment(Alignment),
4545
MaybeMask(MaybeMask), MaybeEVL(MaybeEVL), MaybeStride(MaybeStride) {
46-
const DataLayout &DL = I->getModule()->getDataLayout();
46+
const DataLayout &DL = I->getDataLayout();
4747
TypeStoreSize = DL.getTypeStoreSizeInBits(OpType);
4848
PtrUse = &I->getOperandUse(OperandNo);
4949
}

llvm/lib/Analysis/BranchProbabilityInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ computeUnlikelySuccessors(const BasicBlock *BB, Loop *L,
620620
if (!CmpLHSConst || !llvm::is_contained(successors(BB), B))
621621
continue;
622622
// First collapse InstChain
623-
const DataLayout &DL = BB->getModule()->getDataLayout();
623+
const DataLayout &DL = BB->getDataLayout();
624624
for (Instruction *I : llvm::reverse(InstChain)) {
625625
CmpLHSConst = ConstantFoldBinaryOpOperands(
626626
I->getOpcode(), CmpLHSConst, cast<Constant>(I->getOperand(1)), DL);

llvm/lib/Analysis/CaptureTracking.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ UseCaptureKind llvm::DetermineUseCaptureKind(
388388
// Comparing a dereferenceable_or_null pointer against null cannot
389389
// lead to pointer escapes, because if it is not null it must be a
390390
// valid (in-bounds) pointer.
391-
const DataLayout &DL = I->getModule()->getDataLayout();
391+
const DataLayout &DL = I->getDataLayout();
392392
if (IsDereferenceableOrNull && IsDereferenceableOrNull(O, DL))
393393
return UseCaptureKind::NO_CAPTURE;
394394
}

llvm/lib/Analysis/DemandedBits.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void DemandedBits::determineLiveOperandBits(
6969
return;
7070
KnownBitsComputed = true;
7171

72-
const DataLayout &DL = UserI->getModule()->getDataLayout();
72+
const DataLayout &DL = UserI->getDataLayout();
7373
Known = KnownBits(BitWidth);
7474
computeKnownBits(V1, Known, DL, 0, &AC, UserI, &DT);
7575

@@ -404,14 +404,14 @@ APInt DemandedBits::getDemandedBits(Instruction *I) {
404404
if (Found != AliveBits.end())
405405
return Found->second;
406406

407-
const DataLayout &DL = I->getModule()->getDataLayout();
407+
const DataLayout &DL = I->getDataLayout();
408408
return APInt::getAllOnes(DL.getTypeSizeInBits(I->getType()->getScalarType()));
409409
}
410410

411411
APInt DemandedBits::getDemandedBits(Use *U) {
412412
Type *T = (*U)->getType();
413413
auto *UserI = cast<Instruction>(U->getUser());
414-
const DataLayout &DL = UserI->getModule()->getDataLayout();
414+
const DataLayout &DL = UserI->getDataLayout();
415415
unsigned BitWidth = DL.getTypeSizeInBits(T->getScalarType());
416416

417417
// We only track integer uses, everything else produces a mask with all bits

llvm/lib/Analysis/IVDescriptors.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ static std::pair<Type *, bool> computeRecurrenceType(Instruction *Exit,
9595
AssumptionCache *AC,
9696
DominatorTree *DT) {
9797
bool IsSigned = false;
98-
const DataLayout &DL = Exit->getModule()->getDataLayout();
98+
const DataLayout &DL = Exit->getDataLayout();
9999
uint64_t MaxBitWidth = DL.getTypeSizeInBits(Exit->getType());
100100

101101
if (DB) {

llvm/lib/Analysis/IVUsers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ static bool IVUseShouldUsePostIncValue(Instruction *User, Value *Operand,
134134
/// add its users to the IVUsesByStride set and return true. Otherwise, return
135135
/// false.
136136
bool IVUsers::AddUsersIfInteresting(Instruction *I) {
137-
const DataLayout &DL = I->getModule()->getDataLayout();
137+
const DataLayout &DL = I->getDataLayout();
138138

139139
// Add this IV user to the Processed set before returning false to ensure that
140140
// all IV users are members of the set. See IVUsers::isIVUserOrOperand.

llvm/lib/Analysis/InstructionSimplify.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7183,7 +7183,7 @@ static bool replaceAndRecursivelySimplifyImpl(
71837183
SmallSetVector<Instruction *, 8> *UnsimplifiedUsers = nullptr) {
71847184
bool Simplified = false;
71857185
SmallSetVector<Instruction *, 8> Worklist;
7186-
const DataLayout &DL = I->getModule()->getDataLayout();
7186+
const DataLayout &DL = I->getDataLayout();
71877187

71887188
// If we have an explicit value to collapse to, do that round of the
71897189
// simplification loop by hand initially.

llvm/lib/Analysis/LazyValueInfo.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,7 @@ LazyValueInfoImpl::solveBlockValueExtractValue(ExtractValueInst *EVI,
10591059
// based on replaced with.overflow intrinsics.
10601060
if (Value *V = simplifyExtractValueInst(
10611061
EVI->getAggregateOperand(), EVI->getIndices(),
1062-
EVI->getModule()->getDataLayout()))
1062+
EVI->getDataLayout()))
10631063
return getBlockValue(V, BB, EVI);
10641064

10651065
LLVM_DEBUG(dbgs() << " compute BB '" << BB->getName()
@@ -1387,7 +1387,7 @@ LazyValueInfoImpl::getEdgeValueLocal(Value *Val, BasicBlock *BBFrom,
13871387
// over the operands unnecessarily which can be expensive for
13881388
// instructions with many operands.
13891389
if (isa<IntegerType>(Usr->getType()) && isOperationFoldable(Usr)) {
1390-
const DataLayout &DL = BBTo->getModule()->getDataLayout();
1390+
const DataLayout &DL = BBTo->getDataLayout();
13911391
if (usesOperand(Usr, Condition)) {
13921392
// If Val has Condition as an operand and Val can be folded into a
13931393
// constant with either Condition == true or Condition == false,
@@ -1451,7 +1451,7 @@ LazyValueInfoImpl::getEdgeValueLocal(Value *Val, BasicBlock *BBFrom,
14511451
ConstantRange EdgeVal(CaseValue);
14521452
if (ValUsesConditionAndMayBeFoldable) {
14531453
User *Usr = cast<User>(Val);
1454-
const DataLayout &DL = BBTo->getModule()->getDataLayout();
1454+
const DataLayout &DL = BBTo->getDataLayout();
14551455
ValueLatticeElement EdgeLatticeVal =
14561456
constantFoldUser(Usr, Condition, CaseValue, DL);
14571457
if (EdgeLatticeVal.isOverdefined())

llvm/lib/Analysis/Lint.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -563,22 +563,22 @@ static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT,
563563
}
564564

565565
void Lint::visitSDiv(BinaryOperator &I) {
566-
Check(!isZero(I.getOperand(1), I.getModule()->getDataLayout(), DT, AC),
566+
Check(!isZero(I.getOperand(1), I.getDataLayout(), DT, AC),
567567
"Undefined behavior: Division by zero", &I);
568568
}
569569

570570
void Lint::visitUDiv(BinaryOperator &I) {
571-
Check(!isZero(I.getOperand(1), I.getModule()->getDataLayout(), DT, AC),
571+
Check(!isZero(I.getOperand(1), I.getDataLayout(), DT, AC),
572572
"Undefined behavior: Division by zero", &I);
573573
}
574574

575575
void Lint::visitSRem(BinaryOperator &I) {
576-
Check(!isZero(I.getOperand(1), I.getModule()->getDataLayout(), DT, AC),
576+
Check(!isZero(I.getOperand(1), I.getDataLayout(), DT, AC),
577577
"Undefined behavior: Division by zero", &I);
578578
}
579579

580580
void Lint::visitURem(BinaryOperator &I) {
581-
Check(!isZero(I.getOperand(1), I.getModule()->getDataLayout(), DT, AC),
581+
Check(!isZero(I.getOperand(1), I.getDataLayout(), DT, AC),
582582
"Undefined behavior: Division by zero", &I);
583583
}
584584

llvm/lib/Analysis/Loads.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ bool llvm::isDereferenceableAndAlignedInLoop(LoadInst *LI, Loop *L,
263263
ScalarEvolution &SE,
264264
DominatorTree &DT,
265265
AssumptionCache *AC) {
266-
auto &DL = LI->getModule()->getDataLayout();
266+
auto &DL = LI->getDataLayout();
267267
Value *Ptr = LI->getPointerOperand();
268268

269269
APInt EltSize(DL.getIndexTypeSizeInBits(Ptr->getType()),
@@ -588,7 +588,7 @@ Value *llvm::findAvailablePtrLoadStore(
588588
if (MaxInstsToScan == 0)
589589
MaxInstsToScan = ~0U;
590590

591-
const DataLayout &DL = ScanBB->getModule()->getDataLayout();
591+
const DataLayout &DL = ScanBB->getDataLayout();
592592
const Value *StrippedPtr = Loc.Ptr->stripPointerCasts();
593593

594594
while (ScanFrom != ScanBB->begin()) {
@@ -668,7 +668,7 @@ Value *llvm::findAvailablePtrLoadStore(
668668
Value *llvm::FindAvailableLoadedValue(LoadInst *Load, BatchAAResults &AA,
669669
bool *IsLoadCSE,
670670
unsigned MaxInstsToScan) {
671-
const DataLayout &DL = Load->getModule()->getDataLayout();
671+
const DataLayout &DL = Load->getDataLayout();
672672
Value *StrippedPtr = Load->getPointerOperand()->stripPointerCasts();
673673
BasicBlock *ScanBB = Load->getParent();
674674
Type *AccessTy = Load->getType();

llvm/lib/Analysis/LoopAccessAnalysis.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ getStartAndEndForAccess(const Loop *Lp, const SCEV *PtrExpr, Type *AccessTy,
239239
assert(SE->isLoopInvariant(ScEnd, Lp)&& "ScEnd needs to be invariant");
240240

241241
// Add the size of the pointed element to ScEnd.
242-
auto &DL = Lp->getHeader()->getModule()->getDataLayout();
242+
auto &DL = Lp->getHeader()->getDataLayout();
243243
Type *IdxTy = DL.getIndexType(PtrExpr->getType());
244244
const SCEV *EltSizeSCEV = SE->getStoreSizeOfExpr(IdxTy, AccessTy);
245245
ScEnd = SE->getAddExpr(ScEnd, EltSizeSCEV);
@@ -309,7 +309,7 @@ bool RuntimePointerChecking::tryToCreateDiffCheck(
309309
return false;
310310

311311
const DataLayout &DL =
312-
SinkAR->getLoop()->getHeader()->getModule()->getDataLayout();
312+
SinkAR->getLoop()->getHeader()->getDataLayout();
313313
unsigned AllocSize =
314314
std::max(DL.getTypeAllocSize(SrcTy), DL.getTypeAllocSize(DstTy));
315315

@@ -1494,7 +1494,7 @@ std::optional<int64_t> llvm::getPtrStride(PredicatedScalarEvolution &PSE,
14941494
return std::nullopt;
14951495
}
14961496

1497-
auto &DL = Lp->getHeader()->getModule()->getDataLayout();
1497+
auto &DL = Lp->getHeader()->getDataLayout();
14981498
TypeSize AllocSize = DL.getTypeAllocSize(AccessTy);
14991499
int64_t Size = AllocSize.getFixedValue();
15001500
const APInt &APStepVal = C->getAPInt();
@@ -1907,7 +1907,7 @@ MemoryDepChecker::getDependenceDistanceStrideAndSize(
19071907
const AccessAnalysis::MemAccessInfo &B, Instruction *BInst,
19081908
const DenseMap<Value *, SmallVector<const Value *, 16>>
19091909
&UnderlyingObjects) {
1910-
auto &DL = InnermostLoop->getHeader()->getModule()->getDataLayout();
1910+
auto &DL = InnermostLoop->getHeader()->getDataLayout();
19111911
auto &SE = *PSE.getSE();
19121912
auto [APtr, AIsWrite] = A;
19131913
auto [BPtr, BIsWrite] = B;
@@ -2027,7 +2027,7 @@ MemoryDepChecker::Dependence::DepType MemoryDepChecker::isDependent(
20272027
}
20282028

20292029
ScalarEvolution &SE = *PSE.getSE();
2030-
auto &DL = InnermostLoop->getHeader()->getModule()->getDataLayout();
2030+
auto &DL = InnermostLoop->getHeader()->getDataLayout();
20312031
uint64_t MaxStride = std::max(StrideA, StrideB);
20322032

20332033
// If the distance between the acecsses is larger than their maximum absolute
@@ -2805,7 +2805,7 @@ bool LoopAccessInfo::isInvariant(Value *V) const {
28052805
/// stores. This ignores trailing indices that have no effect on the final
28062806
/// pointer.
28072807
static unsigned getGEPInductionOperand(const GetElementPtrInst *Gep) {
2808-
const DataLayout &DL = Gep->getModule()->getDataLayout();
2808+
const DataLayout &DL = Gep->getDataLayout();
28092809
unsigned LastOperand = Gep->getNumOperands() - 1;
28102810
TypeSize GEPAllocSize = DL.getTypeAllocSize(Gep->getResultElementType());
28112811

@@ -2961,7 +2961,7 @@ void LoopAccessInfo::collectStridedAccess(Value *MemAccess) {
29612961
// Match the types so we can compare the stride and the MaxBTC.
29622962
// The Stride can be positive/negative, so we sign extend Stride;
29632963
// The backedgeTakenCount is non-negative, so we zero extend MaxBTC.
2964-
const DataLayout &DL = TheLoop->getHeader()->getModule()->getDataLayout();
2964+
const DataLayout &DL = TheLoop->getHeader()->getDataLayout();
29652965
uint64_t StrideTypeSizeBits = DL.getTypeSizeInBits(StrideExpr->getType());
29662966
uint64_t BETypeSizeBits = DL.getTypeSizeInBits(MaxBTC->getType());
29672967
const SCEV *CastedStride = StrideExpr;

llvm/lib/Analysis/LoopUnrollAnalyzer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ bool UnrolledInstAnalyzer::visitBinaryOperator(BinaryOperator &I) {
8484
RHS = SimpleRHS;
8585

8686
Value *SimpleV = nullptr;
87-
const DataLayout &DL = I.getModule()->getDataLayout();
87+
const DataLayout &DL = I.getDataLayout();
8888
if (auto FI = dyn_cast<FPMathOperator>(&I))
8989
SimpleV =
9090
simplifyBinOp(I.getOpcode(), LHS, RHS, FI->getFastMathFlags(), DL);
@@ -157,7 +157,7 @@ bool UnrolledInstAnalyzer::visitCastInst(CastInst &I) {
157157
// analysis, which operates on integers (and, e.g., might convert i8* null to
158158
// i32 0).
159159
if (CastInst::castIsValid(I.getOpcode(), Op, I.getType())) {
160-
const DataLayout &DL = I.getModule()->getDataLayout();
160+
const DataLayout &DL = I.getDataLayout();
161161
if (Value *V = simplifyCastInst(I.getOpcode(), Op, I.getType(), DL)) {
162162
SimplifiedValues[&I] = V;
163163
return true;
@@ -194,7 +194,7 @@ bool UnrolledInstAnalyzer::visitCmpInst(CmpInst &I) {
194194
}
195195
}
196196

197-
const DataLayout &DL = I.getModule()->getDataLayout();
197+
const DataLayout &DL = I.getDataLayout();
198198
if (Value *V = simplifyCmpInst(I.getPredicate(), LHS, RHS, DL)) {
199199
SimplifiedValues[&I] = V;
200200
return true;

llvm/lib/Analysis/MemoryBuiltins.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ llvm::getAllocSize(const CallBase *CB, const TargetLibraryInfo *TLI,
386386

387387
// Get the index type for this address space, results and intermediate
388388
// computations are performed at that width.
389-
auto &DL = CB->getModule()->getDataLayout();
389+
auto &DL = CB->getDataLayout();
390390
const unsigned IntTyBits = DL.getIndexTypeSizeInBits(CB->getType());
391391

392392
// Handle strdup-like functions separately.

llvm/lib/Analysis/MemoryDependenceAnalysis.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ MemDepResult MemoryDependenceResults::getSimplePointerDependencyFrom(
399399
BatchAAResults &BatchAA) {
400400
bool isInvariantLoad = false;
401401
Align MemLocAlign =
402-
MemLoc.Ptr->getPointerAlignment(BB->getModule()->getDataLayout());
402+
MemLoc.Ptr->getPointerAlignment(BB->getDataLayout());
403403

404404
unsigned DefaultLimit = getDefaultBlockScanLimit();
405405
if (!Limit)
@@ -910,7 +910,7 @@ void MemoryDependenceResults::getNonLocalPointerDependency(
910910
const_cast<Value *>(Loc.Ptr)));
911911
return;
912912
}
913-
const DataLayout &DL = FromBB->getModule()->getDataLayout();
913+
const DataLayout &DL = FromBB->getDataLayout();
914914
PHITransAddr Address(const_cast<Value *>(Loc.Ptr), DL, &AC);
915915

916916
// This is the set of blocks we've inspected, and the pointer we consider in

0 commit comments

Comments
 (0)