[llvm] [NFCI][IR] Add optional DataLayout argument to zero and null value related APIs (PR #183208)
Shilei Tian via llvm-commits
llvm-commits at lists.llvm.org
Sat May 2 15:07:44 PDT 2026
================
@@ -52,7 +53,10 @@ class Constant : public User {
Constant(const Constant &) = delete;
/// Return true if this is the value that would be returned by getNullValue.
- LLVM_ABI bool isNullValue() const;
+ LLVM_ABI bool isNullValue(const DataLayout *DL = nullptr) const;
----------------
shiltian wrote:
> Checking for an all-null-pointer struct/array probably doesn't make a lot of sense (unlike an all-zero struct/array).
Hmm, I wonder what the expected behavior would be if we check `isNullValue` and `isZeroValue` on things like `{ i32, ptr, i32 }`.
> Though after null pointers are not longer always all-zero, I do wonder whether we should be using ConstantAggregateZero for a vector of null pointer, rather than using a ConstantPointerNull with vector type (similar to how we're in the process of switching ConstantFP/ConstantInt to natively support vector splats. This has recently been enabled by default for FP). This has the benefit that we can always represent a null pointer splat, regardless of whether the null pointer is all zero or not.
That is a great idea! I went ahead doing it right now. https://github.com/llvm/llvm-project/pull/195486
https://github.com/llvm/llvm-project/pull/183208
More information about the llvm-commits
mailing list