- Notifications
You must be signed in to change notification settings - Fork 803
Improve library profile diagnostics #5789
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
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move these tests into test/SemaHLSL/attributes and have them be run using %dxc ... %s -verify instead?
I strongly suspect if we did that these tests would fail because it looks to me like we're emitting errors for this twice because the old code is still there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed.
Also, many entry point diagnostics can be checked in a single HLSL file with a lib target, rather than having one file per scenario. With this new codepath, the entry point checks are the same code path between lib and normal shader entry cases, making it possible to separate the unit tests for adding the shader attribute for the non-lib case from verification of all the entry point rules.
| Shouldn't there be corresponding diagnostic code deleted from |
No, because the only thing CGHLSLMS.cpp does is check if the attribute exists, and if it does, verify that it is on a valid shader stage. It does not ever first check the shader stage, and validate that all necessary/required attributes exist. |
|
|
…file, move to semahlsl/attributes
| PR contains clang-format violations. First 50 lines of the diff: --- tools/clang/lib/Sema/SemaHLSL.cpp (before formatting) +++ tools/clang/lib/Sema/SemaHLSL.cpp (after formatting) @@ -11387,7 +11387,7 @@ if (pEntryPointDecl) { const auto *shaderModel = hlsl::ShaderModel::GetByName(self->getLangOpts().HLSLProfile.c_str()); - + if (shaderModel->IsHS()) { if (const HLSLPatchConstantFuncAttr *Attr = pEntryPointDecl->getAttr<HLSLPatchConstantFuncAttr>()) { --- tools/clang/unittests/HLSL/ValidationTest.cpp (before formatting) +++ tools/clang/unittests/HLSL/ValidationTest.cpp (after formatting) @@ -152,7 +152,7 @@ TEST_METHOD(DuplicateSysValue) TEST_METHOD(FunctionAttributes) TEST_METHOD(GSMainMissingAttributeFail) - TEST_METHOD(GSOtherMissingAttributeFail) + TEST_METHOD(GSOtherMissingAttributeFail) TEST_METHOD(GetAttributeAtVertexInVSFail) TEST_METHOD(GetAttributeAtVertexIn60Fail) TEST_METHOD(GetAttributeAtVertexInterpFail)See action log for the full diff. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
| I don't know why this can't go directly into main. I don't see any mention of nodes or other 6.8 features. |
| PR contains clang-format violations. First 50 lines of the diff: --- include/dxc/HLSL/HLOperations.h (before formatting) +++ include/dxc/HLSL/HLOperations.h (after formatting) @@ -293,7 +293,6 @@ const unsigned kSampleCmpClampArgIndex = 6; const unsigned kSampleCmpStatusArgIndex = 7; - // SampleCmpBias. const unsigned kSampleCmpBCmpValArgIndex = 4; const unsigned kSampleCmpBBiasArgIndex = 5; --- include/llvm/InitializePasses.h (before formatting) +++ include/llvm/InitializePasses.h (after formatting) @@ -258,7 +258,7 @@ void initializeDynamicIndexingVectorToArrayPass(PassRegistry&); void initializeMultiDimArrayToOneDimArrayPass(PassRegistry&); void initializeResourceToHandlePass(PassRegistry&); -void initializeLowerWaveMatTypePass(PassRegistry&); +void initializeLowerWaveMatTypePass(PassRegistry &); void initializeSROA_SSAUp_HLSLPass(PassRegistry&); void initializeHoistConstantArrayPass(PassRegistry&); void initializeDxilLoopUnrollPass(PassRegistry&); --- include/llvm/Transforms/Scalar.h (before formatting) +++ include/llvm/Transforms/Scalar.h (after formatting) @@ -185,7 +185,7 @@ // Flatten resource into handle. // ModulePass *createLowerWaveMatTypePass(); -void initializeLowerWaveMatTypePass(PassRegistry&); +void initializeLowerWaveMatTypePass(PassRegistry &); //===----------------------------------------------------------------------===// // Hoist a local array initialized with constant values to a global array with --- lib/DXIL/DxilWaveMatrix.cpp (before formatting) +++ lib/DXIL/DxilWaveMatrix.cpp (after formatting) @@ -19,7 +19,6 @@ #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" - using namespace llvm; --- lib/Transforms/Utils/Local.cpp (before formatting) +++ lib/Transforms/Utils/Local.cpp (after formatting) @@ -45,10 +45,10 @@ #include "llvm/Support/MathExtras.h" #include "llvm/Support/raw_ostream.h" +#include "dxc/DXIL/DxilInstructions.h" // HLSL Change - DxilInst_OutputComplete usage #include "dxc/DXIL/DxilMetadataHelper.h" // HLSL Change - combine dxil metadata.See action log for the full diff. |
| There seem to be some clang format issues. Perhaps I can cherry pick this over to main once it's in staging. |
| if (shaderModel->IsHS()) { | ||
| if (const HLSLPatchConstantFuncAttr *Attr = | ||
| pEntryPointDecl->getAttr<HLSLPatchConstantFuncAttr>()) { | ||
| NameLookup NL = GetSingleFunctionDeclByName( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this code be moved into DiagnoseHullEntry?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I can't move this block is because pPatchFnDecl is set by this block, and is used below when checking for recursion. If I moved it into DiagnoseHullEntry, I would need to repeat this code here anyways in order to set pPatchFnDecl.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realize that this code also captures the patch constant function for recursion check later. I think all this needs to be moved somewhere else eventually, since we need the recursion check on all functions (but also don't want to have to pay a cost of re-checking the same call graph over and over again).
Or is the reason this can't be moved also related to timing - maybe the patch constant function won't have been created yet when we are in DiagnoseEntry, for example?
| [shader("mesh")] | ||
| //[NumThreads(8, 8, 2)] | ||
| //[OutputTopology("triangle")] | ||
| void MSmain(out vertices myvert verts[32], /* expected-error{{mesh entry point must have the numthreads attribute}} */ /* expected-error{{mesh entry point must have the outputtopology attribute}} */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tip: for better readability, you can use syntax like: expected-error@+2, for instance:
// expected-error@+2{{mesh entry point must have the numthreads attribute}} // expected-error@+1{{mesh entry point must have the outputtopology attribute}} void MSmain(out vertices myvert verts[32],… shaders (#5858) Previously, there would be no recursion validation performed on any function declarations in library shaders. This PR adds code that validates that no function declarations that are found inside library shaders are recursive. The diagnostics aren't repeated, since there's logic to prevent the same diagnostic from being emitted by 2 similar ancestors of the same recursive function. The PR also adjusts recursion detection for shaders in non-library cases, and improves the original diagnostic by adding information about the name of the function that is recursive. The PR is meant to complete the work on issue #5789. However, more work needs to be done for full accuracy. The PR checks *all* function declarations in the translation unit for the library shader case, when it should really only be checking a subset of function declarations. This issue is filed here: #5857 Fixes #5789
There are several diagnostics that are missing when a function declaration that targets a specific shader stage is missing a necessary attribute. For example, if a hull shader function declaration does not have the patchconstantfunc attribute, there is no diagnosis of the missing attribute in sema. This PR addresses this diagnostic hole by filling in some functions that check that all required attributes exist for a given shader stage.
This PR partially addresses #5747