Skip to content

[HLSL] inout/out ABI for array parameters #106917

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

Closed
Tracked by #67692
llvm-beanz opened this issue Sep 1, 2024 · 5 comments · Fixed by #111047
Closed
Tracked by #67692

[HLSL] inout/out ABI for array parameters #106917

llvm-beanz opened this issue Sep 1, 2024 · 5 comments · Fixed by #111047
Assignees
Labels
clang:codegen IR generation bugs: mangling, exceptions, etc. clang:frontend Language frontend issues, e.g. anything involving "Sema" HLSL HLSL Language Support

Comments

@llvm-beanz
Copy link
Collaborator

Basic inout and out parameter support is landed, however it doesn't currently work with ArrayParameterType arguments.

The following code should compile successfully:

void increment(inout int Arr[10]) {
  for (int I = 0; I < 10; I++)
    Arr[0] += 2;
}

export int call() {
  int A[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
  increment(A);
  return A[0];
}
@llvm-beanz llvm-beanz converted this from a draft issue Sep 1, 2024
@EugeneZelenko EugeneZelenko added HLSL HLSL Language Support and removed new issue labels Sep 1, 2024
@llvm-beanz
Copy link
Collaborator Author

Context: Array parameters are treated as a non-decaying array types. The current [in]out support incorrectly translates the parameter's base type to a restrict reference, which results in arrays being treated as arrays of references, instead of a reference to a non-decaying array.

We need to fix that and ensure that the code generation correctly handles the temporary values.

@spall
Copy link
Contributor

spall commented Sep 9, 2024

looking at this

@damyanp
Copy link
Contributor

damyanp commented Sep 23, 2024

Blocked on #109043.

@damyanp damyanp moved this to Active in HLSL Support Oct 9, 2024
@damyanp damyanp moved this from Active to Reviewing in HLSL Support Oct 10, 2024
spall added a commit that referenced this issue Dec 4, 2024
Get inout/out parameters working for HLSL Arrays.
Utilizes the fix from #109323, and corrects the assignment behavior
slightly to allow for Non-LValues on the RHS.
Closes #106917

---------

Co-authored-by: Chris B <[email protected]>
@github-project-automation github-project-automation bot moved this from Needs Review to Closed in HLSL Support Dec 4, 2024
@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:codegen IR generation bugs: mangling, exceptions, etc. labels Dec 4, 2024
@llvmbot
Copy link
Member

llvmbot commented Dec 4, 2024

@llvm/issue-subscribers-clang-codegen

Author: Chris B (llvm-beanz)

Basic `inout` and `out` parameter support is landed, however it doesn't currently work with `ArrayParameterType` arguments.

The following code should compile successfully:

void increment(inout int Arr[10]) {
  for (int I = 0; I &lt; 10; I++)
    Arr[0] += 2;
}

export int call() {
  int A[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
  increment(A);
  return A[0];
}

@llvmbot
Copy link
Member

llvmbot commented Dec 4, 2024

@llvm/issue-subscribers-clang-frontend

Author: Chris B (llvm-beanz)

Basic `inout` and `out` parameter support is landed, however it doesn't currently work with `ArrayParameterType` arguments.

The following code should compile successfully:

void increment(inout int Arr[10]) {
  for (int I = 0; I &lt; 10; I++)
    Arr[0] += 2;
}

export int call() {
  int A[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
  increment(A);
  return A[0];
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:codegen IR generation bugs: mangling, exceptions, etc. clang:frontend Language frontend issues, e.g. anything involving "Sema" HLSL HLSL Language Support
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants