From ac540cb0fe3462d91ab41f0f16c8d5a39a7dd5cb Mon Sep 17 00:00:00 2001 From: Aaron Puchert Date: Tue, 14 Apr 2020 13:32:43 +0200 Subject: [PATCH] [ValueLattice] Remove unused DataLayout parameter of mergeIn, NFC Reviewed By: fhahn, echristo Differential Revision: https://reviews.llvm.org/D78061 --- include/llvm/Analysis/ValueLattice.h | 2 +- lib/Analysis/LazyValueInfo.cpp | 8 ++++---- lib/Transforms/Scalar/SCCP.cpp | 8 ++++---- unittests/Analysis/ValueLatticeTest.cpp | 22 ++++++++-------------- 4 files changed, 17 insertions(+), 23 deletions(-) diff --git a/include/llvm/Analysis/ValueLattice.h b/include/llvm/Analysis/ValueLattice.h index b9ee103eb60..1c4683857f9 100644 --- a/include/llvm/Analysis/ValueLattice.h +++ b/include/llvm/Analysis/ValueLattice.h @@ -321,7 +321,7 @@ public: /// Updates this object to approximate both this object and RHS. Returns /// true if this object has been changed. - bool mergeIn(const ValueLatticeElement &RHS, const DataLayout &DL) { + bool mergeIn(const ValueLatticeElement &RHS) { if (RHS.isUnknown() || isOverdefined()) return false; if (RHS.isOverdefined()) { diff --git a/lib/Analysis/LazyValueInfo.cpp b/lib/Analysis/LazyValueInfo.cpp index 4ad1795f613..c2d0de3f15a 100644 --- a/lib/Analysis/LazyValueInfo.cpp +++ b/lib/Analysis/LazyValueInfo.cpp @@ -747,7 +747,7 @@ bool LazyValueInfoImpl::solveBlockValueNonLocal(ValueLatticeElement &BBLV, // Explore that input, then return here return false; - Result.mergeIn(EdgeResult, DL); + Result.mergeIn(EdgeResult); // If we hit overdefined, exit early. The BlockVals entry is already set // to overdefined. @@ -791,7 +791,7 @@ bool LazyValueInfoImpl::solveBlockValuePHINode(ValueLatticeElement &BBLV, // Explore that input, then return here return false; - Result.mergeIn(EdgeResult, DL); + Result.mergeIn(EdgeResult); // If we hit overdefined, exit early. The BlockVals entry is already set // to overdefined. @@ -989,8 +989,8 @@ bool LazyValueInfoImpl::solveBlockValueSelect(ValueLatticeElement &BBLV, } ValueLatticeElement Result; // Start Undefined. - Result.mergeIn(TrueVal, DL); - Result.mergeIn(FalseVal, DL); + Result.mergeIn(TrueVal); + Result.mergeIn(FalseVal); BBLV = Result; return true; } diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp index 0551120daec..9cb7f069548 100644 --- a/lib/Transforms/Scalar/SCCP.cpp +++ b/lib/Transforms/Scalar/SCCP.cpp @@ -409,7 +409,7 @@ private: markOverdefined(IV, V); return true; } - if (IV.mergeIn(MergeWithV, DL)) { + if (IV.mergeIn(MergeWithV)) { pushToWorkList(IV, V); LLVM_DEBUG(dbgs() << "Merged " << MergeWithV << " into " << *V << " : " << IV << "\n"); @@ -743,7 +743,7 @@ void SCCPSolver::visitPHINode(PHINode &PN) { continue; ValueLatticeElement &Res = getValueState(&PN); - Changed |= Res.mergeIn(IV, DL); + Changed |= Res.mergeIn(IV); if (Res.isOverdefined()) break; } @@ -909,8 +909,8 @@ void SCCPSolver::visitSelectInst(SelectInst &I) { ValueLatticeElement TVal = getValueState(I.getTrueValue()); ValueLatticeElement FVal = getValueState(I.getFalseValue()); - bool Changed = ValueState[&I].mergeIn(TVal, DL); - Changed |= ValueState[&I].mergeIn(FVal, DL); + bool Changed = ValueState[&I].mergeIn(TVal); + Changed |= ValueState[&I].mergeIn(FVal); if (Changed) pushToWorkListMsg(ValueState[&I], &I); } diff --git a/unittests/Analysis/ValueLatticeTest.cpp b/unittests/Analysis/ValueLatticeTest.cpp index 10477ca0b57..8ee2cf1ba34 100644 --- a/unittests/Analysis/ValueLatticeTest.cpp +++ b/unittests/Analysis/ValueLatticeTest.cpp @@ -23,9 +23,6 @@ namespace { class ValueLatticeTest : public testing::Test { protected: LLVMContext Context; - Module M; - - ValueLatticeTest() : M("", Context) {} }; TEST_F(ValueLatticeTest, ValueLatticeGetters) { @@ -66,26 +63,26 @@ TEST_F(ValueLatticeTest, MergeIn) { // Merge to lattice values with equal integer constant. auto LV1 = ValueLatticeElement::get(C1); - EXPECT_FALSE(LV1.mergeIn(ValueLatticeElement::get(C1), M.getDataLayout())); + EXPECT_FALSE(LV1.mergeIn(ValueLatticeElement::get(C1))); EXPECT_TRUE(LV1.isConstantRange()); EXPECT_EQ(LV1.asConstantInteger().getValue().getLimitedValue(), 1U); // Merge LV1 with different integer constant. - EXPECT_TRUE(LV1.mergeIn(ValueLatticeElement::get(ConstantInt::get(I32Ty, 99)), - M.getDataLayout())); + EXPECT_TRUE( + LV1.mergeIn(ValueLatticeElement::get(ConstantInt::get(I32Ty, 99)))); EXPECT_TRUE(LV1.isConstantRange()); EXPECT_EQ(LV1.getConstantRange().getLower().getLimitedValue(), 1U); EXPECT_EQ(LV1.getConstantRange().getUpper().getLimitedValue(), 100U); // Merge constant range with same constant range. - EXPECT_FALSE(LV1.mergeIn(LV1, M.getDataLayout())); + EXPECT_FALSE(LV1.mergeIn(LV1)); EXPECT_TRUE(LV1.isConstantRange()); EXPECT_EQ(LV1.getConstantRange().getLower().getLimitedValue(), 1U); EXPECT_EQ(LV1.getConstantRange().getUpper().getLimitedValue(), 100U); // Merge LV1 in undefined value. ValueLatticeElement LV2; - EXPECT_TRUE(LV2.mergeIn(LV1, M.getDataLayout())); + EXPECT_TRUE(LV2.mergeIn(LV1)); EXPECT_TRUE(LV1.isConstantRange()); EXPECT_EQ(LV1.getConstantRange().getLower().getLimitedValue(), 1U); EXPECT_EQ(LV1.getConstantRange().getUpper().getLimitedValue(), 100U); @@ -94,13 +91,11 @@ TEST_F(ValueLatticeTest, MergeIn) { EXPECT_EQ(LV2.getConstantRange().getUpper().getLimitedValue(), 100U); // Merge LV1 with overdefined. - EXPECT_TRUE( - LV1.mergeIn(ValueLatticeElement::getOverdefined(), M.getDataLayout())); + EXPECT_TRUE(LV1.mergeIn(ValueLatticeElement::getOverdefined())); EXPECT_TRUE(LV1.isOverdefined()); // Merge overdefined with overdefined. - EXPECT_FALSE( - LV1.mergeIn(ValueLatticeElement::getOverdefined(), M.getDataLayout())); + EXPECT_FALSE(LV1.mergeIn(ValueLatticeElement::getOverdefined())); EXPECT_TRUE(LV1.isOverdefined()); } @@ -165,8 +160,7 @@ TEST_F(ValueLatticeTest, getCompareFloat) { EXPECT_TRUE(LV1.getCompare(CmpInst::FCMP_OGT, I1Ty, LV2)->isZeroValue()); EXPECT_TRUE( - LV1.mergeIn(ValueLatticeElement::get(ConstantFP::get(FloatTy, 2.2)), - M.getDataLayout())); + LV1.mergeIn(ValueLatticeElement::get(ConstantFP::get(FloatTy, 2.2)))); EXPECT_EQ(LV1.getCompare(CmpInst::FCMP_OEQ, I1Ty, LV2), nullptr); EXPECT_EQ(LV1.getCompare(CmpInst::FCMP_OGE, I1Ty, LV2), nullptr); EXPECT_EQ(LV1.getCompare(CmpInst::FCMP_OLE, I1Ty, LV2), nullptr);