[llvm] 0d3d445 - [LVI] Remove unnecessary TLI dependency
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 19 05:32:51 PST 2023
Author: Nikita Popov
Date: 2023-12-19T14:32:43+01:00
New Revision: 0d3d44522382028864d0223bc1d74929e17d5137
URL: https://github.com/llvm/llvm-project/commit/0d3d44522382028864d0223bc1d74929e17d5137
DIFF: https://github.com/llvm/llvm-project/commit/0d3d44522382028864d0223bc1d74929e17d5137.diff
LOG: [LVI] Remove unnecessary TLI dependency
Only used in ConstantFoldCompareInstOperands(), which does not
actually use TLI.
Added:
Modified:
llvm/include/llvm/Analysis/LazyValueInfo.h
llvm/lib/Analysis/LazyValueInfo.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/LazyValueInfo.h b/llvm/include/llvm/Analysis/LazyValueInfo.h
index cb5fa35d299510..25a2c9ffa534af 100644
--- a/llvm/include/llvm/Analysis/LazyValueInfo.h
+++ b/llvm/include/llvm/Analysis/LazyValueInfo.h
@@ -32,7 +32,6 @@ namespace llvm {
friend class LazyValueInfoWrapperPass;
AssumptionCache *AC = nullptr;
const DataLayout *DL = nullptr;
- class TargetLibraryInfo *TLI = nullptr;
LazyValueInfoImpl *PImpl = nullptr;
LazyValueInfo(const LazyValueInfo &) = delete;
void operator=(const LazyValueInfo &) = delete;
@@ -43,18 +42,16 @@ namespace llvm {
public:
~LazyValueInfo();
LazyValueInfo() = default;
- LazyValueInfo(AssumptionCache *AC_, const DataLayout *DL_,
- TargetLibraryInfo *TLI_)
- : AC(AC_), DL(DL_), TLI(TLI_) {}
+ LazyValueInfo(AssumptionCache *AC_, const DataLayout *DL_)
+ : AC(AC_), DL(DL_) {}
LazyValueInfo(LazyValueInfo &&Arg)
- : AC(Arg.AC), DL(Arg.DL), TLI(Arg.TLI), PImpl(Arg.PImpl) {
+ : AC(Arg.AC), DL(Arg.DL), PImpl(Arg.PImpl) {
Arg.PImpl = nullptr;
}
LazyValueInfo &operator=(LazyValueInfo &&Arg) {
releaseMemory();
AC = Arg.AC;
DL = Arg.DL;
- TLI = Arg.TLI;
PImpl = Arg.PImpl;
Arg.PImpl = nullptr;
return *this;
diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp
index 910f6b72afefe2..89cc7ea15ec1d7 100644
--- a/llvm/lib/Analysis/LazyValueInfo.cpp
+++ b/llvm/lib/Analysis/LazyValueInfo.cpp
@@ -1566,7 +1566,6 @@ void LazyValueInfoImpl::threadEdge(BasicBlock *PredBB, BasicBlock *OldSucc,
bool LazyValueInfoWrapperPass::runOnFunction(Function &F) {
Info.AC = &getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
- Info.TLI = &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(F);
if (auto *Impl = Info.getImpl())
Impl->clear();
@@ -1627,9 +1626,8 @@ void LazyValueInfoWrapperPass::releaseMemory() { Info.releaseMemory(); }
LazyValueInfo LazyValueAnalysis::run(Function &F,
FunctionAnalysisManager &FAM) {
auto &AC = FAM.getResult<AssumptionAnalysis>(F);
- auto &TLI = FAM.getResult<TargetLibraryAnalysis>(F);
- return LazyValueInfo(&AC, &F.getParent()->getDataLayout(), &TLI);
+ return LazyValueInfo(&AC, &F.getParent()->getDataLayout());
}
/// Returns true if we can statically tell that this value will never be a
@@ -1714,11 +1712,11 @@ ConstantRange LazyValueInfo::getConstantRangeOnEdge(Value *V,
static LazyValueInfo::Tristate
getPredicateResult(unsigned Pred, Constant *C, const ValueLatticeElement &Val,
- const DataLayout &DL, TargetLibraryInfo *TLI) {
+ const DataLayout &DL) {
// If we know the value is a constant, evaluate the conditional.
Constant *Res = nullptr;
if (Val.isConstant()) {
- Res = ConstantFoldCompareInstOperands(Pred, Val.getConstant(), C, DL, TLI);
+ Res = ConstantFoldCompareInstOperands(Pred, Val.getConstant(), C, DL);
if (ConstantInt *ResCI = dyn_cast_or_null<ConstantInt>(Res))
return ResCI->isZero() ? LazyValueInfo::False : LazyValueInfo::True;
return LazyValueInfo::Unknown;
@@ -1759,15 +1757,13 @@ getPredicateResult(unsigned Pred, Constant *C, const ValueLatticeElement &Val,
if (Pred == ICmpInst::ICMP_EQ) {
// !C1 == C -> false iff C1 == C.
Res = ConstantFoldCompareInstOperands(ICmpInst::ICMP_NE,
- Val.getNotConstant(), C, DL,
- TLI);
+ Val.getNotConstant(), C, DL);
if (Res && Res->isNullValue())
return LazyValueInfo::False;
} else if (Pred == ICmpInst::ICMP_NE) {
// !C1 != C -> true iff C1 == C.
Res = ConstantFoldCompareInstOperands(ICmpInst::ICMP_NE,
- Val.getNotConstant(), C, DL,
- TLI);
+ Val.getNotConstant(), C, DL);
if (Res && Res->isNullValue())
return LazyValueInfo::True;
}
@@ -1787,7 +1783,7 @@ LazyValueInfo::getPredicateOnEdge(unsigned Pred, Value *V, Constant *C,
ValueLatticeElement Result =
getOrCreateImpl(M).getValueOnEdge(V, FromBB, ToBB, CxtI);
- return getPredicateResult(Pred, C, Result, M->getDataLayout(), TLI);
+ return getPredicateResult(Pred, C, Result, M->getDataLayout());
}
LazyValueInfo::Tristate
@@ -1811,7 +1807,7 @@ LazyValueInfo::getPredicateAt(unsigned Pred, Value *V, Constant *C,
ValueLatticeElement Result =
UseBlockValue ? Impl.getValueInBlock(V, CxtI->getParent(), CxtI)
: Impl.getValueAt(V, CxtI);
- Tristate Ret = getPredicateResult(Pred, C, Result, DL, TLI);
+ Tristate Ret = getPredicateResult(Pred, C, Result, DL);
if (Ret != Unknown)
return Ret;
More information about the llvm-commits
mailing list