[llvm] [WIP] Extend data layout to add non zero null value for address space. (PR #83109)

Pierre van Houtryve via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 1 03:02:04 PST 2024


================
@@ -299,6 +302,17 @@ class DataLayout {
     return ManglingMode == MM_WinCOFFX86;
   }
 
+  uint64_t getNonZeroValueForAddrSpace(uint64_t AddrSpace) {
+  auto It = AddrSpaceToNonZeroValueMap.find(AddrSpace);
+  if (It == AddrSpaceToNonZeroValueMap.end())
+    return 0x000000000;
+  return AddrSpaceToNonZeroValueMap[AddrSpace];
----------------
Pierre-vh wrote:

Rename this function to `getNullPointerValue` - whether that value is non-zero doesn't matter, the goal is that users should query the DL instead of assuming null == 0.
```suggestion
  uint64_t getNonZeroValueForAddrSpace(uint64_t AddrSpace) {
  auto It = AddrSpaceToNonZeroValueMap.find(AddrSpace);
  if (It == AddrSpaceToNonZeroValueMap.end())
    return 0;
  return It->second;
```

https://github.com/llvm/llvm-project/pull/83109


More information about the llvm-commits mailing list