This is an archive of the discontinued LLVM Phabricator instance.

[HLSL] Enable availability attribute
ClosedPublic

Authored by beanz on Sep 16 2022, 12:46 PM.

Details

Summary

Some HLSL functionality is gated on the target shader model version.
Enabling the use of availability markup allows us to diagnose
availability issues easily in the frontend.

Diff Detail

Event Timeline

beanz created this revision.Sep 16 2022, 12:46 PM
Herald added a project: Restricted Project. · View Herald Transcript
beanz requested review of this revision.Sep 16 2022, 12:46 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 16 2022, 12:46 PM
erichkeane added inline comments.Sep 16 2022, 12:51 PM
clang/lib/Sema/SemaAvailability.cpp
201

This should jsut be a 'case' label added above, we are already switching on getOS.

clang/test/SemaHLSL/AvailabilityMarkup.hlsl
11

Not sure how I feel about us testing the headers AND functionality in the same place. @aaron.ballman : Does this seem inappropriate to you?

beanz updated this revision to Diff 460869.Sep 16 2022, 1:10 PM

Updating based on feedback from @erichkeane. Thank you for the fast feedback!

  • Moved ShaderModel check into a switch case.
  • Added additional self-contained test case with more variations.
erichkeane accepted this revision.Sep 16 2022, 1:16 PM

Besides the request for re-organizing the the test files, LGTM.

clang/test/SemaHLSL/AvailabilityMarkup.hlsl
16

So minor thing, and one that I am going to start pushing for more, is better organization of 'expected-diagnostics'. I think they should better reflect the order and 'cause' of the diagnostic, particularly with notes. So something like:

// expected-warning@+3 {{... only available ...}}
// expected-note@#FN60_LOC {{ marked as being introduced...}}
// expected-note@+1{{enclose...}}

Then on line 5, add the comment: // FN60

I have this preference because it makes it more clear to the reader where the notes come from. I realize this is a new direction, and perhaps pushing my ability to request, but I'd still appreciate it happening here (I WILL be pushing for it on template reviews, where I think it is even MORE beneficial, thanks to 'instantiation of' diagnostics, and I have the authority to demand it :) ).

clang/test/SemaHLSL/WaveBuiltinAvailability.hlsl
11

Same here, though perhaps less-so. You can use @hlsl_intrinsics.h:14 I believe to specify the line as well (which would be nice!) but keeping the diagnostics in 'emitted order' is more important to me.

This revision is now accepted and ready to land.Sep 16 2022, 1:16 PM
beanz added inline comments.Sep 16 2022, 1:25 PM
clang/test/SemaHLSL/AvailabilityMarkup.hlsl
16

I was completely unaware of the ability to create labels like that. That's awesome. I'll update the tests.

beanz updated this revision to Diff 460879.Sep 16 2022, 1:29 PM

Updating test cases to use labels and sort the matches.

Still looks good to me, no nits. As far as using the bookmarks, I tend to use them for things that are 'far away' instead of 'right here', and stick to the @+/@- bits for 'local' ones.

clang/test/SemaHLSL/AvailabilityMarkup.hlsl
14

Your preference here, but the @+3 here is acceptable when they are 'local'. I have no preference either way.

This revision was landed with ongoing or failed builds.Sep 16 2022, 2:04 PM
This revision was automatically updated to reflect the committed changes.