238 changes: 119 additions & 119 deletions clang/test/SemaHLSL/Availability/avail-diag-default-compute.hlsl
Original file line number Diff line number Diff line change
@@ -1,119 +1,119 @@
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute \
// RUN: -fsyntax-only -verify %s

__attribute__((availability(shadermodel, introduced = 6.5)))
float fx(float); // #fx

__attribute__((availability(shadermodel, introduced = 6.6)))
half fx(half); // #fx_half

__attribute__((availability(shadermodel, introduced = 5.0, environment = pixel)))
__attribute__((availability(shadermodel, introduced = 6.5, environment = compute)))
float fy(float); // #fy

__attribute__((availability(shadermodel, introduced = 5.0, environment = pixel)))
__attribute__((availability(shadermodel, introduced = 6.5, environment = mesh)))
float fz(float); // #fz

float also_alive(float f) {
// expected-error@#also_alive_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
// expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
float A = fx(f); // #also_alive_fx_call
// expected-error@#also_alive_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}
// expected-note@#fy {{'fy' has been marked as being introduced in Shader Model 6.5 in compute environment here, but the deployment target is Shader Model 6.0 compute environment}}
float B = fy(f); // #also_alive_fy_call
// expected-error@#also_alive_fz_call {{'fz' is unavailable}}
// expected-note@#fz {{'fz' has been marked as being introduced in Shader Model 6.5 in mesh environment here, but the deployment target is Shader Model 6.0 compute environment}}
float C = fz(f); // #also_alive_fz_call
return 0;
}

float alive(float f) {
// expected-error@#alive_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
// expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
float A = fx(f); // #alive_fx_call
// expected-error@#alive_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}
// expected-note@#fy {{'fy' has been marked as being introduced in Shader Model 6.5 in compute environment here, but the deployment target is Shader Model 6.0 compute environment}}
float B = fy(f); // #alive_fy_call
// expected-error@#alive_fz_call {{'fz' is unavailable}}
// expected-note@#fz {{'fz' has been marked as being introduced in Shader Model 6.5 in mesh environment here, but the deployment target is Shader Model 6.0 compute environment}}
float C = fz(f); // #alive_fz_call

return also_alive(f);
}

float also_dead(float f) {
// unreachable code - no errors expected
float A = fx(f);
float B = fy(f);
float C = fz(f);
return 0;
}

float dead(float f) {
// unreachable code - no errors expected
float A = fx(f);
float B = fy(f);
float C = fz(f);

return also_dead(f);
}

template<typename T>
T aliveTemp(T f) {
// expected-error@#aliveTemp_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
// expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
float A = fx(f); // #aliveTemp_fx_call
// expected-error@#aliveTemp_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}
// expected-note@#fy {{'fy' has been marked as being introduced in Shader Model 6.5 in compute environment here, but the deployment target is Shader Model 6.0 compute environment}}
float B = fy(f); // #aliveTemp_fy_call
// expected-error@#aliveTemp_fz_call {{'fz' is unavailable}}
// expected-note@#fz {{'fz' has been marked as being introduced in Shader Model 6.5 in mesh environment here, but the deployment target is Shader Model 6.0 compute environment}}
float C = fz(f); // #aliveTemp_fz_call
return 0;
}

template<typename T> T aliveTemp2(T f) {
// expected-error@#aliveTemp2_fx_call {{'fx' is only available on Shader Model 6.6 or newer}}
// expected-note@#fx_half {{'fx' has been marked as being introduced in Shader Model 6.6 here, but the deployment target is Shader Model 6.0}}
// expected-error@#aliveTemp2_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
// expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
return fx(f); // #aliveTemp2_fx_call
}

half test(half x) {
return aliveTemp2(x);
}

float test(float x) {
return aliveTemp2(x);
}

class MyClass
{
float F;
float makeF() {
// expected-error@#MyClass_makeF_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
// expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
float A = fx(F); // #MyClass_makeF_fx_call
// expected-error@#MyClass_makeF_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}
// expected-note@#fy {{'fy' has been marked as being introduced in Shader Model 6.5 in compute environment here, but the deployment target is Shader Model 6.0 compute environment}}
float B = fy(F); // #MyClass_makeF_fy_call
// expected-error@#MyClass_makeF_fz_call {{'fz' is unavailable}}
// expected-note@#fz {{'fz' has been marked as being introduced in Shader Model 6.5 in mesh environment here, but the deployment target is Shader Model 6.0 compute environment}}
float C = fz(F); // #MyClass_makeF_fz_call
return 0;
}
};

[numthreads(4,1,1)]
float main() {
float f = 3;
MyClass C = { 1.0f };
float a = alive(f);
float b = aliveTemp<float>(f); // #aliveTemp_inst
float c = C.makeF();
float d = test((float)1.0);
float e = test((half)1.0);
return a * b * c;
}
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute \
// RUN: -fsyntax-only -verify %s

__attribute__((availability(shadermodel, introduced = 6.5)))
float fx(float); // #fx

__attribute__((availability(shadermodel, introduced = 6.6)))
half fx(half); // #fx_half

__attribute__((availability(shadermodel, introduced = 5.0, environment = pixel)))
__attribute__((availability(shadermodel, introduced = 6.5, environment = compute)))
float fy(float); // #fy

__attribute__((availability(shadermodel, introduced = 5.0, environment = pixel)))
__attribute__((availability(shadermodel, introduced = 6.5, environment = mesh)))
float fz(float); // #fz

float also_alive(float f) {
// expected-error@#also_alive_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
// expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
float A = fx(f); // #also_alive_fx_call
// expected-error@#also_alive_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}
// expected-note@#fy {{'fy' has been marked as being introduced in Shader Model 6.5 in compute environment here, but the deployment target is Shader Model 6.0 compute environment}}
float B = fy(f); // #also_alive_fy_call
// expected-error@#also_alive_fz_call {{'fz' is unavailable}}
// expected-note@#fz {{'fz' has been marked as being introduced in Shader Model 6.5 in mesh environment here, but the deployment target is Shader Model 6.0 compute environment}}
float C = fz(f); // #also_alive_fz_call
return 0;
}

float alive(float f) {
// expected-error@#alive_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
// expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
float A = fx(f); // #alive_fx_call
// expected-error@#alive_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}
// expected-note@#fy {{'fy' has been marked as being introduced in Shader Model 6.5 in compute environment here, but the deployment target is Shader Model 6.0 compute environment}}
float B = fy(f); // #alive_fy_call
// expected-error@#alive_fz_call {{'fz' is unavailable}}
// expected-note@#fz {{'fz' has been marked as being introduced in Shader Model 6.5 in mesh environment here, but the deployment target is Shader Model 6.0 compute environment}}
float C = fz(f); // #alive_fz_call

return also_alive(f);
}

float also_dead(float f) {
// unreachable code - no errors expected
float A = fx(f);
float B = fy(f);
float C = fz(f);
return 0;
}

float dead(float f) {
// unreachable code - no errors expected
float A = fx(f);
float B = fy(f);
float C = fz(f);

return also_dead(f);
}

template<typename T>
T aliveTemp(T f) {
// expected-error@#aliveTemp_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
// expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
float A = fx(f); // #aliveTemp_fx_call
// expected-error@#aliveTemp_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}
// expected-note@#fy {{'fy' has been marked as being introduced in Shader Model 6.5 in compute environment here, but the deployment target is Shader Model 6.0 compute environment}}
float B = fy(f); // #aliveTemp_fy_call
// expected-error@#aliveTemp_fz_call {{'fz' is unavailable}}
// expected-note@#fz {{'fz' has been marked as being introduced in Shader Model 6.5 in mesh environment here, but the deployment target is Shader Model 6.0 compute environment}}
float C = fz(f); // #aliveTemp_fz_call
return 0;
}

template<typename T> T aliveTemp2(T f) {
// expected-error@#aliveTemp2_fx_call {{'fx' is only available on Shader Model 6.6 or newer}}
// expected-note@#fx_half {{'fx' has been marked as being introduced in Shader Model 6.6 here, but the deployment target is Shader Model 6.0}}
// expected-error@#aliveTemp2_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
// expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
return fx(f); // #aliveTemp2_fx_call
}

half test(half x) {
return aliveTemp2(x);
}

float test(float x) {
return aliveTemp2(x);
}

class MyClass
{
float F;
float makeF() {
// expected-error@#MyClass_makeF_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
// expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
float A = fx(F); // #MyClass_makeF_fx_call
// expected-error@#MyClass_makeF_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}
// expected-note@#fy {{'fy' has been marked as being introduced in Shader Model 6.5 in compute environment here, but the deployment target is Shader Model 6.0 compute environment}}
float B = fy(F); // #MyClass_makeF_fy_call
// expected-error@#MyClass_makeF_fz_call {{'fz' is unavailable}}
// expected-note@#fz {{'fz' has been marked as being introduced in Shader Model 6.5 in mesh environment here, but the deployment target is Shader Model 6.0 compute environment}}
float C = fz(F); // #MyClass_makeF_fz_call
return 0;
}
};

[numthreads(4,1,1)]
float main() {
float f = 3;
MyClass C = { 1.0f };
float a = alive(f);
float b = aliveTemp<float>(f); // #aliveTemp_inst
float c = C.makeF();
float d = test((float)1.0);
float e = test((half)1.0);
return a * b * c;
}
360 changes: 180 additions & 180 deletions clang/test/SemaHLSL/Availability/avail-diag-default-lib.hlsl

Large diffs are not rendered by default.

238 changes: 119 additions & 119 deletions clang/test/SemaHLSL/Availability/avail-diag-relaxed-compute.hlsl
Original file line number Diff line number Diff line change
@@ -1,119 +1,119 @@
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute \
// RUN: -fsyntax-only -Wno-error=hlsl-availability -verify %s

__attribute__((availability(shadermodel, introduced = 6.5)))
float fx(float); // #fx

__attribute__((availability(shadermodel, introduced = 6.6)))
half fx(half); // #fx_half

__attribute__((availability(shadermodel, introduced = 5.0, environment = pixel)))
__attribute__((availability(shadermodel, introduced = 6.5, environment = compute)))
float fy(float); // #fy

__attribute__((availability(shadermodel, introduced = 5.0, environment = pixel)))
__attribute__((availability(shadermodel, introduced = 6.5, environment = mesh)))
float fz(float); // #fz

float also_alive(float f) {
// expected-warning@#also_alive_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
// expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
float A = fx(f); // #also_alive_fx_call
// expected-warning@#also_alive_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}
// expected-note@#fy {{'fy' has been marked as being introduced in Shader Model 6.5 in compute environment here, but the deployment target is Shader Model 6.0 compute environment}}
float B = fy(f); // #also_alive_fy_call
// expected-warning@#also_alive_fz_call {{'fz' is unavailable}}
// expected-note@#fz {{'fz' has been marked as being introduced in Shader Model 6.5 in mesh environment here, but the deployment target is Shader Model 6.0 compute environment}}
float C = fz(f); // #also_alive_fz_call
return 0;
}

float alive(float f) {
// expected-warning@#alive_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
// expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
float A = fx(f); // #alive_fx_call
// expected-warning@#alive_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}
// expected-note@#fy {{'fy' has been marked as being introduced in Shader Model 6.5 in compute environment here, but the deployment target is Shader Model 6.0 compute environment}}
float B = fy(f); // #alive_fy_call
// expected-warning@#alive_fz_call {{'fz' is unavailable}}
// expected-note@#fz {{'fz' has been marked as being introduced in Shader Model 6.5 in mesh environment here, but the deployment target is Shader Model 6.0 compute environment}}
float C = fz(f); // #alive_fz_call

return also_alive(f);
}

float also_dead(float f) {
// unreachable code - no errors expected
float A = fx(f);
float B = fy(f);
float C = fz(f);
return 0;
}

float dead(float f) {
// unreachable code - no errors expected
float A = fx(f);
float B = fy(f);
float C = fz(f);

return also_dead(f);
}

