Skip to content

Raising: drop accesses through null buffers - #3010

Open
wsmoses wants to merge 3 commits into
pb/buffer-normalizationsfrom
pb/null-buffers
Open

Raising: drop accesses through null buffers#3010
wsmoses wants to merge 3 commits into
pb/buffer-normalizationsfrom
pb/null-buffers

Conversation

@wsmoses

@wsmoses wsmoses commented Aug 28, 2026

Copy link
Copy Markdown
Member

Stacks on #3006 and includes #2992's null-select fold (will rebase when those merge).

mfem's staging helpers return null for empty buffers, so a captured device pointer can arrive as a null base pointer — directly, hidden behind offset arithmetic in a select arm (select(p, gep(buf, i), gep(null, i))), or as mixed-typed views of the null (an empty Ahat_ii viewed as both ?xi32 pivots and ?xf64 data). Every access through it sits on a path that can only fault: loads read as zero, stores vanish, and the null never has to become a kernel argument.

Part of #2968 (hybridization/derefmat triage).

🤖 Generated with Claude Code

https://claude.ai/code/session_016zErYp7upmqr4NHfhod9UD

wsmoses and others added 3 commits August 27, 2026 10:23
Staging helpers (mfem's Read/Write) return null for empty buffers, so a
captured device pointer reaches the kernel as select(size > 0, ptr, null)
and the raising fails on the select. When the pointer's value is only
ever consumed as the address of a memory access, the null arm can only
fault, so the select collapses to the real pointer. Pointers whose value
is observed directly (compared, cast to int, stored as data, passed to a
call) are left alone.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016zErYp7upmqr4NHfhod9UD
# Conflicts:
#	src/enzyme_ad/jax/Passes/AffineToStableHLORaising.cpp
An empty optional buffer arrives as a null base pointer - directly,
behind offset arithmetic in a select arm, or as a mixed-typed view of
the null. Every access through it sits on a path that can only fault:
loads read as zero, stores vanish, and the null never has to become a
kernel argument.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016zErYp7upmqr4NHfhod9UD
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.

1 participant