Remove unused target types from !dx.targetTypes metadata#8202
Remove unused target types from !dx.targetTypes metadata#8202hekota merged 5 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.
| // mat1 = Matrix::Splat(5); | ||
| __builtin_LinAlg_FillMatrix(mat1, 5); | ||
|
|
||
| // Matrix<ComponentType::I32, 4, 5, MatrixUse::A, MatrixScope::Thread> m; |
There was a problem hiding this comment.
nit: Looks like this comment is out of sync
#8202 and #8233 collided post merge to reveal a long standing bug with `-lib_6_x` that is currently breaking CI on main. This change fixes that bug by skipping reachable call diagnostics in the case that they are allowed to be transiently invalid. The comment in the PR is a bit more verbose on the details and I'll avoid reposting it here.
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