Skip to content

Commit d23959b

Browse files
committed
[SCEV] Cache DataLayout in class (NFC)
PR #96919 caused a minor compile-time regression, mostly because SCEV now goes through an extra out-of-line function to fetch the data layout, and does this a lot. Cache the DataLayout in SCEV to avoid these repeated calls.
1 parent 9de14e2 commit d23959b

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

llvm/include/llvm/Analysis/ScalarEvolution.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,9 +1265,7 @@ class ScalarEvolution {
12651265

12661266
/// Return the DataLayout associated with the module this SCEV instance is
12671267
/// operating on.
1268-
const DataLayout &getDataLayout() const {
1269-
return F.getDataLayout();
1270-
}
1268+
const DataLayout &getDataLayout() const { return DL; }
12711269

12721270
const SCEVPredicate *getEqualPredicate(const SCEV *LHS, const SCEV *RHS);
12731271
const SCEVPredicate *getComparePredicate(ICmpInst::Predicate Pred,
@@ -1373,6 +1371,9 @@ class ScalarEvolution {
13731371
/// The function we are analyzing.
13741372
Function &F;
13751373

1374+
/// Data layout of the module.
1375+
const DataLayout &DL;
1376+
13761377
/// Does the module have any calls to the llvm.experimental.guard intrinsic
13771378
/// at all? If this is false, we avoid doing work that will only help if
13781379
/// thare are guards present in the IR.

llvm/lib/Analysis/ScalarEvolution.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13509,7 +13509,7 @@ ScalarEvolution::SCEVCallbackVH::SCEVCallbackVH(Value *V, ScalarEvolution *se)
1350913509
ScalarEvolution::ScalarEvolution(Function &F, TargetLibraryInfo &TLI,
1351013510
AssumptionCache &AC, DominatorTree &DT,
1351113511
LoopInfo &LI)
13512-
: F(F), TLI(TLI), AC(AC), DT(DT), LI(LI),
13512+
: F(F), DL(F.getDataLayout()), TLI(TLI), AC(AC), DT(DT), LI(LI),
1351313513
CouldNotCompute(new SCEVCouldNotCompute()), ValuesAtScopes(64),
1351413514
LoopDispositions(64), BlockDispositions(64) {
1351513515
// To use guards for proving predicates, we need to scan every instruction in
@@ -13528,8 +13528,8 @@ ScalarEvolution::ScalarEvolution(Function &F, TargetLibraryInfo &TLI,
1352813528
}
1352913529

1353013530
ScalarEvolution::ScalarEvolution(ScalarEvolution &&Arg)
13531-
: F(Arg.F), HasGuards(Arg.HasGuards), TLI(Arg.TLI), AC(Arg.AC), DT(Arg.DT),
13532-
LI(Arg.LI), CouldNotCompute(std::move(Arg.CouldNotCompute)),
13531+
: F(Arg.F), DL(Arg.DL), HasGuards(Arg.HasGuards), TLI(Arg.TLI), AC(Arg.AC),
13532+
DT(Arg.DT), LI(Arg.LI), CouldNotCompute(std::move(Arg.CouldNotCompute)),
1353313533
ValueExprMap(std::move(Arg.ValueExprMap)),
1353413534
PendingLoopPredicates(std::move(Arg.PendingLoopPredicates)),
1353513535
PendingPhiRanges(std::move(Arg.PendingPhiRanges)),

0 commit comments

Comments
 (0)