Remove unused target types from !dx.targetTypes metadata#8202
Remove unused target types from !dx.targetTypes metadata#8202hekota wants to merge 4 commits intomicrosoft:mainfrom
!dx.targetTypes metadata#8202Conversation
…ntains types that are actually used module. Introduces a new pass `DxilTrimTargetTypes` that runs towards the end of the pipeline and re-creates the `!dx.targetTypes` metadata node with only the target types used in the module. This pass runs during single shader compilation and also when multiple lib_6_x modules are linked together for SM 6.10. Fixes microsoft#8133
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
damyanp
left a comment
There was a problem hiding this comment.
LGTM, but I mostly reviewed for style type things. Mostly typos, but there's enough that we should probably try and fix them.
Oops :) |
|
|
||
| // Map of target type to its metadata node and usage flag. | ||
| using TargetTypesUsageMap = | ||
| SmallDenseMap<llvm::Type *, std::pair<MDTuple *, bool>, 16>; |
There was a problem hiding this comment.
Question: do we actually need to track whether or not types are used, or should we just collect the list of types that are and replace the metadata?
It seems to me that re-computing the set of used types is probably faster than looking at the existing set and determining if it is correct.
There was a problem hiding this comment.
If we just collect the list of types that are used, we will need to parse the type name to reconstruct the metadata constants. I was under the impression that that's what we want to avoid.
| static const char *m_NamePrefix; | ||
| static const char *m_TypePrefix; | ||
| static const char *m_MatrixTypePrefix; | ||
| static const char *m_LinAlgNamePrefix; |
There was a problem hiding this comment.
The dx.types version of this was put into DxilUtil in this PR https://github.com/microsoft/DirectXShaderCompiler/pull/8186/changes
Might make sense to have them next to each other?
Make sure
!dx.targetTypesmetadata node in the final module only contains types that are actually used module. Introduces a new passDxilTrimTargetTypesthat runs towards the end of the pipeline and re-creates the!dx.targetTypesmetadata node with only the target types used in the module. This pass runs during single shader compilation and also when multiple lib_6_x modules are linked together for SM 6.10.Fixes #8133