[llvm] 696cc20 - [LVI] Make UndefAllowed argument of getConstantRange() required
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 12 02:43:59 PST 2023
Author: Nikita Popov
Date: 2023-12-12T11:43:52+01:00
New Revision: 696cc20d4e748f2619f7398dcfe8f4ed8d0863ab
URL: https://github.com/llvm/llvm-project/commit/696cc20d4e748f2619f7398dcfe8f4ed8d0863ab
DIFF: https://github.com/llvm/llvm-project/commit/696cc20d4e748f2619f7398dcfe8f4ed8d0863ab.diff
LOG: [LVI] Make UndefAllowed argument of getConstantRange() required
For the two remaining uses that did not explicitly specify it,
set UndefAllowed=false. In both cases, I believe that treating
undef as a full range is the correct behavior.
Added:
Modified:
llvm/include/llvm/Analysis/LazyValueInfo.h
llvm/lib/Transforms/IPO/AttributorAttributes.cpp
llvm/lib/Transforms/Utils/LowerSwitch.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/LazyValueInfo.h b/llvm/include/llvm/Analysis/LazyValueInfo.h
index ead9f5f0225cd..bf2fc47fa642d 100644
--- a/llvm/include/llvm/Analysis/LazyValueInfo.h
+++ b/llvm/include/llvm/Analysis/LazyValueInfo.h
@@ -95,7 +95,7 @@ namespace llvm {
/// specified value at the specified instruction. This may only be called
/// on integer-typed Values.
ConstantRange getConstantRange(Value *V, Instruction *CxtI,
- bool UndefAllowed = true);
+ bool UndefAllowed);
/// Return the ConstantRange constraint that is known to hold for the value
/// at a specific use-site.
diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index cbe0a96976c3f..8e1f782f7cd81 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -9051,7 +9051,8 @@ struct AAValueConstantRangeImpl : AAValueConstantRange {
if (!LVI || !CtxI)
return getWorstState(getBitWidth());
return LVI->getConstantRange(&getAssociatedValue(),
- const_cast<Instruction *>(CtxI));
+ const_cast<Instruction *>(CtxI),
+ /*UndefAllowed*/ false);
}
/// Return true if \p CtxI is valid for querying outside analyses.
diff --git a/llvm/lib/Transforms/Utils/LowerSwitch.cpp b/llvm/lib/Transforms/Utils/LowerSwitch.cpp
index d1cdab7599c49..4131d36b572d7 100644
--- a/llvm/lib/Transforms/Utils/LowerSwitch.cpp
+++ b/llvm/lib/Transforms/Utils/LowerSwitch.cpp
@@ -412,7 +412,8 @@ void ProcessSwitchInst(SwitchInst *SI,
// TODO Shouldn't this create a signed range?
ConstantRange KnownBitsRange =
ConstantRange::fromKnownBits(Known, /*IsSigned=*/false);
- const ConstantRange LVIRange = LVI->getConstantRange(Val, SI);
+ const ConstantRange LVIRange =
+ LVI->getConstantRange(Val, SI, /*UndefAllowed*/ false);
ConstantRange ValRange = KnownBitsRange.intersectWith(LVIRange);
// We delegate removal of unreachable non-default cases to other passes. In
// the unlikely event that some of them survived, we just conservatively
More information about the llvm-commits
mailing list