[llvm] [WIP][IR][Constants] Change the semantic of `ConstantPointerNull` to represent an actual `nullptr` instead of a zero-value pointer (PR #166667)
Alexander Richardson via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 6 11:20:20 PST 2025
================
@@ -72,12 +72,21 @@ bool Constant::isNegativeZeroValue() const {
}
// Return true iff this constant is positive zero (floating point), negative
-// zero (floating point), or a null value.
+// zero (floating point), zero-value pointer, or a null value.
bool Constant::isZeroValue() const {
// Floating point values have an explicit -0.0 value.
if (const ConstantFP *CFP = dyn_cast<ConstantFP>(this))
return CFP->isZero();
+ // Zero value pointer is a constant expression of inttoptr(0).
+ if (const auto *CE = dyn_cast<ConstantExpr>(this)) {
+ if (CE->getOpcode() == Instruction::IntToPtr) {
----------------
arichardson wrote:
I initially thought we need to check the bitwidth matches, but since inttoptr zero-extends or truncates that doesn't matter. Maybe worth adding that as a comment?
https://github.com/llvm/llvm-project/pull/166667
More information about the llvm-commits
mailing list