-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[HLSL] get inout/out ABI for array parameters working #111047
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
119def0
theoretically fix issue
spall 3231a7b
get inout working
spall 67ca255
fix tests cases broken by changes
spall fe046b9
new tests
spall cd022bb
fix clang format issues
spall b65b4ed
addressing pr comments
spall b663f00
get rid of unwanted temporary generated by EmitCall
spall 58577d2
Update clang/lib/CodeGen/CGCall.cpp
spall 0026eb8
Merge branch 'main' into issue-106917
spall File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump %s | FileCheck %s | ||
|
||
// CHECK-LABEL: increment | ||
void increment(inout int Arr[2]) { | ||
for (int I = 0; I < 2; I++) | ||
Arr[0] += 2; | ||
} | ||
|
||
// CHECK-LABEL: call | ||
// CHECK: CallExpr 0x{{.*}} {{.*}} 'void' | ||
// CHECK: ImplicitCastExpr 0x{{.*}} {{.*}} 'void (*)(inout int[2])' <FunctionToPointerDecay> | ||
// CHECK: DeclRefExpr 0x{{.*}} {{.*}} 'void (inout int[2])' lvalue Function 0x{{.*}} 'increment' 'void (inout int[2])' | ||
// CHECK: HLSLOutArgExpr 0x{{.*}} {{.*}} 'int[2]' lvalue inout | ||
// CHECK: OpaqueValueExpr [[A:0x.*]] {{.*}} 'int[2]' lvalue | ||
// CHECK: DeclRefExpr [[B:0x.*]] {{.*}} 'int[2]' lvalue Var [[E:0x.*]] 'A' 'int[2]' | ||
// CHECK: OpaqueValueExpr [[C:0x.*]] {{.*}} 'int[2]' lvalue | ||
// CHECK: ImplicitCastExpr [[D:0x.*]] {{.*}} 'int[2]' <HLSLArrayRValue> | ||
// CHECK: OpaqueValueExpr [[A]] {{.*}} 'int[2]' lvalue | ||
// CHECK: DeclRefExpr [[B]] {{.*}} 'int[2]' lvalue Var [[E]] 'A' 'int[2]' | ||
// CHECK: BinaryOperator 0x{{.*}} {{.*}} 'int[2]' lvalue '=' | ||
// CHECK: OpaqueValueExpr [[A]] {{.*}} 'int[2]' lvalue | ||
// CHECK: DeclRefExpr 0x{{.*}} {{.*}} 'int[2]' lvalue Var [[E]] 'A' 'int[2]' | ||
// CHECK: ImplicitCastExpr 0x{{.*}} {{.*}} 'int[2]' <HLSLArrayRValue> | ||
// CHECK: OpaqueValueExpr [[C]] {{.*}} 'int[2]' lvalue | ||
// CHECK: ImplicitCastExpr [[D]] {{.*}} 'int[2]' <HLSLArrayRValue> | ||
// CHECK: OpaqueValueExpr [[A]] {{.*}} 'int[2]' lvalue | ||
// CHECK: DeclRefExpr [[B]] {{.*}} 'int[2]' lvalue Var [[E]] 'A' 'int[2]' | ||
export int call() { | ||
int A[2] = { 0, 1 }; | ||
increment(A); | ||
return A[0]; | ||
} | ||
|
||
// CHECK-LABEL: fn2 | ||
void fn2(out int Arr[2]) { | ||
Arr[0] += 5; | ||
Arr[1] += 6; | ||
} | ||
|
||
// CHECK-LABEL: call2 | ||
// CHECK: CallExpr 0x{{.*}} {{.*}} 'void' | ||
// CHECK: ImplicitCastExpr 0x{{.*}} {{.*}} 'void (*)(out int[2])' <FunctionToPointerDecay> | ||
// CHECK: DeclRefExpr 0x{{.*}} {{.*}} 'void (out int[2])' lvalue Function 0x{{.*}} 'fn2' 'void (out int[2])' | ||
// CHECK: HLSLOutArgExpr 0x{{.*}} {{.*}} 'int[2]' lvalue out | ||
// CHECK: OpaqueValueExpr [[A:0x.*]] {{.*}} 'int[2]' lvalue | ||
// CHECK: DeclRefExpr [[B:0x.*]] {{.*}} 'int[2]' lvalue Var [[E:0x.*]] 'A' 'int[2]' | ||
// CHECK: OpaqueValueExpr [[C:0x.*]] {{.*}} 'int[2]' lvalue | ||
// CHECK: ImplicitCastExpr [[D:0x.*]] {{.*}} 'int[2]' <HLSLArrayRValue> | ||
// CHECK: OpaqueValueExpr [[A]] {{.*}} 'int[2]' lvalue | ||
// CHECK: DeclRefExpr [[B]] {{.*}} 'int[2]' lvalue Var [[E]] 'A' 'int[2]' | ||
// CHECK: BinaryOperator 0x{{.*}} {{.*}} 'int[2]' lvalue '=' | ||
// CHECK: OpaqueValueExpr [[A]] {{.*}} 'int[2]' lvalue | ||
// CHECK: DeclRefExpr [[B]] {{.*}} 'int[2]' lvalue Var [[E]] 'A' 'int[2]' | ||
// CHECK: ImplicitCastExpr 0x{{.*}} {{.*}} 'int[2]' <HLSLArrayRValue> | ||
// CHECK: OpaqueValueExpr [[C]] {{.*}} 'int[2]' lvalue | ||
// CHECK: ImplicitCastExpr [[D]] {{.*}} 'int[2]' <HLSLArrayRValue> | ||
// CHECK: OpaqueValueExpr [[A]] {{.*}} 'int[2]' lvalue | ||
// CHECK: DeclRefExpr [[B]] {{.*}} 'int[2]' lvalue Var [[E]] 'A' 'int[2]' | ||
export int call2() { | ||
int A[2] = { 0, 1 }; | ||
fn2(A); | ||
return 1; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this might be the wrong solution. If we instead make the parameter ABI
Direct
, it should end up doing effectively what you're accomplishing here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bleh... I spent some time today looking at this, and I think I've convinced myself that this is probably the simplest approach.
Without this you get a redundant copy because the cast that produces the ArrayParameterType. I have one small request to change the comment above.