KhronosGroup / KhronosGroup/SPIRV-Tools
Disallows TypeManager::GetId on non unique types
- Dominant language
- C++
- Stars
- 1.4k
- Forks
- 709
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 28
Description
As was found in #5624, the multiple types in the module can hash to the same entry in the type manager. When `GetId` is called on one of these, the return value is not predictable. This can lead to errors when it returns the id of a type different than what is expected.
To solve this problem, we need to disallow calls to `GetId` where the type is not guarenteed to be unique in the spec. Before we can add the assert to enforce this restriction, we need to fix up the places in the code that uses `GetId` on types that are not necessarily unique.
The list of test buckets that fail when the assertion is added is:
- [ ] CopyPropArrayPassTest
- [ ] ElimDeadIOComponentsTest
- [ ] ElimDeadOutputStoresTest
- [x] FixStorageClassTest
- [ ] FixTypeTest
- [ ] GraphicsRobustAccessTest
- [ ] InlineTest
- [ ] InstDebugPrintfTest
- [ ] InterfaceVariableScalarReplacementTest
- [ ] TypeManager
- [ ] UpgradeMemoryModelTest
- [x] CompositeConstructFoldingTest
- [x] CompositeExtractOrInsertMatchingTest
- [x] AnalyzeLiveInputTest
- [x] ConvertToSampledImageTest
Not all of these issues will lead to real problems, but they all trigger the assert. We will also want to check with some real users to make sure their code does not trigger the assert before it lands.
Contributor guide
Assessment
This issue has not been assessed yet.