Skip to content

Commit 0d3d445

Browse files
committed
[LVI] Remove unnecessary TLI dependency
Only used in ConstantFoldCompareInstOperands(), which does not actually use TLI.
1 parent 9519e3e commit 0d3d445

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

llvm/include/llvm/Analysis/LazyValueInfo.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ namespace llvm {
3232
friend class LazyValueInfoWrapperPass;
3333
AssumptionCache *AC = nullptr;
3434
const DataLayout *DL = nullptr;
35-
class TargetLibraryInfo *TLI = nullptr;
3635
LazyValueInfoImpl *PImpl = nullptr;
3736
LazyValueInfo(const LazyValueInfo &) = delete;
3837
void operator=(const LazyValueInfo &) = delete;
@@ -43,18 +42,16 @@ namespace llvm {
4342
public:
4443
~LazyValueInfo();
4544
LazyValueInfo() = default;
46-
LazyValueInfo(AssumptionCache *AC_, const DataLayout *DL_,
47-
TargetLibraryInfo *TLI_)
48-
: AC(AC_), DL(DL_), TLI(TLI_) {}
45+
LazyValueInfo(AssumptionCache *AC_, const DataLayout *DL_)
46+
: AC(AC_), DL(DL_) {}
4947
LazyValueInfo(LazyValueInfo &&Arg)
50-
: AC(Arg.AC), DL(Arg.DL), TLI(Arg.TLI), PImpl(Arg.PImpl) {
48+
: AC(Arg.AC), DL(Arg.DL), PImpl(Arg.PImpl) {
5149
Arg.PImpl = nullptr;
5250
}
5351
LazyValueInfo &operator=(LazyValueInfo &&Arg) {
5452
releaseMemory();
5553
AC = Arg.AC;
5654
DL = Arg.DL;
57-
TLI = Arg.TLI;
5855
PImpl = Arg.PImpl;
5956
Arg.PImpl = nullptr;
6057
return *this;

llvm/lib/Analysis/LazyValueInfo.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,7 +1566,6 @@ void LazyValueInfoImpl::threadEdge(BasicBlock *PredBB, BasicBlock *OldSucc,
15661566

15671567
bool LazyValueInfoWrapperPass::runOnFunction(Function &F) {
15681568
Info.AC = &getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
1569-
Info.TLI = &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(F);
15701569

15711570
if (auto *Impl = Info.getImpl())
15721571
Impl->clear();
@@ -1627,9 +1626,8 @@ void LazyValueInfoWrapperPass::releaseMemory() { Info.releaseMemory(); }
16271626
LazyValueInfo LazyValueAnalysis::run(Function &F,
16281627
FunctionAnalysisManager &FAM) {
16291628
auto &AC = FAM.getResult<AssumptionAnalysis>(F);
1630-
auto &TLI = FAM.getResult<TargetLibraryAnalysis>(F);
16311629

1632-
return LazyValueInfo(&AC, &F.getParent()->getDataLayout(), &TLI);
1630+
return LazyValueInfo(&AC, &F.getParent()->getDataLayout());
16331631
}
16341632

16351633
/// Returns true if we can statically tell that this value will never be a
@@ -1714,11 +1712,11 @@ ConstantRange LazyValueInfo::getConstantRangeOnEdge(Value *V,
17141712

17151713
static LazyValueInfo::Tristate
17161714
getPredicateResult(unsigned Pred, Constant *C, const ValueLatticeElement &Val,
1717-
const DataLayout &DL, TargetLibraryInfo *TLI) {
1715+
const DataLayout &DL) {
17181716
// If we know the value is a constant, evaluate the conditional.
17191717
Constant *Res = nullptr;
17201718
if (Val.isConstant()) {
1721-
Res = ConstantFoldCompareInstOperands(Pred, Val.getConstant(), C, DL, TLI);
1719+
Res = ConstantFoldCompareInstOperands(Pred, Val.getConstant(), C, DL);
17221720
if (ConstantInt *ResCI = dyn_cast_or_null<ConstantInt>(Res))
17231721
return ResCI->isZero() ? LazyValueInfo::False : LazyValueInfo::True;
17241722
return LazyValueInfo::Unknown;
@@ -1759,15 +1757,13 @@ getPredicateResult(unsigned Pred, Constant *C, const ValueLatticeElement &Val,
17591757
if (Pred == ICmpInst::ICMP_EQ) {
17601758
// !C1 == C -> false iff C1 == C.
17611759
Res = ConstantFoldCompareInstOperands(ICmpInst::ICMP_NE,
1762-
Val.getNotConstant(), C, DL,
1763-
TLI);
1760+
Val.getNotConstant(), C, DL);
17641761
if (Res && Res->isNullValue())
17651762
return LazyValueInfo::False;
17661763
} else if (Pred == ICmpInst::ICMP_NE) {
17671764
// !C1 != C -> true iff C1 == C.
17681765
Res = ConstantFoldCompareInstOperands(ICmpInst::ICMP_NE,
1769-
Val.getNotConstant(), C, DL,
1770-
TLI);
1766+
Val.getNotConstant(), C, DL);
17711767
if (Res && Res->isNullValue())
17721768
return LazyValueInfo::True;
17731769
}
@@ -1787,7 +1783,7 @@ LazyValueInfo::getPredicateOnEdge(unsigned Pred, Value *V, Constant *C,
17871783
ValueLatticeElement Result =
17881784
getOrCreateImpl(M).getValueOnEdge(V, FromBB, ToBB, CxtI);
17891785

1790-
return getPredicateResult(Pred, C, Result, M->getDataLayout(), TLI);
1786+
return getPredicateResult(Pred, C, Result, M->getDataLayout());
17911787
}
17921788

17931789
LazyValueInfo::Tristate
@@ -1811,7 +1807,7 @@ LazyValueInfo::getPredicateAt(unsigned Pred, Value *V, Constant *C,
18111807
ValueLatticeElement Result =
18121808
UseBlockValue ? Impl.getValueInBlock(V, CxtI->getParent(), CxtI)
18131809
: Impl.getValueAt(V, CxtI);
1814-
Tristate Ret = getPredicateResult(Pred, C, Result, DL, TLI);
1810+
Tristate Ret = getPredicateResult(Pred, C, Result, DL);
18151811
if (Ret != Unknown)
18161812
return Ret;
18171813

0 commit comments

Comments
 (0)