[llvm] [RFC][DataLayout] Add null pointer value infrastructure (PR #183207)
Alexander Richardson via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 27 14:49:28 PDT 2026
================
@@ -756,9 +800,21 @@ void DataLayout::setPointerSpec(uint32_t AddrSpace, uint32_t BitWidth,
I->HasUnstableRepresentation = HasUnstableRepr;
I->HasExternalState = HasExternalState;
I->AddrSpaceName = AddrSpaceName.str();
+ I->NullPtrValue = std::move(NullPtrValue);
}
}
+APInt DataLayout::getNullPtrValue(unsigned AS) const {
+ auto I = lower_bound(PointerSpecs, AS, LessPointerAddrSpace());
+ if (I != PointerSpecs.end() && I->AddrSpace == AS && I->NullPtrValue)
+ return *I->NullPtrValue;
+
+ unsigned BitWidth = getPointerSizeInBits(AS);
+ if (DefaultNullPtrValue->isZero())
+ return APInt::getZero(BitWidth);
+ return APInt::getAllOnes(BitWidth);
----------------
arichardson wrote:
Would it make sense to change this to sign-extend? Doesn't really make it much shorter though.
https://github.com/llvm/llvm-project/pull/183207
More information about the llvm-commits
mailing list