template<typename T>
T aliveTemp(T f) {
// expected-warning@#aliveTemp_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
// expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
float A = fx(f); // #aliveTemp_fx_call
// expected-warning@#aliveTemp_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}
// expected-note@#fy {{'fy' has been marked as being introduced in Shader Model 6.5 in compute environment here, but the deployment target is Shader Model 6.0 compute environment}}
float B = fy(f); // #aliveTemp_fy_call
// expected-warning@#aliveTemp_fz_call {{'fz' is unavailable}}
// expected-note@#fz {{'fz' has been marked as being introduced in Shader Model 6.5 in mesh environment here, but the deployment target is Shader Model 6.0 compute environment}}
float C = fz(f); // #aliveTemp_fz_call
return 0;
}

template<typename T> T aliveTemp2(T f) {
// expected-warning@#aliveTemp2_fx_call {{'fx' is only available on Shader Model 6.6 or newer}}
// expected-note@#fx_half {{'fx' has been marked as being introduced in Shader Model 6.6 here, but the deployment target is Shader Model 6.0}}
// expected-warning@#aliveTemp2_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
// expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
return fx(f); // #aliveTemp2_fx_call
}

half test(half x) {
return aliveTemp2(x);
}

float test(float x) {
return aliveTemp2(x);
}

class MyClass
{
float F;
float makeF() {
// expected-warning@#MyClass_makeF_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
// expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
float A = fx(F); // #MyClass_makeF_fx_call
// expected-warning@#MyClass_makeF_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}
// expected-note@#fy {{'fy' has been marked as being introduced in Shader Model 6.5 in compute environment here, but the deployment target is Shader Model 6.0 compute environment}}
float B = fy(F); // #MyClass_makeF_fy_call
// expected-warning@#MyClass_makeF_fz_call {{'fz' is unavailable}}
// expected-note@#fz {{'fz' has been marked as being introduced in Shader Model 6.5 in mesh environment here, but the deployment target is Shader Model 6.0 compute environment}}
float C = fz(F); // #MyClass_makeF_fz_call
return 0;
}
};

[numthreads(4,1,1)]
float main() {
float f = 3;
MyClass C = { 1.0f };
float a = alive(f);
float b = aliveTemp<float>(f); // #aliveTemp_inst
float c = C.makeF();
float d = test((float)1.0);
float e = test((half)1.0);
return a * b * c;
}
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute \
// RUN: -fsyntax-only -Wno-error=hlsl-availability -verify %s

__attribute__((availability(shadermodel, introduced = 6.5)))
float fx(float); // #fx

__attribute__((availability(shadermodel, introduced = 6.6)))
half fx(half); // #fx_half

__attribute__((availability(shadermodel, introduced = 5.0, environment = pixel)))
__attribute__((availability(shadermodel, introduced = 6.5, environment = compute)))
float fy(float); // #fy

__attribute__((availability(shadermodel, introduced = 5.0, environment = pixel)))
__attribute__((availability(shadermodel, introduced = 6.5, environment = mesh)))
float fz(float); // #fz

float also_alive(float f) {
// expected-warning@#also_alive_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
// expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
float A = fx(f); // #also_alive_fx_call
// expected-warning@#also_alive_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}
// expected-note@#fy {{'fy' has been marked as being introduced in Shader Model 6.5 in compute environment here, but the deployment target is Shader Model 6.0 compute environment}}
float B = fy(f); // #also_alive_fy_call
// expected-warning@#also_alive_fz_call {{'fz' is unavailable}}
// expected-note@#fz {{'fz' has been marked as being introduced in Shader Model 6.5 in mesh environment here, but the deployment target is Shader Model 6.0 compute environment}}
float C = fz(f); // #also_alive_fz_call
return 0;
}

float alive(float f) {
// expected-warning@#alive_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
// expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
float A = fx(f); // #alive_fx_call
// expected-warning@#alive_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}
// expected-note@#fy {{'fy' has been marked as being introduced in Shader Model 6.5 in compute environment here, but the deployment target is Shader Model 6.0 compute environment}}
float B = fy(f); // #alive_fy_call
// expected-warning@#alive_fz_call {{'fz' is unavailable}}
// expected-note@#fz {{'fz' has been marked as being introduced in Shader Model 6.5 in mesh environment here, but the deployment target is Shader Model 6.0 compute environment}}
float C = fz(f); // #alive_fz_call

return also_alive(f);
}

float also_dead(float f) {
// unreachable code - no errors expected
float A = fx(f);
float B = fy(f);
float C = fz(f);
return 0;
}

float dead(float f) {
// unreachable code - no errors expected
float A = fx(f);
float B = fy(f);
float C = fz(f);

return also_dead(f);
}

template<typename T>
T aliveTemp(T f) {
// expected-warning@#aliveTemp_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
// expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
float A = fx(f); // #aliveTemp_fx_call
// expected-warning@#aliveTemp_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}
// expected-note@#fy {{'fy' has been marked as being introduced in Shader Model 6.5 in compute environment here, but the deployment target is Shader Model 6.0 compute environment}}
float B = fy(f); // #aliveTemp_fy_call
// expected-warning@#aliveTemp_fz_call {{'fz' is unavailable}}
// expected-note@#fz {{'fz' has been marked as being introduced in Shader Model 6.5 in mesh environment here, but the deployment target is Shader Model 6.0 compute environment}}
float C = fz(f); // #aliveTemp_fz_call
return 0;
}

template<typename T> T aliveTemp2(T f) {
// expected-warning@#aliveTemp2_fx_call {{'fx' is only available on Shader Model 6.6 or newer}}
// expected-note@#fx_half {{'fx' has been marked as being introduced in Shader Model 6.6 here, but the deployment target is Shader Model 6.0}}
// expected-warning@#aliveTemp2_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
// expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
return fx(f); // #aliveTemp2_fx_call
}

half test(half x) {
return aliveTemp2(x);
}

float test(float x) {
return aliveTemp2(x);
}

class MyClass
{
float F;
float makeF() {
// expected-warning@#MyClass_makeF_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
// expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
float A = fx(F); // #MyClass_makeF_fx_call
// expected-warning@#MyClass_makeF_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}
// expected-note@#fy {{'fy' has been marked as being introduced in Shader Model 6.5 in compute environment here, but the deployment target is Shader Model 6.0 compute environment}}
float B = fy(F); // #MyClass_makeF_fy_call
// expected-warning@#MyClass_makeF_fz_call {{'fz' is unavailable}}
// expected-note@#fz {{'fz' has been marked as being introduced in Shader Model 6.5 in mesh environment here, but the deployment target is Shader Model 6.0 compute environment}}
float C = fz(F); // #MyClass_makeF_fz_call
return 0;
}
};

[numthreads(4,1,1)]
float main() {
float f = 3;
MyClass C = { 1.0f };
float a = alive(f);
float b = aliveTemp<float>(f); // #aliveTemp_inst
float c = C.makeF();
float d = test((float)1.0);
float e = test((half)1.0);
return a * b * c;
}
324 changes: 162 additions & 162 deletions clang/test/SemaHLSL/Availability/avail-diag-relaxed-lib.hlsl

Large diffs are not rendered by default.

256 changes: 128 additions & 128 deletions clang/test/SemaHLSL/Availability/avail-diag-strict-compute.hlsl
Original file line number Diff line number Diff line change
@@ -1,129 +1,129 @@
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute \
// RUN: -fhlsl-strict-availability -fsyntax-only -verify %s

__attribute__((availability(shadermodel, introduced = 6.5)))
float fx(float); // #fx

__attribute__((availability(shadermodel, introduced = 6.6)))
half fx(half); // #fx_half

__attribute__((availability(shadermodel, introduced = 5.0, environment = pixel)))
__attribute__((availability(shadermodel, introduced = 6.5, environment = compute)))
float fy(float); // #fy

__attribute__((availability(shadermodel, introduced = 5.0, environment = pixel)))
__attribute__((availability(shadermodel, introduced = 6.5, environment = mesh)))
float fz(float); // #fz

float also_alive(float f) {
// expected-error@#also_alive_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
// expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
float A = fx(f); // #also_alive_fx_call
// expected-error@#also_alive_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}
// expected-note@#fy {{'fy' has been marked as being introduced in Shader Model 6.5 in compute environment here, but the deployment target is Shader Model 6.0 compute environment}}
float B = fy(f); // #also_alive_fy_call
// expected-error@#also_alive_fz_call {{'fz' is unavailable}}
// expected-note@#fz {{'fz' has been marked as being introduced in Shader Model 6.5 in mesh environment here, but the deployment target is Shader Model 6.0 compute environment}}
float C = fz(f); // #also_alive_fz_call
return 0;
}

float alive(float f) {
// expected-error@#alive_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
// expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
float A = fx(f); // #alive_fx_call
// expected-error@#alive_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}
// expected-note@#fy {{'fy' has been marked as being introduced in Shader Model 6.5 in compute environment here, but the deployment target is Shader Model 6.0 compute environment}}
float B = fy(f); // #alive_fy_call
// expected-error@#alive_fz_call {{'fz' is unavailable}}
// expected-note@#fz {{'fz' has been marked as being introduced in Shader Model 6.5 in mesh environment here, but the deployment target is Shader Model 6.0 compute environment}}
float C = fz(f); // #alive_fz_call

return also_alive(f);
}

float also_dead(float f) {
// expected-error@#also_dead_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
// expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
float A = fx(f); // #also_dead_fx_call
// expected-error@#also_dead_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}
// expected-note@#fy {{'fy' has been marked as being introduced in Shader Model 6.5 in compute environment here, but the deployment target is Shader Model 6.0 compute environment}}
float B = fy(f); // #also_dead_fy_call
// expected-error@#also_dead_fz_call {{'fz' is unavailable}}
// expected-note@#fz {{'fz' has been marked as being introduced in Shader Model 6.5 in mesh environment here, but the deployment target is Shader Model 6.0 compute environment}}
float C = fz(f); // #also_dead_fz_call
return 0;
}

float dead(float f) {
// expected-error@#dead_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
// expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
float A = fx(f); // #dead_fx_call
// expected-error@#dead_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}
// expected-note@#fy {{'fy' has been marked as being introduced in Shader Model 6.5 in compute environment here, but the deployment target is Shader Model 6.0 compute environment}}
float B = fy(f); // #dead_fy_call
// expected-error@#dead_fz_call {{'fz' is unavailable}}
// expected-note@#fz {{'fz' has been marked as being introduced in Shader Model 6.5 in mesh environment here, but the deployment target is Shader Model 6.0 compute environment}}
float C = fz(f); // #dead_fz_call

return also_dead(f);
}

template<typename T>
T aliveTemp(T f) {
// expected-error@#aliveTemp_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
// expected-note@#aliveTemp_inst {{in instantiation of function template specialization 'aliveTemp<float>' requested here}}
// expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
float A = fx(f); // #aliveTemp_fx_call
// expected-error@#aliveTemp_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}
// expected-note@#fy {{'fy' has been marked as being introduced in Shader Model 6.5 in compute environment here, but the deployment target is Shader Model 6.0 compute environment}}
float B = fy(f); // #aliveTemp_fy_call
// expected-error@#aliveTemp_fz_call {{'fz' is unavailable}}
// expected-note@#fz {{'fz' has been marked as being introduced in Shader Model 6.5 in mesh environment here, but the deployment target is Shader Model 6.0 compute environment}}
float C = fz(f); // #aliveTemp_fz_call
return 0;
}

template<typename T> T aliveTemp2(T f) {
// expected-error@#aliveTemp2_fx_call {{'fx' is only available on Shader Model 6.6 or newer}}
// expected-note@#fx_half {{'fx' has been marked as being introduced in Shader Model 6.6 here, but the deployment target is Shader Model 6.0}}
// expected-error@#aliveTemp2_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
// expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
return fx(f); // #aliveTemp2_fx_call
}

half test(half x) {
return aliveTemp2(x); // expected-note {{in instantiation of function template specialization 'aliveTemp2<half>' requested here}}
}

float test(float x) {
return aliveTemp2(x); // expected-note {{in instantiation of function template specialization 'aliveTemp2<float>' requested here}}
}

