mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-17 05:26:47 +00:00

HLSL constant sized array function parameters do not decay to pointers. Instead constant sized array types are preserved as unique types for overload resolution, template instantiation and name mangling. This implements the change by adding a new `ArrayParameterType` which represents a non-decaying `ConstantArrayType`. The new type behaves the same as `ConstantArrayType` except that it does not decay to a pointer. Values of `ConstantArrayType` in HLSL decay during overload resolution via a new `HLSLArrayRValue` cast to `ArrayParameterType`. `ArrayParamterType` values are passed indirectly by-value to functions in IR generation resulting in callee generated memcpy instructions. The behavior of HLSL function calls is documented in the [draft language specification](https://microsoft.github.io/hlsl-specs/specs/hlsl.pdf) under the Expr.Post.Call heading. Additionally the design of this implementation approach is documented in [Clang's documentation](https://clang.llvm.org/docs/HLSL/FunctionCalls.html) Resolves #70123
30 lines
1.3 KiB
HLSL
30 lines
1.3 KiB
HLSL
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library %s -verify
|
|
|
|
void fn(int I[5]); // #fn
|
|
void fn2(int I[3][3]); // #fn2
|
|
|
|
void call() {
|
|
float F[5];
|
|
double D[4];
|
|
int Long[9];
|
|
int Short[4];
|
|
int Same[5];
|
|
|
|
fn(F); // expected-error{{no matching function for call to 'fn'}}
|
|
// expected-note@#fn{{candidate function not viable: no known conversion from 'float[5]' to 'int[5]' for 1st argument}}
|
|
|
|
fn(D); // expected-error{{no matching function for call to 'fn'}}
|
|
// expected-note@#fn{{candidate function not viable: no known conversion from 'double[4]' to 'int[5]' for 1st argument}}
|
|
|
|
fn(Long); // expected-error{{no matching function for call to 'fn'}}
|
|
// expected-note@#fn{{candidate function not viable: no known conversion from 'int[9]' to 'int[5]' for 1st argument}}
|
|
|
|
fn(Short); // expected-error{{no matching function for call to 'fn'}}
|
|
// expected-note@#fn{{candidate function not viable: no known conversion from 'int[4]' to 'int[5]' for 1st argument}}
|
|
|
|
fn(Same); // totally fine, nothing to see here.
|
|
|
|
fn2(Long); // expected-error{{no matching function for call to 'fn2'}}
|
|
// expected-note@#fn2{{candidate function not viable: no known conversion from 'int[9]' to 'int[3][3]' for 1st argument}}
|
|
}
|