Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DXIL-style typed pointer handling. #7

Closed
wants to merge 1 commit into from

Conversation

maleadt
Copy link
Member

@maleadt maleadt commented Jun 5, 2024

Like #5, but similar to how the DXILWriter in LLVM proper currently works. I had high hopes for this approach, because it doesn't mutate the module, doesn't need to inject additional intrinsics or metadata. However after hacking on it for a day or two it seems like:

  • this requires much more (simple, but conflict prone) changes in the bitcode writer, making it difficult to maintain this across LLVM versions;
  • the approach is more fragile, as it keeps typed pointers around much more, which easily results in type mismatches in the serialized IR (see example below);
  • the approach doesn't seem to handle pointers all that well, presumably because it's been developed with shader inputs (HLSL) in mind.

An example of the fragility:

define i64 @kernel(ptr %0) {
  %box = alloca i64, i32 0, align 8
  %ifelse = select i1 false, ptr %box, ptr %0
  %value = load i64, ptr %ifelse, align 4
  ret i64 %value
}

The pointer analysis pass deduces that %box is i64*, but %box falls back to i8*, resulting in a crash when deserializing the select with two differently-typed pointer inputs

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