Skip to content

Commit bfebadc

Browse files
committed
[LVI] Don't require DataLayout in getConstantRangeOrFull() (NFC)
We're only working on integers here, so we don't need DataLayout to determine the width.
1 parent ed4194b commit bfebadc

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

llvm/lib/Analysis/LazyValueInfo.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -802,10 +802,11 @@ void LazyValueInfoImpl::intersectAssumeOrGuardBlockValueConstantRange(
802802
}
803803

804804
static ConstantRange getConstantRangeOrFull(const ValueLatticeElement &Val,
805-
Type *Ty, const DataLayout &DL) {
805+
Type *Ty) {
806+
assert(Ty->isIntOrIntVectorTy() && "Must be integer type");
806807
if (Val.isConstantRange(/*UndefAllowed*/ false))
807808
return Val.getConstantRange();
808-
return ConstantRange::getFull(DL.getTypeSizeInBits(Ty));
809+
return ConstantRange::getFull(Ty->getScalarSizeInBits());
809810
}
810811

811812
std::optional<ValueLatticeElement>
@@ -825,9 +826,9 @@ LazyValueInfoImpl::solveBlockValueSelect(SelectInst *SI, BasicBlock *BB) {
825826

826827
if (TrueVal.isConstantRange() || FalseVal.isConstantRange()) {
827828
const ConstantRange &TrueCR =
828-
getConstantRangeOrFull(TrueVal, SI->getType(), DL);
829+
getConstantRangeOrFull(TrueVal, SI->getType());
829830
const ConstantRange &FalseCR =
830-
getConstantRangeOrFull(FalseVal, SI->getType(), DL);
831+
getConstantRangeOrFull(FalseVal, SI->getType());
831832
Value *LHS = nullptr;
832833
Value *RHS = nullptr;
833834
SelectPatternResult SPR = matchSelectPattern(SI, LHS, RHS);
@@ -898,7 +899,7 @@ LazyValueInfoImpl::getRangeFor(Value *V, Instruction *CxtI, BasicBlock *BB) {
898899
std::optional<ValueLatticeElement> OptVal = getBlockValue(V, BB, CxtI);
899900
if (!OptVal)
900901
return std::nullopt;
901-
return getConstantRangeOrFull(*OptVal, V->getType(), DL);
902+
return getConstantRangeOrFull(*OptVal, V->getType());
902903
}
903904

904905
std::optional<ValueLatticeElement>

0 commit comments

Comments
 (0)