[llvm] [WIP][IR][Constants] Change the semantic of `ConstantPointerNull` to represent an actual `nullptr` instead of a zero-value pointer (PR #166667)
Shilei Tian via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 6 11:48:12 PST 2025
================
@@ -369,7 +378,10 @@ bool Constant::containsConstantExpression() const {
return false;
}
-/// Constructor to create a '0' constant of arbitrary type.
+/// Constructor that creates a null constant of any type. For most types, this
+/// means a constant with value '0', but for pointer types, it represents a
+/// nullptr constant. A nullptr isn't always a zero-value pointer in certain
+/// address spaces on some targets.
Constant *Constant::getNullValue(Type *Ty) {
----------------
shiltian wrote:
Most of the places where a `ConstantPointerNull` is constructed is via `Constant::getNull`, so if we do `Constant::getNullPtrValue`, then that will require pretty much every place to be rewritten with a `if-else` based on their type, which I tried locally to some extent a couple of months ago, and it was not fun.
https://github.com/llvm/llvm-project/pull/166667
More information about the llvm-commits
mailing list