[HLSL2021] Fix template parameter for buffer types#4099
Merged
llvm-beanz merged 1 commit intomicrosoft:masterfrom Nov 24, 2021
Merged
[HLSL2021] Fix template parameter for buffer types#4099llvm-beanz merged 1 commit intomicrosoft:masterfrom
llvm-beanz merged 1 commit intomicrosoft:masterfrom
Conversation
This is a bit of an oddball situation caused by a two factors. (1) We verify that template parameters for buffer types are complete (2) The template expansion for the HLSL buffer types doesn't actually require instantiation of the parameter type We could, skip verification of template parameters, but doing so causes the backend to crash because we need the buffer type expanded for code generation. Skipping verification might work in some common cases, but will fail if buffers are unused, and if nothing else forces the instantiation. The safe approach is to force instantiation ourselves, and that's what this change does. Basically if the parameter of a buffer type is a template specialization, we force the specialization to instantiate by creating the specialization in the AST. This allows us to continue verifing that the types are complete, because after instantiation the template type is complete.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a bit of an oddball situation caused by a two factors.
(1) We verify that template parameters for buffer types are complete
(2) The template expansion for the HLSL buffer types doesn't actually
require instantiation of the parameter type
We could, skip verification of template parameters, but doing so causes
the backend to crash because we need the buffer type expanded for code
generation. Skipping verification might work in some common cases, but
will fail if buffers are unused, and if nothing else forces the
instantiation.
The safe approach is to force instantiation ourselves, and that's what
this change does. Basically if the parameter of a buffer type is a
template specialization, we force the specialization to instantiate by
creating the specialization in the AST.
This allows us to continue verifing that the types are complete,
because after instantiation the template type is complete.