[llvm] d23959b - [SCEV] Cache DataLayout in class (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 28 03:19:43 PDT 2024
Author: Nikita Popov
Date: 2024-06-28T12:19:27+02:00
New Revision: d23959b2f59438829975107e175b4bd34744477d
URL: https://github.com/llvm/llvm-project/commit/d23959b2f59438829975107e175b4bd34744477d
DIFF: https://github.com/llvm/llvm-project/commit/d23959b2f59438829975107e175b4bd34744477d.diff
LOG: [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.
Added:
Modified:
llvm/include/llvm/Analysis/ScalarEvolution.h
llvm/lib/Analysis/ScalarEvolution.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/ScalarEvolution.h b/llvm/include/llvm/Analysis/ScalarEvolution.h
index 88c085533eb86..97b30daf4427a 100644
--- a/llvm/include/llvm/Analysis/ScalarEvolution.h
+++ b/llvm/include/llvm/Analysis/ScalarEvolution.h
@@ -1265,9 +1265,7 @@ class ScalarEvolution {
/// Return the DataLayout associated with the module this SCEV instance is
/// operating on.
- const DataLayout &getDataLayout() const {
- return F.getDataLayout();
- }
+ const DataLayout &getDataLayout() const { return DL; }
const SCEVPredicate *getEqualPredicate(const SCEV *LHS, const SCEV *RHS);
const SCEVPredicate *getComparePredicate(ICmpInst::Predicate Pred,
@@ -1373,6 +1371,9 @@ class ScalarEvolution {
/// The function we are analyzing.
Function &F;
+ /// Data layout of the module.
+ const DataLayout &DL;
+
/// Does the module have any calls to the llvm.experimental.guard intrinsic
/// at all? If this is false, we avoid doing work that will only help if
/// thare are guards present in the IR.
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index a79a6e18b1a6c..e998fe9452ad7 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -13509,7 +13509,7 @@ ScalarEvolution::SCEVCallbackVH::SCEVCallbackVH(Value *V, ScalarEvolution *se)
ScalarEvolution::ScalarEvolution(Function &F, TargetLibraryInfo &TLI,
AssumptionCache &AC, DominatorTree &DT,
LoopInfo &LI)
- : F(F), TLI(TLI), AC(AC), DT(DT), LI(LI),
+ : F(F), DL(F.getDataLayout()), TLI(TLI), AC(AC), DT(DT), LI(LI),
CouldNotCompute(new SCEVCouldNotCompute()), ValuesAtScopes(64),
LoopDispositions(64), BlockDispositions(64) {
// To use guards for proving predicates, we need to scan every instruction in
@@ -13528,8 +13528,8 @@ ScalarEvolution::ScalarEvolution(Function &F, TargetLibraryInfo &TLI,
}
ScalarEvolution::ScalarEvolution(ScalarEvolution &&Arg)
- : F(Arg.F), HasGuards(Arg.HasGuards), TLI(Arg.TLI), AC(Arg.AC), DT(Arg.DT),
- LI(Arg.LI), CouldNotCompute(std::move(Arg.CouldNotCompute)),
+ : F(Arg.F), DL(Arg.DL), HasGuards(Arg.HasGuards), TLI(Arg.TLI), AC(Arg.AC),
+ DT(Arg.DT), LI(Arg.LI), CouldNotCompute(std::move(Arg.CouldNotCompute)),
ValueExprMap(std::move(Arg.ValueExprMap)),
PendingLoopPredicates(std::move(Arg.PendingLoopPredicates)),
PendingPhiRanges(std::move(Arg.PendingPhiRanges)),
More information about the llvm-commits
mailing list