Skip to content

[RFC][NVPTX] Update data layout string to include null pointer value spec - #195178

Closed
shiltian wants to merge 1 commit into
mainfrom
users/shiltian/nvptx-datalayout-string
Closed

[RFC][NVPTX] Update data layout string to include null pointer value spec#195178
shiltian wants to merge 1 commit into
mainfrom
users/shiltian/nvptx-datalayout-string

Conversation

@shiltian

Copy link
Copy Markdown
Contributor

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.

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.
@shiltian

shiltian commented Apr 30, 2026

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by sgh.

@shiltian
shiltian requested review from AlexMaclean, Artem-B and rnk April 30, 2026 21:05
@shiltian

Copy link
Copy Markdown
Contributor Author

Since I don't really work on NVPTX backend, I don't know if this PR is correct. Please let me know.

// 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"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General question -- how did we arrive at the conclusion that these AS should use all-ones nullptr?

I do not think I've seen it documented publicly for NVIDIA GPUs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's my educated guess 🙂

  • AMDGPU uses all-ones for nullptr in AS 3 and 5, and we happen to use those address spaces with similar semantics.
  • For AS 7, it looks like in LLVM IR the nullptr isn't represented as ptr addrspace(7) null, but rather as addrspacecast ptr null to addrspace(7), which suggests it isn't a zero value. Since we don't expect any other pattern right now, all-ones seems like the most reasonable assumption.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gonzalobg @AlexMaclean Any thoughts on what kind of nullptr makes sense for particular AS on NVIDIA GPUs?

@shiltian shiltian changed the title [NVPTX] Update data layout string [NVPTX] Update data layout string to include null pointer value spec Apr 30, 2026
@shiltian shiltian changed the title [NVPTX] Update data layout string to include null pointer value spec [RFC][NVPTX] Update data layout string to include null pointer value spec May 1, 2026
@shiltian

shiltian commented May 2, 2026

Copy link
Copy Markdown
Contributor Author

I'm going to close this PR at this moment, since the infrastructure is not ready so to update them right now will cause some inconsistency, but please do let me know what ASs have non-zero null pointer value such that I can update them locally to test my changes.

FYI, #183215 this PR stack shows where we are heading.

@shiltian shiltian closed this May 2, 2026
@shiltian
shiltian deleted the users/shiltian/nvptx-datalayout-string branch May 2, 2026 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants