Skip to content

[Validation] Drill through chained GEPs for TGSM#8575

Open
llvm-beanz wants to merge 5 commits into
microsoft:mainfrom
llvm-beanz:8571
Open

[Validation] Drill through chained GEPs for TGSM#8575
llvm-beanz wants to merge 5 commits into
microsoft:mainfrom
llvm-beanz:8571

Conversation

@llvm-beanz

@llvm-beanz llvm-beanz commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

DXIL requires that TGSM pointers originate from a global variable in address space 3, and that any use of a pointer resolve to one and only one possible global variable.

In SM 6.9 with the introduction of native vectors to DXIL it is now possible to end up with a chain of GEP and/or bitcast instructions in the access chain for a TGSM pointer. To address this the validator needs to be able to walk up a TGSM chain to find the one unambiguous global.

Fixes #8571

Assisted by Claude Opus 4.7

DXIL requires that TGSM pointers originate from a global variable in
address space 3, and that any use of a pointer resolve to one and only
one possible global variable.

In SM 6.9 with the introduction of native vectors to DXIL it is now
possible to end up with a chain of GEP and/or bitcast instructions in
the access change for a TGSM pointer. To address this the validator
needs to be able to walk up a TGSM chain to find the one unambiguous
global.

Assisted by Claude Opus 4.7
Comment thread lib/DxilValidation/DxilValidation.cpp
Co-authored-by: Ashley Coleman <ascoleman@microsoft.com>
@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

✅ With the latest revision this PR passed the C/C++ code formatter.

@V-FEXrt

V-FEXrt commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator
some/path/lib/DxilValidation/DxilValidation.cpp:3314:24: error: no member named 'getOperand' in 'llvm::Value'
 3314 |             Ptr = Ptr->getOperand(0);

Looks like that change doesn't work because Value doesn't have a getOperand. I think casting to Instruction here should be good enough?

@llvm-beanz

Copy link
Copy Markdown
Collaborator Author

Looks like that change doesn't work because Value doesn't have a getOperand. I think casting to Instruction here should be good enough?

Sorry, moving too fast on things. You can't cast these to Instructions because they are in the Operator class hierarchy not Instruction.

@alsepkow

Copy link
Copy Markdown
Contributor

Did you mean 'access chain' in the description? Not change?

Comment thread lib/DxilValidation/DxilValidation.cpp Outdated
Comment on lines +5 to +6
; operators / instructions; any other construct (phi, select, etc.) in
; the middle of a chain leaves the ultimate base ambiguous and must be

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What if the phi or select is choosing between multiple GEPs or bitcasts that all point to the same global variable, just at different offsets? Would this still be valid DXIL?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I think it should be... but to be honest I can't even contrive how it would be possible to generate it from HLSL. Generating PHIs and selects on offsets is easy enough because you can just mess with the index, but the base address of an array isn't something HLSL allows you to conditionalize on.

@llvm-beanz

Copy link
Copy Markdown
Collaborator Author

Did you mean 'access chain' in the description? Not change?

🤦

Co-authored-by: Alex Sepkowski <alexsepkowski@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

[6.9] Validator failing to look through multi-level GEPs

4 participants