[clang] [llvm] [NVPTX] Update data layout string (PR #195178)

Shilei Tian via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 30 14:04:56 PDT 2026


https://github.com/shiltian created https://github.com/llvm/llvm-project/pull/195178

PR #183207 introduced support in the data layout for targets to specify the
actual nullptr value per address space. If not specified, it defaults to zero.
This PR updates the NVPTX data layout string accordingly.


>From 4287a7c64c9278320f1805f256c699c78e7f4a4b Mon Sep 17 00:00:00 2001
From: Shilei Tian <i at tianshilei.me>
Date: Thu, 30 Apr 2026 17:04:16 -0400
Subject: [PATCH] [NVPTX] Update data layout string

PR #183207 introduced support in the data layout for targets to specify the
actual nullptr value per address space. If not specified, it defaults to zero.
This PR updates the NVPTX data layout string accordingly.
---
 clang/test/CodeGen/target-data.c           | 4 ++--
 llvm/lib/TargetParser/TargetDataLayout.cpp | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/clang/test/CodeGen/target-data.c b/clang/test/CodeGen/target-data.c
index ffc37b49a1854..df2188411b1e1 100644
--- a/clang/test/CodeGen/target-data.c
+++ b/clang/test/CodeGen/target-data.c
@@ -144,11 +144,11 @@
 
 // RUN: %clang_cc1 -triple nvptx-unknown -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=NVPTX
-// NVPTX: target datalayout = "e-p:32:32-p6:32:32-p7:32:32-i64:64-i128:128-i256:256-v16:16-v32:32-n16:32:64"
+// NVPTX: target datalayout = "e-p:32:32-po3:32:32-po5:32:32-p6:32:32-po7:32:32-i64:64-i128:128-i256:256-v16:16-v32:32-n16:32:64"
 
 // RUN: %clang_cc1 -triple nvptx64-unknown -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=NVPTX64
-// NVPTX64: target datalayout = "e-p6:32:32-i64:64-i128:128-i256:256-v16:16-v32:32-n16:32:64"
+// NVPTX64: target datalayout = "e-po3:64:64-po5:64:64-p6:32:32-po7:64:64-i64:64-i128:128-i256:256-v16:16-v32:32-n16:32:64"
 
 // RUN: %clang_cc1 -triple r600-unknown -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=R600
diff --git a/llvm/lib/TargetParser/TargetDataLayout.cpp b/llvm/lib/TargetParser/TargetDataLayout.cpp
index a225b5b52b7f8..7f17ee087a38d 100644
--- a/llvm/lib/TargetParser/TargetDataLayout.cpp
+++ b/llvm/lib/TargetParser/TargetDataLayout.cpp
@@ -463,11 +463,11 @@ static std::string computeNVPTXDataLayout(const Triple &T, StringRef ABIName) {
   // Distributed Shared Memory (addrspace:7) follows shared memory
   // (addrspace:3).
   if (!Is64Bit)
-    Ret += "-p:32:32-p6:32:32-p7:32:32";
+    Ret += "-p:32:32-po3:32:32-po5:32:32-p6:32:32-po7:32:32";
   else if (ABIName == "shortptr")
-    Ret += "-p3:32:32-p4:32:32-p5:32:32-p6:32:32-p7:32:32";
+    Ret += "-po3:32:32-p4:32:32-po5:32:32-p6:32:32-po7:32:32";
   else
-    Ret += "-p6:32:32";
+    Ret += "-po3:64:64-po5:64:64-p6:32:32-po7:64:64";
 
   Ret += "-i64:64-i128:128-i256:256-v16:16-v32:32-n16:32:64";
 



More information about the cfe-commits mailing list