class MyClass
{
float F;
float makeF() {
// expected-error@#MyClass_makeF_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
// expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
float A = fx(F); // #MyClass_makeF_fx_call
// expected-error@#MyClass_makeF_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}
// expected-note@#fy {{'fy' has been marked as being introduced in Shader Model 6.5 in compute environment here, but the deployment target is Shader Model 6.0 compute environment}}
float B = fy(F); // #MyClass_makeF_fy_call
// expected-error@#MyClass_makeF_fz_call {{'fz' is unavailable}}
// expected-note@#fz {{'fz' has been marked as being introduced in Shader Model 6.5 in mesh environment here, but the deployment target is Shader Model 6.0 compute environment}}
float C = fz(F); // #MyClass_makeF_fz_call
}
};

[numthreads(4,1,1)]
float main() {
float f = 3;
MyClass C = { 1.0f };
float a = alive(f);
float b = aliveTemp<float>(f); // #aliveTemp_inst
float c = C.makeF();
float d = test((float)1.0);
float e = test((half)1.0);
return a * b * c;
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute \
// RUN: -fhlsl-strict-availability -fsyntax-only -verify %s

__attribute__((availability(shadermodel, introduced = 6.5)))
float fx(float); // #fx

__attribute__((availability(shadermodel, introduced = 6.6)))
half fx(half); // #fx_half

__attribute__((availability(shadermodel, introduced = 5.0, environment = pixel)))
__attribute__((availability(shadermodel, introduced = 6.5, environment = compute)))
float fy(float); // #fy

__attribute__((availability(shadermodel, introduced = 5.0, environment = pixel)))
__attribute__((availability(shadermodel, introduced = 6.5, environment = mesh)))
float fz(float); // #fz

float also_alive(float f) {
// expected-error@#also_alive_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
// expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
float A = fx(f); // #also_alive_fx_call
// expected-error@#also_alive_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}
// expected-note@#fy {{'fy' has been marked as being introduced in Shader Model 6.5 in compute environment here, but the deployment target is Shader Model 6.0 compute environment}}
float B = fy(f); // #also_alive_fy_call
// expected-error@#also_alive_fz_call {{'fz' is unavailable}}
// expected-note@#fz {{'fz' has been marked as being introduced in Shader Model 6.5 in mesh environment here, but the deployment target is Shader Model 6.0 compute environment}}
float C = fz(f); // #also_alive_fz_call
return 0;
}

float alive(float f) {
// expected-error@#alive_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
// expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
float A = fx(f); // #alive_fx_call
// expected-error@#alive_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}
// expected-note@#fy {{'fy' has been marked as being introduced in Shader Model 6.5 in compute environment here, but the deployment target is Shader Model 6.0 compute environment}}
float B = fy(f); // #alive_fy_call
// expected-error@#alive_fz_call {{'fz' is unavailable}}
// expected-note@#fz {{'fz' has been marked as being introduced in Shader Model 6.5 in mesh environment here, but the deployment target is Shader Model 6.0 compute environment}}
float C = fz(f); // #alive_fz_call

return also_alive(f);
}

float also_dead(float f) {
// expected-error@#also_dead_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
// expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
float A = fx(f); // #also_dead_fx_call
// expected-error@#also_dead_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}
// expected-note@#fy {{'fy' has been marked as being introduced in Shader Model 6.5 in compute environment here, but the deployment target is Shader Model 6.0 compute environment}}
float B = fy(f); // #also_dead_fy_call
// expected-error@#also_dead_fz_call {{'fz' is unavailable}}
// expected-note@#fz {{'fz' has been marked as being introduced in Shader Model 6.5 in mesh environment here, but the deployment target is Shader Model 6.0 compute environment}}
float C = fz(f); // #also_dead_fz_call
return 0;
}

float dead(float f) {
// expected-error@#dead_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
// expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
float A = fx(f); // #dead_fx_call
// expected-error@#dead_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}
// expected-note@#fy {{'fy' has been marked as being introduced in Shader Model 6.5 in compute environment here, but the deployment target is Shader Model 6.0 compute environment}}
float B = fy(f); // #dead_fy_call
// expected-error@#dead_fz_call {{'fz' is unavailable}}
// expected-note@#fz {{'fz' has been marked as being introduced in Shader Model 6.5 in mesh environment here, but the deployment target is Shader Model 6.0 compute environment}}
float C = fz(f); // #dead_fz_call

return also_dead(f);
}

template<typename T>
T aliveTemp(T f) {
// expected-error@#aliveTemp_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
// expected-note@#aliveTemp_inst {{in instantiation of function template specialization 'aliveTemp<float>' requested here}}
// expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
float A = fx(f); // #aliveTemp_fx_call
// expected-error@#aliveTemp_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}
// expected-note@#fy {{'fy' has been marked as being introduced in Shader Model 6.5 in compute environment here, but the deployment target is Shader Model 6.0 compute environment}}
float B = fy(f); // #aliveTemp_fy_call
// expected-error@#aliveTemp_fz_call {{'fz' is unavailable}}
// expected-note@#fz {{'fz' has been marked as being introduced in Shader Model 6.5 in mesh environment here, but the deployment target is Shader Model 6.0 compute environment}}
float C = fz(f); // #aliveTemp_fz_call
return 0;
}

template<typename T> T aliveTemp2(T f) {
// expected-error@#aliveTemp2_fx_call {{'fx' is only available on Shader Model 6.6 or newer}}
// expected-note@#fx_half {{'fx' has been marked as being introduced in Shader Model 6.6 here, but the deployment target is Shader Model 6.0}}
// expected-error@#aliveTemp2_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
// expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
return fx(f); // #aliveTemp2_fx_call
}

half test(half x) {
return aliveTemp2(x); // expected-note {{in instantiation of function template specialization 'aliveTemp2<half>' requested here}}
}

float test(float x) {
return aliveTemp2(x); // expected-note {{in instantiation of function template specialization 'aliveTemp2<float>' requested here}}
}

class MyClass
{
float F;
float makeF() {
// expected-error@#MyClass_makeF_fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
// expected-note@#fx {{'fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
float A = fx(F); // #MyClass_makeF_fx_call
// expected-error@#MyClass_makeF_fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}
// expected-note@#fy {{'fy' has been marked as being introduced in Shader Model 6.5 in compute environment here, but the deployment target is Shader Model 6.0 compute environment}}
float B = fy(F); // #MyClass_makeF_fy_call
// expected-error@#MyClass_makeF_fz_call {{'fz' is unavailable}}
// expected-note@#fz {{'fz' has been marked as being introduced in Shader Model 6.5 in mesh environment here, but the deployment target is Shader Model 6.0 compute environment}}
float C = fz(F); // #MyClass_makeF_fz_call
}
};

[numthreads(4,1,1)]
float main() {
float f = 3;
MyClass C = { 1.0f };
float a = alive(f);
float b = aliveTemp<float>(f); // #aliveTemp_inst
float c = C.makeF();
float d = test((float)1.0);
float e = test((half)1.0);
return a * b * c;
}
384 changes: 192 additions & 192 deletions clang/test/SemaHLSL/Availability/avail-diag-strict-lib.hlsl

Large diffs are not rendered by default.

114 changes: 57 additions & 57 deletions clang/test/SemaHLSL/Availability/avail-lib-multiple-stages.hlsl
Original file line number Diff line number Diff line change
@@ -1,57 +1,57 @@
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library \
// RUN: -fsyntax-only -verify %s

__attribute__((availability(shadermodel, introduced = 6.5)))
float fx(float); // #fx

__attribute__((availability(shadermodel, introduced = 5.0, environment = pixel)))
__attribute__((availability(shadermodel, introduced = 6.5, environment = compute)))
float fy(float); // #fy

__attribute__((availability(shadermodel, introduced = 5.0, environment = compute)))
float fz(float); // #fz


void F(float f) {
// Make sure we only get this error once, even though this function is scanned twice - once
// in compute shader context and once in pixel shader context.
// expected-error@#fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
// expected-note@#fx {{fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
float A = fx(f); // #fx_call

// expected-error@#fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}
// expected-note@#fy {{'fy' has been marked as being introduced in Shader Model 6.5 in compute environment here, but the deployment target is Shader Model 6.0 compute environment}}
float B = fy(f); // #fy_call

// expected-error@#fz_call {{'fz' is unavailable}}
// expected-note@#fz {{'fz' has been marked as being introduced in Shader Model 5.0 in compute environment here, but the deployment target is Shader Model 6.0 pixel environment}}
float X = fz(f); // #fz_call
}

void deadCode(float f) {
// no diagnostics expected under default diagnostic mode
float A = fx(f);
float B = fy(f);
float X = fz(f);
}

// Pixel shader
[shader("pixel")]
void mainPixel() {
F(1.0);
}

// First Compute shader
[shader("compute")]
[numthreads(4,1,1)]
void mainCompute1() {
F(2.0);
}

// Second compute shader to make sure we do not get duplicate messages if F is called
// from multiple entry points.
[shader("compute")]
[numthreads(4,1,1)]
void mainCompute2() {
F(3.0);
}
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library \
// RUN: -fsyntax-only -verify %s

__attribute__((availability(shadermodel, introduced = 6.5)))
float fx(float); // #fx

__attribute__((availability(shadermodel, introduced = 5.0, environment = pixel)))
__attribute__((availability(shadermodel, introduced = 6.5, environment = compute)))
float fy(float); // #fy

__attribute__((availability(shadermodel, introduced = 5.0, environment = compute)))
float fz(float); // #fz


void F(float f) {
// Make sure we only get this error once, even though this function is scanned twice - once
// in compute shader context and once in pixel shader context.
// expected-error@#fx_call {{'fx' is only available on Shader Model 6.5 or newer}}
// expected-note@#fx {{fx' has been marked as being introduced in Shader Model 6.5 here, but the deployment target is Shader Model 6.0}}
float A = fx(f); // #fx_call

// expected-error@#fy_call {{'fy' is only available in compute environment on Shader Model 6.5 or newer}}
// expected-note@#fy {{'fy' has been marked as being introduced in Shader Model 6.5 in compute environment here, but the deployment target is Shader Model 6.0 compute environment}}
float B = fy(f); // #fy_call

// expected-error@#fz_call {{'fz' is unavailable}}
// expected-note@#fz {{'fz' has been marked as being introduced in Shader Model 5.0 in compute environment here, but the deployment target is Shader Model 6.0 pixel environment}}
float X = fz(f); // #fz_call
}

void deadCode(float f) {
// no diagnostics expected under default diagnostic mode
float A = fx(f);
float B = fy(f);
float X = fz(f);
}

// Pixel shader
[shader("pixel")]
void mainPixel() {
F(1.0);
}

// First Compute shader
[shader("compute")]
[numthreads(4,1,1)]
void mainCompute1() {
F(2.0);
}

// Second compute shader to make sure we do not get duplicate messages if F is called
// from multiple entry points.
[shader("compute")]
[numthreads(4,1,1)]
void mainCompute2() {
F(3.0);
}
38 changes: 19 additions & 19 deletions clang/test/SemaHLSL/BuiltIns/StructuredBuffers.hlsl
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -fsyntax-only -verify %s

typedef vector<float, 3> float3;

StructuredBuffer<float3> Buffer;

// expected-error@+2 {{class template 'StructuredBuffer' requires template arguments}}
// expected-note@*:* {{template declaration from hidden source: template <class element_type> class StructuredBuffer}}
StructuredBuffer BufferErr1;

// expected-error@+2 {{too few template arguments for class template 'StructuredBuffer'}}
// expected-note@*:* {{template declaration from hidden source: template <class element_type> class StructuredBuffer}}
StructuredBuffer<> BufferErr2;

[numthreads(1,1,1)]
void main() {
(void)Buffer.h; // expected-error {{'h' is a private member of 'hlsl::StructuredBuffer<vector<float, 3>>'}}
// expected-note@* {{implicitly declared private here}}
}
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -fsyntax-only -verify %s

typedef vector<float, 3> float3;

StructuredBuffer<float3> Buffer;

// expected-error@+2 {{class template 'StructuredBuffer' requires template arguments}}
// expected-note@*:* {{template declaration from hidden source: template <class element_type> class StructuredBuffer}}
StructuredBuffer BufferErr1;

// expected-error@+2 {{too few template arguments for class template 'StructuredBuffer'}}
// expected-note@*:* {{template declaration from hidden source: template <class element_type> class StructuredBuffer}}
StructuredBuffer<> BufferErr2;

[numthreads(1,1,1)]
void main() {
(void)Buffer.h; // expected-error {{'h' is a private member of 'hlsl::StructuredBuffer<vector<float, 3>>'}}
// expected-note@* {{implicitly declared private here}}
}
86 changes: 43 additions & 43 deletions clang/test/SemaHLSL/BuiltIns/cross-errors.hlsl
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -disable-llvm-passes -verify

void test_too_few_arg()
{
return __builtin_hlsl_cross();
// expected-error@-1 {{too few arguments to function call, expected 2, have 0}}
}

void test_too_many_arg(float3 p0)
{
return __builtin_hlsl_cross(p0, p0, p0);
// expected-error@-1 {{too many arguments to function call, expected 2, have 3}}
}

bool builtin_bool_to_float_type_promotion(bool p1)
{
return __builtin_hlsl_cross(p1, p1);
// expected-error@-1 {{passing 'bool' to parameter of incompatible type 'float'}}
}

bool builtin_cross_int_to_float_promotion(int p1)
{
return __builtin_hlsl_cross(p1, p1);
// expected-error@-1 {{passing 'int' to parameter of incompatible type 'float'}}
}

bool2 builtin_cross_int2_to_float2_promotion(int2 p1)
{
return __builtin_hlsl_cross(p1, p1);
// expected-error@-1 {{passing 'int2' (aka 'vector<int, 2>') to parameter of incompatible type '__attribute__((__vector_size__(2 * sizeof(float)))) float' (vector of 2 'float' values)}}
}

float2 builtin_cross_float2(float2 p1, float2 p2)
{
return __builtin_hlsl_cross(p1, p2);
// expected-error@-1 {{too many elements in vector operand (expected 3 elements, have 2)}}
}

float3 builtin_cross_float3_int3(float3 p1, int3 p2)
{
return __builtin_hlsl_cross(p1, p2);
// expected-error@-1 {{all arguments to '__builtin_hlsl_cross' must have the same type}}
}
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -disable-llvm-passes -verify

void test_too_few_arg()
{
return __builtin_hlsl_cross();
// expected-error@-1 {{too few arguments to function call, expected 2, have 0}}
}

void test_too_many_arg(float3 p0)
{
return __builtin_hlsl_cross(p0, p0, p0);
// expected-error@-1 {{too many arguments to function call, expected 2, have 3}}
}

bool builtin_bool_to_float_type_promotion(bool p1)
{
return __builtin_hlsl_cross(p1, p1);
// expected-error@-1 {{passing 'bool' to parameter of incompatible type 'float'}}
}

bool builtin_cross_int_to_float_promotion(int p1)
{
return __builtin_hlsl_cross(p1, p1);
// expected-error@-1 {{passing 'int' to parameter of incompatible type 'float'}}
}

bool2 builtin_cross_int2_to_float2_promotion(int2 p1)
{
return __builtin_hlsl_cross(p1, p1);
// expected-error@-1 {{passing 'int2' (aka 'vector<int, 2>') to parameter of incompatible type '__attribute__((__vector_size__(2 * sizeof(float)))) float' (vector of 2 'float' values)}}
}

float2 builtin_cross_float2(float2 p1, float2 p2)
{
return __builtin_hlsl_cross(p1, p2);
// expected-error@-1 {{too many elements in vector operand (expected 3 elements, have 2)}}
}

float3 builtin_cross_float3_int3(float3 p1, int3 p2)
{
return __builtin_hlsl_cross(p1, p2);
// expected-error@-1 {{all arguments to '__builtin_hlsl_cross' must have the same type}}
}
26 changes: 13 additions & 13 deletions clang/test/SemaHLSL/BuiltIns/half-float-only-errors2.hlsl
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm-only -disable-llvm-passes -verify -DTEST_FUNC=__builtin_elementwise_atan2
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm-only -disable-llvm-passes -verify -DTEST_FUNC=__builtin_elementwise_fmod
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm-only -disable-llvm-passes -verify -DTEST_FUNC=__builtin_elementwise_pow

double test_double_builtin(double p0, double p1) {
return TEST_FUNC(p0, p1);
// expected-error@-1 {{passing 'double' to parameter of incompatible type 'float'}}
}

double2 test_vec_double_builtin(double2 p0, double2 p1) {
return TEST_FUNC(p0, p1);
// expected-error@-1 {{passing 'double2' (aka 'vector<double, 2>') to parameter of incompatible type '__attribute__((__vector_size__(2 * sizeof(float)))) float' (vector of 2 'float' values)}}
}
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm-only -disable-llvm-passes -verify -DTEST_FUNC=__builtin_elementwise_atan2
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm-only -disable-llvm-passes -verify -DTEST_FUNC=__builtin_elementwise_fmod
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm-only -disable-llvm-passes -verify -DTEST_FUNC=__builtin_elementwise_pow

double test_double_builtin(double p0, double p1) {
return TEST_FUNC(p0, p1);
// expected-error@-1 {{passing 'double' to parameter of incompatible type 'float'}}
}

double2 test_vec_double_builtin(double2 p0, double2 p1) {
return TEST_FUNC(p0, p1);
// expected-error@-1 {{passing 'double2' (aka 'vector<double, 2>') to parameter of incompatible type '__attribute__((__vector_size__(2 * sizeof(float)))) float' (vector of 2 'float' values)}}
}
64 changes: 32 additions & 32 deletions clang/test/SemaHLSL/BuiltIns/length-errors.hlsl
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -disable-llvm-passes -verify -verify-ignore-unexpected


void test_too_few_arg()
{
return __builtin_hlsl_length();
// expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
}

void test_too_many_arg(float2 p0)
{
return __builtin_hlsl_length(p0, p0);
// expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
}

bool builtin_bool_to_float_type_promotion(bool p1)
{
return __builtin_hlsl_length(p1);
// expected-error@-1 {passing 'bool' to parameter of incompatible type 'float'}}
}

bool builtin_length_int_to_float_promotion(int p1)
{
return __builtin_hlsl_length(p1);
// expected-error@-1 {{passing 'int' to parameter of incompatible type 'float'}}
}

bool2 builtin_length_int2_to_float2_promotion(int2 p1)
{
return __builtin_hlsl_length(p1);
// expected-error@-1 {{passing 'int2' (aka 'vector<int, 2>') to parameter of incompatible type '__attribute__((__vector_size__(2 * sizeof(float)))) float' (vector of 2 'float' values)}}
}
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -disable-llvm-passes -verify -verify-ignore-unexpected


void test_too_few_arg()
{
return __builtin_hlsl_length();
// expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
}

void test_too_many_arg(float2 p0)
{
return __builtin_hlsl_length(p0, p0);
// expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
}

bool builtin_bool_to_float_type_promotion(bool p1)
{
return __builtin_hlsl_length(p1);
// expected-error@-1 {passing 'bool' to parameter of incompatible type 'float'}}
}

bool builtin_length_int_to_float_promotion(int p1)
{
return __builtin_hlsl_length(p1);
// expected-error@-1 {{passing 'int' to parameter of incompatible type 'float'}}
}

bool2 builtin_length_int2_to_float2_promotion(int2 p1)
{
return __builtin_hlsl_length(p1);
// expected-error@-1 {{passing 'int2' (aka 'vector<int, 2>') to parameter of incompatible type '__attribute__((__vector_size__(2 * sizeof(float)))) float' (vector of 2 'float' values)}}
}
62 changes: 31 additions & 31 deletions clang/test/SemaHLSL/BuiltIns/normalize-errors.hlsl
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -disable-llvm-passes -verify -verify-ignore-unexpected

void test_too_few_arg()
{
return __builtin_hlsl_normalize();
// expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
}

void test_too_many_arg(float2 p0)
{
return __builtin_hlsl_normalize(p0, p0);
// expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
}

bool builtin_bool_to_float_type_promotion(bool p1)
{
return __builtin_hlsl_normalize(p1);
// expected-error@-1 {passing 'bool' to parameter of incompatible type 'float'}}
}

bool builtin_normalize_int_to_float_promotion(int p1)
{
return __builtin_hlsl_normalize(p1);
// expected-error@-1 {{passing 'int' to parameter of incompatible type 'float'}}
}

bool2 builtin_normalize_int2_to_float2_promotion(int2 p1)
{
return __builtin_hlsl_normalize(p1);
// expected-error@-1 {{passing 'int2' (aka 'vector<int, 2>') to parameter of incompatible type '__attribute__((__vector_size__(2 * sizeof(float)))) float' (vector of 2 'float' values)}}
}
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -disable-llvm-passes -verify -verify-ignore-unexpected

void test_too_few_arg()
{
return __builtin_hlsl_normalize();
// expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
}

void test_too_many_arg(float2 p0)
{
return __builtin_hlsl_normalize(p0, p0);
// expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
}

bool builtin_bool_to_float_type_promotion(bool p1)
{
return __builtin_hlsl_normalize(p1);
// expected-error@-1 {passing 'bool' to parameter of incompatible type 'float'}}
}

bool builtin_normalize_int_to_float_promotion(int p1)
{
return __builtin_hlsl_normalize(p1);
// expected-error@-1 {{passing 'int' to parameter of incompatible type 'float'}}
}

bool2 builtin_normalize_int2_to_float2_promotion(int2 p1)
{
return __builtin_hlsl_normalize(p1);
// expected-error@-1 {{passing 'int2' (aka 'vector<int, 2>') to parameter of incompatible type '__attribute__((__vector_size__(2 * sizeof(float)))) float' (vector of 2 'float' values)}}
}
62 changes: 31 additions & 31 deletions clang/test/SemaHLSL/BuiltIns/step-errors.hlsl
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -disable-llvm-passes -verify -verify-ignore-unexpected

void test_too_few_arg()
{
return __builtin_hlsl_step();
// expected-error@-1 {{too few arguments to function call, expected 2, have 0}}
}

void test_too_many_arg(float2 p0)
{
return __builtin_hlsl_step(p0, p0, p0);
// expected-error@-1 {{too many arguments to function call, expected 2, have 3}}
}

bool builtin_bool_to_float_type_promotion(bool p1)
{
return __builtin_hlsl_step(p1, p1);
// expected-error@-1 {passing 'bool' to parameter of incompatible type 'float'}}
}

bool builtin_step_int_to_float_promotion(int p1)
{
return __builtin_hlsl_step(p1, p1);
// expected-error@-1 {{passing 'int' to parameter of incompatible type 'float'}}
}

bool2 builtin_step_int2_to_float2_promotion(int2 p1)
{
return __builtin_hlsl_step(p1, p1);
// expected-error@-1 {{passing 'int2' (aka 'vector<int, 2>') to parameter of incompatible type '__attribute__((__vector_size__(2 * sizeof(float)))) float' (vector of 2 'float' values)}}
}
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -disable-llvm-passes -verify -verify-ignore-unexpected

void test_too_few_arg()
{
return __builtin_hlsl_step();
// expected-error@-1 {{too few arguments to function call, expected 2, have 0}}
}

void test_too_many_arg(float2 p0)
{
return __builtin_hlsl_step(p0, p0, p0);
// expected-error@-1 {{too many arguments to function call, expected 2, have 3}}
}

bool builtin_bool_to_float_type_promotion(bool p1)
{
return __builtin_hlsl_step(p1, p1);
// expected-error@-1 {passing 'bool' to parameter of incompatible type 'float'}}
}

bool builtin_step_int_to_float_promotion(int p1)
{
return __builtin_hlsl_step(p1, p1);
// expected-error@-1 {{passing 'int' to parameter of incompatible type 'float'}}
}

bool2 builtin_step_int2_to_float2_promotion(int2 p1)
{
return __builtin_hlsl_step(p1, p1);
// expected-error@-1 {{passing 'int2' (aka 'vector<int, 2>') to parameter of incompatible type '__attribute__((__vector_size__(2 * sizeof(float)))) float' (vector of 2 'float' values)}}
}
162 changes: 81 additions & 81 deletions clang/test/SemaHLSL/Types/Traits/IsIntangibleType.hlsl
Original file line number Diff line number Diff line change
@@ -1,81 +1,81 @@
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.6-library -finclude-default-header -verify %s
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.6-library -finclude-default-header -fnative-half-type -verify %s
// expected-no-diagnostics

_Static_assert(__builtin_hlsl_is_intangible(__hlsl_resource_t), "");
// no need to check array of __hlsl_resource_t, arrays of sizeless types are not supported

_Static_assert(!__builtin_hlsl_is_intangible(int), "");
_Static_assert(!__builtin_hlsl_is_intangible(float3), "");
_Static_assert(!__builtin_hlsl_is_intangible(half[4]), "");

typedef __hlsl_resource_t Res;
_Static_assert(__builtin_hlsl_is_intangible(const Res), "");
// no need to check array of Res, arrays of sizeless types are not supported

struct ABuffer {
const int i[10];
__hlsl_resource_t h;
};
_Static_assert(__builtin_hlsl_is_intangible(ABuffer), "");
_Static_assert(__builtin_hlsl_is_intangible(ABuffer[10]), "");

struct MyStruct {
half2 h2;
int3 i3;
};
_Static_assert(!__builtin_hlsl_is_intangible(MyStruct), "");
_Static_assert(!__builtin_hlsl_is_intangible(MyStruct[10]), "");

class MyClass {
int3 ivec;
float farray[12];
MyStruct ms;
ABuffer buf;
};
_Static_assert(__builtin_hlsl_is_intangible(MyClass), "");
_Static_assert(__builtin_hlsl_is_intangible(MyClass[2]), "");

union U {
double d[4];
Res buf;
};
_Static_assert(__builtin_hlsl_is_intangible(U), "");
_Static_assert(__builtin_hlsl_is_intangible(U[100]), "");

class MyClass2 {
int3 ivec;
float farray[12];
U u;
};
_Static_assert(__builtin_hlsl_is_intangible(MyClass2), "");
_Static_assert(__builtin_hlsl_is_intangible(MyClass2[5]), "");

class Simple {
int a;
};

template<typename T> struct TemplatedBuffer {
T a;
__hlsl_resource_t h;
};
_Static_assert(__builtin_hlsl_is_intangible(TemplatedBuffer<int>), "");

struct MyStruct2 : TemplatedBuffer<float> {
float x;
};
_Static_assert(__builtin_hlsl_is_intangible(MyStruct2), "");

struct MyStruct3 {
const TemplatedBuffer<float> TB[10];
};
_Static_assert(__builtin_hlsl_is_intangible(MyStruct3), "");

template<typename T> struct SimpleTemplate {
T a;
};
_Static_assert(__builtin_hlsl_is_intangible(SimpleTemplate<__hlsl_resource_t>), "");
_Static_assert(!__builtin_hlsl_is_intangible(SimpleTemplate<float>), "");

_Static_assert(__builtin_hlsl_is_intangible(RWBuffer<float>), "");
_Static_assert(__builtin_hlsl_is_intangible(StructuredBuffer<Simple>), "");
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.6-library -finclude-default-header -verify %s
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.6-library -finclude-default-header -fnative-half-type -verify %s
// expected-no-diagnostics

_Static_assert(__builtin_hlsl_is_intangible(__hlsl_resource_t), "");
// no need to check array of __hlsl_resource_t, arrays of sizeless types are not supported

_Static_assert(!__builtin_hlsl_is_intangible(int), "");
_Static_assert(!__builtin_hlsl_is_intangible(float3), "");
_Static_assert(!__builtin_hlsl_is_intangible(half[4]), "");

typedef __hlsl_resource_t Res;
_Static_assert(__builtin_hlsl_is_intangible(const Res), "");
// no need to check array of Res, arrays of sizeless types are not supported

struct ABuffer {
const int i[10];
__hlsl_resource_t h;
};
_Static_assert(__builtin_hlsl_is_intangible(ABuffer), "");
_Static_assert(__builtin_hlsl_is_intangible(ABuffer[10]), "");

struct MyStruct {
half2 h2;
int3 i3;
};
_Static_assert(!__builtin_hlsl_is_intangible(MyStruct), "");
_Static_assert(!__builtin_hlsl_is_intangible(MyStruct[10]), "");

class MyClass {
int3 ivec;
float farray[12];
MyStruct ms;
ABuffer buf;
};
_Static_assert(__builtin_hlsl_is_intangible(MyClass), "");
_Static_assert(__builtin_hlsl_is_intangible(MyClass[2]), "");

union U {
double d[4];
Res buf;
};
_Static_assert(__builtin_hlsl_is_intangible(U), "");
_Static_assert(__builtin_hlsl_is_intangible(U[100]), "");

class MyClass2 {
int3 ivec;
float farray[12];
U u;
};
_Static_assert(__builtin_hlsl_is_intangible(MyClass2), "");
_Static_assert(__builtin_hlsl_is_intangible(MyClass2[5]), "");

class Simple {
int a;
};

template<typename T> struct TemplatedBuffer {
T a;
__hlsl_resource_t h;
};
_Static_assert(__builtin_hlsl_is_intangible(TemplatedBuffer<int>), "");

struct MyStruct2 : TemplatedBuffer<float> {
float x;
};
_Static_assert(__builtin_hlsl_is_intangible(MyStruct2), "");

struct MyStruct3 {
const TemplatedBuffer<float> TB[10];
};
_Static_assert(__builtin_hlsl_is_intangible(MyStruct3), "");

template<typename T> struct SimpleTemplate {
T a;
};
_Static_assert(__builtin_hlsl_is_intangible(SimpleTemplate<__hlsl_resource_t>), "");
_Static_assert(!__builtin_hlsl_is_intangible(SimpleTemplate<float>), "");

_Static_assert(__builtin_hlsl_is_intangible(RWBuffer<float>), "");
_Static_assert(__builtin_hlsl_is_intangible(StructuredBuffer<Simple>), "");
24 changes: 12 additions & 12 deletions clang/test/SemaHLSL/Types/Traits/IsIntangibleTypeErrors.hlsl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.6-library -finclude-default-header -verify %s

struct Undefined; // expected-note {{forward declaration of 'Undefined'}}
_Static_assert(!__builtin_hlsl_is_intangible(Undefined), ""); // expected-error{{incomplete type 'Undefined' used in type trait expression}}

void fn(int X) { // expected-note {{declared here}}
// expected-error@#vla {{variable length arrays are not supported for the current target}}
// expected-error@#vla {{variable length arrays are not supported in '__builtin_hlsl_is_intangible'}}
// expected-warning@#vla {{variable length arrays in C++ are a Clang extension}}
// expected-note@#vla {{function parameter 'X' with unknown value cannot be used in a constant expression}}
_Static_assert(!__builtin_hlsl_is_intangible(int[X]), ""); // #vla
}
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.6-library -finclude-default-header -verify %s

struct Undefined; // expected-note {{forward declaration of 'Undefined'}}
_Static_assert(!__builtin_hlsl_is_intangible(Undefined), ""); // expected-error{{incomplete type 'Undefined' used in type trait expression}}

void fn(int X) { // expected-note {{declared here}}
// expected-error@#vla {{variable length arrays are not supported for the current target}}
// expected-error@#vla {{variable length arrays are not supported in '__builtin_hlsl_is_intangible'}}
// expected-warning@#vla {{variable length arrays in C++ are a Clang extension}}
// expected-note@#vla {{function parameter 'X' with unknown value cannot be used in a constant expression}}
_Static_assert(!__builtin_hlsl_is_intangible(int[X]), ""); // #vla
}
84 changes: 42 additions & 42 deletions clang/test/SemaHLSL/resource_binding_attr_error_basic.hlsl
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -o - -fsyntax-only %s -verify

// expected-error@+1{{binding type 't' only applies to SRV resources}}
float f1 : register(t0);

// expected-error@+1 {{binding type 'u' only applies to UAV resources}}
float f2 : register(u0);

// expected-error@+1{{binding type 'b' only applies to constant buffers. The 'bool constant' binding type is no longer supported}}
float f3 : register(b9);

// expected-error@+1 {{binding type 's' only applies to sampler state}}
float f4 : register(s0);

// expected-error@+1{{binding type 'i' ignored. The 'integer constant' binding type is no longer supported}}
float f5 : register(i9);

// expected-error@+1{{binding type 'x' is invalid}}
float f6 : register(x9);

cbuffer g_cbuffer1 {
// expected-error@+1{{binding type 'c' ignored in buffer declaration. Did you mean 'packoffset'?}}
float f7 : register(c2);
};

tbuffer g_tbuffer1 {
// expected-error@+1{{binding type 'c' ignored in buffer declaration. Did you mean 'packoffset'?}}
float f8 : register(c2);
};

cbuffer g_cbuffer2 {
// expected-error@+1{{binding type 'b' only applies to constant buffer resources}}
float f9 : register(b2);
};

tbuffer g_tbuffer2 {
// expected-error@+1{{binding type 'i' ignored. The 'integer constant' binding type is no longer supported}}
float f10 : register(i2);
};

// expected-error@+1{{binding type 'c' only applies to numeric variables in the global scope}}
RWBuffer<float> f11 : register(c3);
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -o - -fsyntax-only %s -verify

// expected-error@+1{{binding type 't' only applies to SRV resources}}
float f1 : register(t0);

// expected-error@+1 {{binding type 'u' only applies to UAV resources}}
float f2 : register(u0);

// expected-error@+1{{binding type 'b' only applies to constant buffers. The 'bool constant' binding type is no longer supported}}
float f3 : register(b9);

// expected-error@+1 {{binding type 's' only applies to sampler state}}
float f4 : register(s0);

// expected-error@+1{{binding type 'i' ignored. The 'integer constant' binding type is no longer supported}}
float f5 : register(i9);

// expected-error@+1{{binding type 'x' is invalid}}
float f6 : register(x9);

cbuffer g_cbuffer1 {
// expected-error@+1{{binding type 'c' ignored in buffer declaration. Did you mean 'packoffset'?}}
float f7 : register(c2);
};

tbuffer g_tbuffer1 {
// expected-error@+1{{binding type 'c' ignored in buffer declaration. Did you mean 'packoffset'?}}
float f8 : register(c2);
};

cbuffer g_cbuffer2 {
// expected-error@+1{{binding type 'b' only applies to constant buffer resources}}
float f9 : register(b2);
};

tbuffer g_tbuffer2 {
// expected-error@+1{{binding type 'i' ignored. The 'integer constant' binding type is no longer supported}}
float f10 : register(i2);
};

// expected-error@+1{{binding type 'c' only applies to numeric variables in the global scope}}
RWBuffer<float> f11 : register(c3);
18 changes: 9 additions & 9 deletions clang/test/SemaHLSL/resource_binding_attr_error_other.hlsl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// RUN: not %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -o - -fsyntax-only %s | FileCheck %s

// XFAIL: *
// This expectedly fails because RayQuery is an unsupported type.
// When it becomes supported, we should expect an error due to
// the variable type being classified as "other", and according
// to the spec, err_hlsl_unsupported_register_type_and_variable_type
// should be emitted.
RayQuery<0> r1: register(t0);
// RUN: not %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -o - -fsyntax-only %s | FileCheck %s

// XFAIL: *
// This expectedly fails because RayQuery is an unsupported type.
// When it becomes supported, we should expect an error due to
// the variable type being classified as "other", and according
// to the spec, err_hlsl_unsupported_register_type_and_variable_type
// should be emitted.
RayQuery<0> r1: register(t0);
98 changes: 49 additions & 49 deletions clang/test/SemaHLSL/resource_binding_attr_error_resource.hlsl
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -o - -fsyntax-only %s -verify

// This test validates the diagnostics that are emitted when a variable with a "resource" type
// is bound to a register using the register annotation


template<typename T>
struct MyTemplatedSRV {
__hlsl_resource_t [[hlsl::resource_class(SRV)]] x;
};

struct MySRV {
__hlsl_resource_t [[hlsl::resource_class(SRV)]] x;
};

struct MySampler {
__hlsl_resource_t [[hlsl::resource_class(Sampler)]] x;
};

struct MyUAV {
__hlsl_resource_t [[hlsl::resource_class(UAV)]] x;
};

struct MyCBuffer {
__hlsl_resource_t [[hlsl::resource_class(CBuffer)]] x;
};


// expected-error@+1 {{binding type 'i' ignored. The 'integer constant' binding type is no longer supported}}
MySRV invalid : register(i2);

// expected-error@+1 {{binding type 't' only applies to SRV resources}}
MyUAV a : register(t2, space1);

// expected-error@+1 {{binding type 'u' only applies to UAV resources}}
MySampler b : register(u2, space1);

// expected-error@+1 {{binding type 'b' only applies to constant buffer resources}}
MyTemplatedSRV<int> c : register(b2);

// expected-error@+1 {{binding type 's' only applies to sampler state}}
MyUAV d : register(s2, space1);

// empty binding prefix cases:
// expected-error@+1 {{expected identifier}}
MyTemplatedSRV<int> e: register();

// expected-error@+1 {{expected identifier}}
MyTemplatedSRV<int> f: register("");
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -o - -fsyntax-only %s -verify

// This test validates the diagnostics that are emitted when a variable with a "resource" type
// is bound to a register using the register annotation


template<typename T>
struct MyTemplatedSRV {
__hlsl_resource_t [[hlsl::resource_class(SRV)]] x;
};

struct MySRV {
__hlsl_resource_t [[hlsl::resource_class(SRV)]] x;
};

struct MySampler {
__hlsl_resource_t [[hlsl::resource_class(Sampler)]] x;
};

struct MyUAV {
__hlsl_resource_t [[hlsl::resource_class(UAV)]] x;
};

struct MyCBuffer {
__hlsl_resource_t [[hlsl::resource_class(CBuffer)]] x;
};


// expected-error@+1 {{binding type 'i' ignored. The 'integer constant' binding type is no longer supported}}
MySRV invalid : register(i2);

// expected-error@+1 {{binding type 't' only applies to SRV resources}}
MyUAV a : register(t2, space1);

// expected-error@+1 {{binding type 'u' only applies to UAV resources}}
MySampler b : register(u2, space1);

// expected-error@+1 {{binding type 'b' only applies to constant buffer resources}}
MyTemplatedSRV<int> c : register(b2);

// expected-error@+1 {{binding type 's' only applies to sampler state}}
MyUAV d : register(s2, space1);

// empty binding prefix cases:
// expected-error@+1 {{expected identifier}}
MyTemplatedSRV<int> e: register();

// expected-error@+1 {{expected identifier}}
MyTemplatedSRV<int> f: register("");
54 changes: 27 additions & 27 deletions clang/test/SemaHLSL/resource_binding_attr_error_silence_diags.hlsl
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -o - -fsyntax-only -Wno-legacy-constant-register-binding %s -verify

// expected-no-diagnostics
float f2 : register(b9);

float f3 : register(i9);

cbuffer g_cbuffer1 {
float f4 : register(c2);
};


struct Eg12{
RWBuffer<int> a;
};

Eg12 e12 : register(c9);

Eg12 bar : register(i1);

struct Eg7 {
struct Bar {
float f;
};
Bar b;
};
Eg7 e7 : register(t0);
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -o - -fsyntax-only -Wno-legacy-constant-register-binding %s -verify

// expected-no-diagnostics
float f2 : register(b9);

float f3 : register(i9);

cbuffer g_cbuffer1 {
float f4 : register(c2);
};


struct Eg12{
RWBuffer<int> a;
};

Eg12 e12 : register(c9);

Eg12 bar : register(i1);

struct Eg7 {
struct Bar {
float f;
};
Bar b;
};
Eg7 e7 : register(t0);
124 changes: 62 additions & 62 deletions clang/test/SemaHLSL/resource_binding_attr_error_space.hlsl
Original file line number Diff line number Diff line change
@@ -1,62 +1,62 @@
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -o - -fsyntax-only %s -verify

// valid
cbuffer cbuf {
RWBuffer<int> r : register(u0, space0);
}

cbuffer cbuf2 {
struct x {
// this test validates that no diagnostic is emitted on the space parameter, because
// this register annotation is not in the global scope.
// expected-error@+1 {{'register' attribute only applies to cbuffer/tbuffer and external global variables}}
RWBuffer<int> E : register(u2, space3);
};
}

struct MyStruct {
RWBuffer<int> E;
};

cbuffer cbuf3 {
// valid
MyStruct E : register(u2, space3);
}

// valid
MyStruct F : register(u3, space4);

cbuffer cbuf4 {
// this test validates that no diagnostic is emitted on the space parameter, because
// this register annotation is not in the global scope.
// expected-error@+1 {{binding type 'u' only applies to UAV resources}}
float a : register(u2, space3);
}

// expected-error@+1 {{invalid space specifier 's2' used; expected 'space' followed by an integer, like space1}}
cbuffer a : register(b0, s2) {

}

// expected-error@+1 {{invalid space specifier 'spaces' used; expected 'space' followed by an integer, like space1}}
cbuffer b : register(b2, spaces) {

}

// expected-error@+1 {{wrong argument format for hlsl attribute, use space3 instead}}
cbuffer c : register(b2, space 3) {}

// expected-error@+1 {{register space cannot be specified on global constants}}
int d : register(c2, space3);

// expected-error@+1 {{register space cannot be specified on global constants}}
int e : register(c2, space0);

// expected-error@+1 {{register space cannot be specified on global constants}}
int f : register(c2, space00);

// valid
RWBuffer<int> g : register(u2, space0);

// valid
RWBuffer<int> h : register(u2, space0);
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -o - -fsyntax-only %s -verify

// valid
cbuffer cbuf {
RWBuffer<int> r : register(u0, space0);
}

cbuffer cbuf2 {
struct x {
// this test validates that no diagnostic is emitted on the space parameter, because
// this register annotation is not in the global scope.
// expected-error@+1 {{'register' attribute only applies to cbuffer/tbuffer and external global variables}}
RWBuffer<int> E : register(u2, space3);
};
}

struct MyStruct {
RWBuffer<int> E;
};

cbuffer cbuf3 {
// valid
MyStruct E : register(u2, space3);
}

// valid
MyStruct F : register(u3, space4);

cbuffer cbuf4 {
// this test validates that no diagnostic is emitted on the space parameter, because
// this register annotation is not in the global scope.
// expected-error@+1 {{binding type 'u' only applies to UAV resources}}
float a : register(u2, space3);
}

// expected-error@+1 {{invalid space specifier 's2' used; expected 'space' followed by an integer, like space1}}
cbuffer a : register(b0, s2) {

}

// expected-error@+1 {{invalid space specifier 'spaces' used; expected 'space' followed by an integer, like space1}}
cbuffer b : register(b2, spaces) {

}

// expected-error@+1 {{wrong argument format for hlsl attribute, use space3 instead}}
cbuffer c : register(b2, space 3) {}

// expected-error@+1 {{register space cannot be specified on global constants}}
int d : register(c2, space3);

// expected-error@+1 {{register space cannot be specified on global constants}}
int e : register(c2, space0);

// expected-error@+1 {{register space cannot be specified on global constants}}
int f : register(c2, space00);

// valid
RWBuffer<int> g : register(u2, space0);

// valid
RWBuffer<int> h : register(u2, space0);
270 changes: 135 additions & 135 deletions clang/test/SemaHLSL/resource_binding_attr_error_udt.hlsl
Original file line number Diff line number Diff line change
@@ -1,135 +1,135 @@
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -o - -fsyntax-only %s -verify

template<typename T>
struct MyTemplatedUAV {
__hlsl_resource_t [[hlsl::resource_class(UAV)]] x;
};

struct MySRV {
__hlsl_resource_t [[hlsl::resource_class(SRV)]] x;
};

struct MySampler {
__hlsl_resource_t [[hlsl::resource_class(Sampler)]] x;
};

struct MyUAV {
__hlsl_resource_t [[hlsl::resource_class(UAV)]] x;
};

struct MyCBuffer {
__hlsl_resource_t [[hlsl::resource_class(CBuffer)]] x;
};

// Valid: f is skipped, SRVBuf is bound to t0, UAVBuf is bound to u0
struct Eg1 {
float f;
MySRV SRVBuf;
MyUAV UAVBuf;
};
Eg1 e1 : register(t0) : register(u0);

// Valid: f is skipped, SRVBuf is bound to t0, UAVBuf is bound to u0.
// UAVBuf2 gets automatically assigned to u1 even though there is no explicit binding for u1.
struct Eg2 {
float f;
MySRV SRVBuf;
MyUAV UAVBuf;
MyUAV UAVBuf2;
};
Eg2 e2 : register(t0) : register(u0);

// Valid: Bar, the struct within Eg3, has a valid resource that can be bound to t0.
struct Eg3 {
struct Bar {
MyUAV a;
};
Bar b;
};
Eg3 e3 : register(u0);

// Valid: the first sampler state object within 's' is bound to slot 5
struct Eg4 {
MySampler s[3];
};

Eg4 e4 : register(s5);


struct Eg5 {
float f;
};
// expected-warning@+1{{binding type 't' only applies to types containing SRV resources}}
Eg5 e5 : register(t0);

struct Eg6 {
float f;
};
// expected-warning@+1{{binding type 'u' only applies to types containing UAV resources}}
Eg6 e6 : register(u0);

struct Eg7 {
float f;
};
// expected-warning@+1{{binding type 'b' only applies to types containing constant buffer resources}}
Eg7 e7 : register(b0);

struct Eg8 {
float f;
};
// expected-warning@+1{{binding type 's' only applies to types containing sampler state}}
Eg8 e8 : register(s0);

struct Eg9 {
MySRV s;
};
// expected-warning@+1{{binding type 'c' only applies to types containing numeric types}}
Eg9 e9 : register(c0);

struct Eg10{
// expected-error@+1{{'register' attribute only applies to cbuffer/tbuffer and external global variables}}
MyTemplatedUAV<int> a : register(u9);
};
Eg10 e10;


template<typename R>
struct Eg11 {
R b;
};
// expected-warning@+1{{binding type 'u' only applies to types containing UAV resources}}
Eg11<MySRV> e11 : register(u0);
// invalid because after template expansion, there are no valid resources inside Eg11 to bind as a UAV, only an SRV


struct Eg12{
MySRV s1;
MySRV s2;
};
// expected-warning@+2{{binding type 'u' only applies to types containing UAV resources}}
// expected-error@+1{{binding type 'u' cannot be applied more than once}}
Eg12 e12 : register(u9) : register(u10);

struct Eg13{
MySRV s1;
MySRV s2;
};
// expected-warning@+3{{binding type 'u' only applies to types containing UAV resources}}
// expected-error@+2{{binding type 'u' cannot be applied more than once}}
// expected-error@+1{{binding type 'u' cannot be applied more than once}}
Eg13 e13 : register(u9) : register(u10) : register(u11);

// expected-error@+1{{binding type 't' cannot be applied more than once}}
Eg13 e13_2 : register(t11) : register(t12);

struct Eg14{
MyTemplatedUAV<int> r1;
};
// expected-warning@+1{{binding type 't' only applies to types containing SRV resources}}
Eg14 e14 : register(t9);

struct Eg15 {
float f[4];
};
// expected no error
Eg15 e15 : register(c0);
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -o - -fsyntax-only %s -verify

template<typename T>
struct MyTemplatedUAV {
__hlsl_resource_t [[hlsl::resource_class(UAV)]] x;
};

struct MySRV {
__hlsl_resource_t [[hlsl::resource_class(SRV)]] x;
};

struct MySampler {
__hlsl_resource_t [[hlsl::resource_class(Sampler)]] x;
};

struct MyUAV {
__hlsl_resource_t [[hlsl::resource_class(UAV)]] x;
};

struct MyCBuffer {
__hlsl_resource_t [[hlsl::resource_class(CBuffer)]] x;
};

// Valid: f is skipped, SRVBuf is bound to t0, UAVBuf is bound to u0
struct Eg1 {
float f;
MySRV SRVBuf;
MyUAV UAVBuf;
};
Eg1 e1 : register(t0) : register(u0);

// Valid: f is skipped, SRVBuf is bound to t0, UAVBuf is bound to u0.
// UAVBuf2 gets automatically assigned to u1 even though there is no explicit binding for u1.
struct Eg2 {
float f;
MySRV SRVBuf;
MyUAV UAVBuf;
MyUAV UAVBuf2;
};
Eg2 e2 : register(t0) : register(u0);

// Valid: Bar, the struct within Eg3, has a valid resource that can be bound to t0.
struct Eg3 {
struct Bar {
MyUAV a;
};
Bar b;
};
Eg3 e3 : register(u0);

// Valid: the first sampler state object within 's' is bound to slot 5
struct Eg4 {
MySampler s[3];
};

Eg4 e4 : register(s5);


struct Eg5 {
float f;
};
// expected-warning@+1{{binding type 't' only applies to types containing SRV resources}}
Eg5 e5 : register(t0);

struct Eg6 {
float f;
};
// expected-warning@+1{{binding type 'u' only applies to types containing UAV resources}}
Eg6 e6 : register(u0);

struct Eg7 {
float f;
};
// expected-warning@+1{{binding type 'b' only applies to types containing constant buffer resources}}
Eg7 e7 : register(b0);

struct Eg8 {
float f;
};
// expected-warning@+1{{binding type 's' only applies to types containing sampler state}}
Eg8 e8 : register(s0);

struct Eg9 {
MySRV s;
};
// expected-warning@+1{{binding type 'c' only applies to types containing numeric types}}
Eg9 e9 : register(c0);

struct Eg10{
// expected-error@+1{{'register' attribute only applies to cbuffer/tbuffer and external global variables}}
MyTemplatedUAV<int> a : register(u9);
};
Eg10 e10;


template<typename R>
struct Eg11 {
R b;
};
// expected-warning@+1{{binding type 'u' only applies to types containing UAV resources}}
Eg11<MySRV> e11 : register(u0);
// invalid because after template expansion, there are no valid resources inside Eg11 to bind as a UAV, only an SRV


struct Eg12{
MySRV s1;
MySRV s2;
};
// expected-warning@+2{{binding type 'u' only applies to types containing UAV resources}}
// expected-error@+1{{binding type 'u' cannot be applied more than once}}
Eg12 e12 : register(u9) : register(u10);

struct Eg13{
MySRV s1;
MySRV s2;
};
// expected-warning@+3{{binding type 'u' only applies to types containing UAV resources}}
// expected-error@+2{{binding type 'u' cannot be applied more than once}}
// expected-error@+1{{binding type 'u' cannot be applied more than once}}
Eg13 e13 : register(u9) : register(u10) : register(u11);

// expected-error@+1{{binding type 't' cannot be applied more than once}}
Eg13 e13_2 : register(t11) : register(t12);

struct Eg14{
MyTemplatedUAV<int> r1;
};
// expected-warning@+1{{binding type 't' only applies to types containing SRV resources}}
Eg14 e14 : register(t9);

struct Eg15 {
float f[4];
};
// expected no error
Eg15 e15 : register(c0);
2 changes: 1 addition & 1 deletion clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ Expected<std::unique_ptr<lto::LTO>> createLTO(const ArgList &Args) {
Conf.RemarksHotnessThreshold = RemarksHotnessThreshold;
Conf.RemarksFormat = RemarksFormat;

Conf.MAttrs = {Args.getLastArgValue(OPT_feature, "").str()};
Conf.MAttrs = llvm::codegen::getMAttrs();
std::optional<CodeGenOptLevel> CGOptLevelOrNone =
CodeGenOpt::parseLevel(Args.getLastArgValue(OPT_O, "2")[0]);
assert(CGOptLevelOrNone && "Invalid optimization level");
Expand Down
3 changes: 0 additions & 3 deletions clang/tools/clang-nvlink-wrapper/NVLinkOpts.td
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ def arch : Separate<["--", "-"], "arch">,
def : Joined<["--", "-"], "plugin-opt=mcpu=">,
Flags<[HelpHidden, WrapperOnlyOption]>, Alias<arch>;

def feature : Separate<["--", "-"], "feature">, Flags<[WrapperOnlyOption]>,
HelpText<"Specify the '+ptx' freature to use for LTO.">;

def g : Flag<["-"], "g">, HelpText<"Specify that this was a debug compile.">;
def debug : Flag<["--"], "debug">, Alias<g>;

Expand Down
2 changes: 1 addition & 1 deletion clang/tools/scan-build/bin/scan-build.bat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
perl -S scan-build %*
perl -S scan-build %*
2 changes: 1 addition & 1 deletion clang/tools/scan-build/libexec/c++-analyzer.bat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
perl -S c++-analyzer %*
perl -S c++-analyzer %*
2 changes: 1 addition & 1 deletion clang/tools/scan-build/libexec/ccc-analyzer.bat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
perl -S ccc-analyzer %*
perl -S ccc-analyzer %*
2,178 changes: 1,089 additions & 1,089 deletions clang/utils/ClangVisualizers/clang.natvis

Large diffs are not rendered by default.

51 changes: 46 additions & 5 deletions compiler-rt/lib/lsan/lsan_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,27 @@ struct DirectMemoryAccessor {
void Init(uptr begin, uptr end) {};
void *LoadPtr(uptr p) const { return *reinterpret_cast<void **>(p); }
};

struct CopyMemoryAccessor {
void Init(uptr begin, uptr end) {
this->begin = begin;
buffer.clear();
buffer.resize(end - begin);
MemCpyAccessible(buffer.data(), reinterpret_cast<void *>(begin),
buffer.size());
};

void *LoadPtr(uptr p) const {
uptr offset = p - begin;
CHECK_LE(offset + sizeof(void *), reinterpret_cast<uptr>(buffer.size()));
return *reinterpret_cast<void **>(offset +
reinterpret_cast<uptr>(buffer.data()));
}

private:
uptr begin;
InternalMmapVector<char> buffer;
};
} // namespace

// Scans the memory range, looking for byte patterns that point into allocator
Expand Down Expand Up @@ -373,18 +394,18 @@ void ScanGlobalRange(uptr begin, uptr end, Frontier *frontier) {
}

template <class Accessor>
void ScanExtraStack(const InternalMmapVector<Range> &ranges, Frontier *frontier,
Accessor &accessor) {
void ScanRanges(const InternalMmapVector<Range> &ranges, Frontier *frontier,
const char *region_type, Accessor &accessor) {
for (uptr i = 0; i < ranges.size(); i++) {
ScanForPointers(ranges[i].begin, ranges[i].end, frontier, "FAKE STACK",
ScanForPointers(ranges[i].begin, ranges[i].end, frontier, region_type,
kReachable, accessor);
}
}

void ScanExtraStackRanges(const InternalMmapVector<Range> &ranges,
Frontier *frontier) {
DirectMemoryAccessor accessor;
ScanExtraStack(ranges, frontier, accessor);
ScanRanges(ranges, frontier, "FAKE STACK", accessor);
}

# if SANITIZER_FUCHSIA
Expand Down Expand Up @@ -478,7 +499,7 @@ static void ProcessThread(tid_t os_id, uptr sp,
ScanForPointers(stack_begin, stack_end, frontier, "STACK", kReachable,
accessor);
GetThreadExtraStackRangesLocked(os_id, &extra_ranges);
ScanExtraStack(extra_ranges, frontier, accessor);
ScanRanges(extra_ranges, frontier, "FAKE STACK", accessor);
}

if (flags()->use_tls) {
Expand Down Expand Up @@ -535,6 +556,7 @@ static void ProcessThread(tid_t os_id, uptr sp,
static void ProcessThreads(SuspendedThreadsList const &suspended_threads,
Frontier *frontier, tid_t caller_tid,
uptr caller_sp) {
InternalMmapVector<tid_t> done_threads;
InternalMmapVector<uptr> registers;
InternalMmapVector<Range> extra_ranges;
for (uptr i = 0; i < suspended_threads.ThreadCount(); i++) {
Expand All @@ -559,6 +581,25 @@ static void ProcessThreads(SuspendedThreadsList const &suspended_threads,

DirectMemoryAccessor accessor;
ProcessThread(os_id, sp, registers, extra_ranges, frontier, accessor);
if (flags()->use_detached)
done_threads.push_back(os_id);
}

if (flags()->use_detached) {
CopyMemoryAccessor accessor;
InternalMmapVector<tid_t> known_threads;
GetRunningThreadsLocked(&known_threads);
Sort(done_threads.data(), done_threads.size());
for (tid_t os_id : known_threads) {
registers.clear();
extra_ranges.clear();

uptr i = InternalLowerBound(done_threads, os_id);
if (i >= done_threads.size() || done_threads[i] != os_id) {
uptr sp = (os_id == caller_tid) ? caller_sp : 0;
ProcessThread(os_id, sp, registers, extra_ranges, frontier, accessor);
}
}
}

// Add pointers reachable from ThreadContexts
Expand Down
2 changes: 2 additions & 0 deletions compiler-rt/lib/lsan/lsan_flags.inc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ LSAN_FLAG(bool, use_ld_allocations, true,
LSAN_FLAG(bool, use_unaligned, false, "Consider unaligned pointers valid.")
LSAN_FLAG(bool, use_poisoned, false,
"Consider pointers found in poisoned memory to be valid.")
LSAN_FLAG(bool, use_detached, false,
"Scan threads even if attaching to them failed.")
LSAN_FLAG(bool, log_pointers, false, "Debug logging")
LSAN_FLAG(bool, log_threads, false, "Debug logging")
LSAN_FLAG(int, tries, 1, "Debug option to repeat leak checking multiple times")
Expand Down
72 changes: 36 additions & 36 deletions flang/test/Driver/msvc-dependent-lib-flags.f90
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
! RUN: %flang -### --target=aarch64-windows-msvc -resource-dir=%S/Inputs/resource_dir %S/Inputs/hello.f90 -v 2>&1 | FileCheck %s --check-prefixes=MSVC
! RUN: %flang -### --target=aarch64-windows-msvc -resource-dir=%S/Inputs/resource_dir -fms-runtime-lib=static_dbg %S/Inputs/hello.f90 -v 2>&1 | FileCheck %s --check-prefixes=MSVC-DEBUG
! RUN: %flang -### --target=aarch64-windows-msvc -resource-dir=%S/Inputs/resource_dir -fms-runtime-lib=dll %S/Inputs/hello.f90 -v 2>&1 | FileCheck %s --check-prefixes=MSVC-DLL
! RUN: %flang -### --target=aarch64-windows-msvc -resource-dir=%S/Inputs/resource_dir -fms-runtime-lib=dll_dbg %S/Inputs/hello.f90 -v 2>&1 | FileCheck %s --check-prefixes=MSVC-DLL-DEBUG

! MSVC: -fc1
! MSVC-SAME: --dependent-lib=clang_rt.builtins.lib
! MSVC-SAME: -D_MT
! MSVC-SAME: --dependent-lib=libcmt
! MSVC-SAME: --dependent-lib=FortranRuntime.static.lib
! MSVC-SAME: --dependent-lib=FortranDecimal.static.lib

! MSVC-DEBUG: -fc1
! MSVC-DEBUG-SAME: --dependent-lib=clang_rt.builtins.lib
! MSVC-DEBUG-SAME: -D_MT
! MSVC-DEBUG-SAME: -D_DEBUG
! MSVC-DEBUG-SAME: --dependent-lib=libcmtd
! MSVC-DEBUG-SAME: --dependent-lib=FortranRuntime.static_dbg.lib
! MSVC-DEBUG-SAME: --dependent-lib=FortranDecimal.static_dbg.lib

! MSVC-DLL: -fc1
! MSVC-DLL-SAME: --dependent-lib=clang_rt.builtins.lib
! MSVC-DLL-SAME: -D_MT
! MSVC-DLL-SAME: -D_DLL
! MSVC-DLL-SAME: --dependent-lib=msvcrt
! MSVC-DLL-SAME: --dependent-lib=FortranRuntime.dynamic.lib
! MSVC-DLL-SAME: --dependent-lib=FortranDecimal.dynamic.lib

! MSVC-DLL-DEBUG: -fc1
! MSVC-DLL-DEBUG-SAME: --dependent-lib=clang_rt.builtins.lib
! MSVC-DLL-DEBUG-SAME: -D_MT
! MSVC-DLL-DEBUG-SAME: -D_DEBUG
! MSVC-DLL-DEBUG-SAME: -D_DLL
! MSVC-DLL-DEBUG-SAME: --dependent-lib=msvcrtd
! MSVC-DLL-DEBUG-SAME: --dependent-lib=FortranRuntime.dynamic_dbg.lib
! MSVC-DLL-DEBUG-SAME: --dependent-lib=FortranDecimal.dynamic_dbg.lib
! RUN: %flang -### --target=aarch64-windows-msvc -resource-dir=%S/Inputs/resource_dir %S/Inputs/hello.f90 -v 2>&1 | FileCheck %s --check-prefixes=MSVC
! RUN: %flang -### --target=aarch64-windows-msvc -resource-dir=%S/Inputs/resource_dir -fms-runtime-lib=static_dbg %S/Inputs/hello.f90 -v 2>&1 | FileCheck %s --check-prefixes=MSVC-DEBUG
! RUN: %flang -### --target=aarch64-windows-msvc -resource-dir=%S/Inputs/resource_dir -fms-runtime-lib=dll %S/Inputs/hello.f90 -v 2>&1 | FileCheck %s --check-prefixes=MSVC-DLL
! RUN: %flang -### --target=aarch64-windows-msvc -resource-dir=%S/Inputs/resource_dir -fms-runtime-lib=dll_dbg %S/Inputs/hello.f90 -v 2>&1 | FileCheck %s --check-prefixes=MSVC-DLL-DEBUG

! MSVC: -fc1
! MSVC-SAME: --dependent-lib=clang_rt.builtins.lib
! MSVC-SAME: -D_MT
! MSVC-SAME: --dependent-lib=libcmt
! MSVC-SAME: --dependent-lib=FortranRuntime.static.lib
! MSVC-SAME: --dependent-lib=FortranDecimal.static.lib

! MSVC-DEBUG: -fc1
! MSVC-DEBUG-SAME: --dependent-lib=clang_rt.builtins.lib
! MSVC-DEBUG-SAME: -D_MT
! MSVC-DEBUG-SAME: -D_DEBUG
! MSVC-DEBUG-SAME: --dependent-lib=libcmtd
! MSVC-DEBUG-SAME: --dependent-lib=FortranRuntime.static_dbg.lib
! MSVC-DEBUG-SAME: --dependent-lib=FortranDecimal.static_dbg.lib

! MSVC-DLL: -fc1
! MSVC-DLL-SAME: --dependent-lib=clang_rt.builtins.lib
! MSVC-DLL-SAME: -D_MT
! MSVC-DLL-SAME: -D_DLL
! MSVC-DLL-SAME: --dependent-lib=msvcrt
! MSVC-DLL-SAME: --dependent-lib=FortranRuntime.dynamic.lib
! MSVC-DLL-SAME: --dependent-lib=FortranDecimal.dynamic.lib

! MSVC-DLL-DEBUG: -fc1
! MSVC-DLL-DEBUG-SAME: --dependent-lib=clang_rt.builtins.lib
! MSVC-DLL-DEBUG-SAME: -D_MT
! MSVC-DLL-DEBUG-SAME: -D_DEBUG
! MSVC-DLL-DEBUG-SAME: -D_DLL
! MSVC-DLL-DEBUG-SAME: --dependent-lib=msvcrtd
! MSVC-DLL-DEBUG-SAME: --dependent-lib=FortranRuntime.dynamic_dbg.lib
! MSVC-DLL-DEBUG-SAME: --dependent-lib=FortranDecimal.dynamic_dbg.lib
2 changes: 2 additions & 0 deletions libc/config/gpu/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,9 @@ if(LIBC_TYPES_HAS_FLOAT16)
libc.src.math.llogbf16
libc.src.math.llrintf16
libc.src.math.llroundf16
libc.src.math.log2f16
libc.src.math.logbf16
libc.src.math.logf16
libc.src.math.lrintf16
libc.src.math.lroundf16
libc.src.math.modff16
Expand Down
2 changes: 2 additions & 0 deletions libc/config/linux/x86_64/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,9 @@ if(LIBC_TYPES_HAS_FLOAT16)
libc.src.math.llogbf16
libc.src.math.llrintf16
libc.src.math.llroundf16
libc.src.math.log2f16
libc.src.math.logbf16
libc.src.math.logf16
libc.src.math.lrintf16
libc.src.math.lroundf16
libc.src.math.modff16
Expand Down
4 changes: 2 additions & 2 deletions libc/docs/math/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -310,15 +310,15 @@ Higher Math Functions
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| lgamma | | | | | | 7.12.8.3 | F.10.5.3 |
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| log | |check| | |check| | | | | 7.12.6.11 | F.10.3.11 |
| log | |check| | |check| | | |check| | | 7.12.6.11 | F.10.3.11 |
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| log10 | |check| | |check| | | | | 7.12.6.12 | F.10.3.12 |
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| log10p1 | | | | | | 7.12.6.13 | F.10.3.13 |
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| log1p | |check| | |check| | | | | 7.12.6.14 | F.10.3.14 |
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| log2 | |check| | |check| | | | | 7.12.6.15 | F.10.3.15 |
| log2 | |check| | |check| | | |check| | | 7.12.6.15 | F.10.3.15 |
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| log2p1 | | | | | | 7.12.6.16 | F.10.3.16 |
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
Expand Down
2 changes: 2 additions & 0 deletions libc/spec/stdc.td
Original file line number Diff line number Diff line change
Expand Up @@ -648,9 +648,11 @@ def StdC : StandardSpec<"stdc"> {

FunctionSpec<"log2", RetValSpec<DoubleType>, [ArgSpec<DoubleType>]>,
FunctionSpec<"log2f", RetValSpec<FloatType>, [ArgSpec<FloatType>]>,
GuardedFunctionSpec<"log2f16", RetValSpec<Float16Type>, [ArgSpec<Float16Type>], "LIBC_TYPES_HAS_FLOAT16">,

FunctionSpec<"log", RetValSpec<DoubleType>, [ArgSpec<DoubleType>]>,
FunctionSpec<"logf", RetValSpec<FloatType>, [ArgSpec<FloatType>]>,
GuardedFunctionSpec<"logf16", RetValSpec<Float16Type>, [ArgSpec<Float16Type>], "LIBC_TYPES_HAS_FLOAT16">,

FunctionSpec<"logb", RetValSpec<DoubleType>, [ArgSpec<DoubleType>]>,
FunctionSpec<"logbf", RetValSpec<FloatType>, [ArgSpec<FloatType>]>,
Expand Down
2 changes: 2 additions & 0 deletions libc/src/math/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,11 @@ add_math_entrypoint_object(log1pf)

add_math_entrypoint_object(log2)
add_math_entrypoint_object(log2f)
add_math_entrypoint_object(log2f16)

add_math_entrypoint_object(log)
add_math_entrypoint_object(logf)
add_math_entrypoint_object(logf16)

add_math_entrypoint_object(logb)
add_math_entrypoint_object(logbf)
Expand Down
44 changes: 44 additions & 0 deletions libc/src/math/generic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2250,6 +2250,28 @@ add_entrypoint_object(
-O3
)

add_entrypoint_object(
log2f16
SRCS
log2f16.cpp
HDRS
../log2f16.h
DEPENDS
.expxf16
libc.hdr.errno_macros
libc.hdr.fenv_macros
libc.src.__support.FPUtil.cast
libc.src.__support.FPUtil.except_value_utils
libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
libc.src.__support.FPUtil.multiply_add
libc.src.__support.FPUtil.polyeval
libc.src.__support.macros.optimization
libc.src.__support.macros.properties.cpu_features
COMPILE_OPTIONS
-O3
)

add_entrypoint_object(
log
SRCS
Expand Down Expand Up @@ -2289,6 +2311,28 @@ add_entrypoint_object(
-O3
)

add_entrypoint_object(
logf16
SRCS
logf16.cpp
HDRS
../logf16.h
DEPENDS
.expxf16
libc.hdr.errno_macros
libc.hdr.fenv_macros
libc.src.__support.FPUtil.cast
libc.src.__support.FPUtil.except_value_utils
libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
libc.src.__support.FPUtil.multiply_add
libc.src.__support.FPUtil.polyeval
libc.src.__support.macros.optimization
libc.src.__support.macros.properties.cpu_features
COMPILE_OPTIONS
-O3
)

add_entrypoint_object(
logb
SRCS
Expand Down
42 changes: 42 additions & 0 deletions libc/src/math/generic/expxf16.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,48 @@ template <bool IsSinh> LIBC_INLINE float16 eval_sinh_or_cosh(float16 x) {
lo, half_p_odd * exp2_hi_mid_diff, half_p_even * exp2_hi_mid_sum));
}

// Generated by Sollya with the following commands:
// > display = hexadecimal;
// > for i from 0 to 31 do print(round(log(1 + i * 2^-5), SG, RN));
constexpr cpp::array<float, 32> LOGF_F = {
0x0p+0f, 0x1.f829bp-6f, 0x1.f0a30cp-5f, 0x1.6f0d28p-4f,
0x1.e27076p-4f, 0x1.29553p-3f, 0x1.5ff308p-3f, 0x1.9525aap-3f,
0x1.c8ff7cp-3f, 0x1.fb9186p-3f, 0x1.1675cap-2f, 0x1.2e8e2cp-2f,
0x1.4618bcp-2f, 0x1.5d1bdcp-2f, 0x1.739d8p-2f, 0x1.89a338p-2f,
0x1.9f323ep-2f, 0x1.b44f78p-2f, 0x1.c8ff7cp-2f, 0x1.dd46ap-2f,
0x1.f128f6p-2f, 0x1.02552ap-1f, 0x1.0be72ep-1f, 0x1.154c3ep-1f,
0x1.1e85f6p-1f, 0x1.2795e2p-1f, 0x1.307d74p-1f, 0x1.393e0ep-1f,
0x1.41d8fep-1f, 0x1.4a4f86p-1f, 0x1.52a2d2p-1f, 0x1.5ad404p-1f,
};

// Generated by Sollya with the following commands:
// > display = hexadecimal;
// > for i from 0 to 31 do print(round(log2(1 + i * 2^-5), SG, RN));
constexpr cpp::array<float, 32> LOG2F_F = {
0x0p+0f, 0x1.6bad38p-5f, 0x1.663f7p-4f, 0x1.08c588p-3f,
0x1.5c01a4p-3f, 0x1.acf5e2p-3f, 0x1.fbc16cp-3f, 0x1.24407ap-2f,
0x1.49a784p-2f, 0x1.6e221cp-2f, 0x1.91bba8p-2f, 0x1.b47ecp-2f,
0x1.d6753ep-2f, 0x1.f7a856p-2f, 0x1.0c105p-1f, 0x1.1bf312p-1f,
0x1.2b8034p-1f, 0x1.3abb4p-1f, 0x1.49a784p-1f, 0x1.584822p-1f,
0x1.66a008p-1f, 0x1.74b1fep-1f, 0x1.82809ep-1f, 0x1.900e62p-1f,
0x1.9d5dap-1f, 0x1.aa709p-1f, 0x1.b74948p-1f, 0x1.c3e9cap-1f,
0x1.d053f6p-1f, 0x1.dc899ap-1f, 0x1.e88c6cp-1f, 0x1.f45e08p-1f,
};

// Generated by Sollya with the following commands:
// > display = hexadecimal;
// > for i from 0 to 31 do print(round(1 / (1 + i * 2^-5), SG, RN));
constexpr cpp::array<float, 32> ONE_OVER_F_F = {
0x1p+0f, 0x1.f07c2p-1f, 0x1.e1e1e2p-1f, 0x1.d41d42p-1f,
0x1.c71c72p-1f, 0x1.bacf92p-1f, 0x1.af286cp-1f, 0x1.a41a42p-1f,
0x1.99999ap-1f, 0x1.8f9c18p-1f, 0x1.861862p-1f, 0x1.7d05f4p-1f,
0x1.745d18p-1f, 0x1.6c16c2p-1f, 0x1.642c86p-1f, 0x1.5c9882p-1f,
0x1.555556p-1f, 0x1.4e5e0ap-1f, 0x1.47ae14p-1f, 0x1.414142p-1f,
0x1.3b13b2p-1f, 0x1.3521dp-1f, 0x1.2f684cp-1f, 0x1.29e412p-1f,
0x1.24924ap-1f, 0x1.1f7048p-1f, 0x1.1a7b96p-1f, 0x1.15b1e6p-1f,
0x1.111112p-1f, 0x1.0c9714p-1f, 0x1.08421p-1f, 0x1.041042p-1f,
};

} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_MATH_GENERIC_EXPXF16_H
Loading