Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[HLSL] Enable HLSL availability diagnostic on exported library functions and add tests #92073

Open
Tracked by #87389
hekota opened this issue May 14, 2024 · 0 comments
Open
Tracked by #87389
Assignees
Labels
HLSL HLSL Language Support

Comments

@hekota
Copy link
Member

hekota commented May 14, 2024

This is a tracking work item to enable HLSL availability diagnostic on exported library functions and to add tests. This can happen as soon as #92071 is resolved, HLSL functions have internal linkage by default and the export keyword is implemented.

The diagnostic of exported function can be enabled in DiagnoseHLSLAvailability::RunOnTranslationUnit.

The tests should be added to the files in clang\test\SemaHLSL\Availability for all diagnostic modes. For example this is the minimum that should be added to AvailabilityDefaultLibrary.hlsl:

// Exported function without body
export void exportedFunction(float f);

// Exported function with body
export void exportedFunction(float f) {
  // expected-error@#exportedFunction_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); // #exportedFunction_fx_call

  // API with shader-stage-specific availability in exported library function
  // - no errors expected because the actual shader stage this function
  // will be used in not known at this time
  float B = fy(f);
  float C = fz(f);
}
@hekota hekota changed the title Enable HLSL diagnostic on exported library functions and add tests Enable HLSL availability diagnostic on exported library functions and add tests May 14, 2024
@hekota hekota changed the title Enable HLSL availability diagnostic on exported library functions and add tests [HLSL] Enable HLSL availability diagnostic on exported library functions and add tests May 14, 2024
@hekota hekota added the HLSL HLSL Language Support label May 14, 2024
@hekota hekota self-assigned this May 14, 2024
hekota added a commit that referenced this issue May 30, 2024
Implements HLSL availability diagnostics' default and relaxed mode.

HLSL availability diagnostics emits errors or warning when unavailable
shader APIs are used. Unavailable shader APIs are APIs that are exposed
in HLSL code but are not available in the target shader stage or shader
model version.

In the default mode the compiler emits an error when an unavailable API
is found in a code that is reachable from the shader entry point
function. In the future this check will also extended to exported
library functions (#92073). The relaxed diagnostic mode is the same
except the compiler emits a warning. This mode is enabled by
``-Wno-error=hlsl-availability``.

See HLSL Availability Diagnostics design doc
[here](https://github.com/llvm/llvm-project/blob/main/clang/docs/HLSL/AvailabilityDiagnostics.rst)
for more details.

Fixes #90095
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
HLSL HLSL Language Support
Projects
Status: No status
Development

No branches or pull requests

2 participants