KhronosGroup / KhronosGroup/SPIRV-Tools
Disallow searches in the type manager for non-unique types.
- Dominant language
- C++
- Stars
- 1.4k
- Forks
- 709
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 28
Description
A common source of bugs in the optimizer is dealing with the type manager not returning the correct type. For example, suppose I have type 1 `struct { int a; }` and type 2 `struct { int b; }`. If I say I need the type of a struct that contain a single int, then the type manager can correctly return either type 1 or type 2.
This can be very easily overlooked especially because we use to be more aggressive at merging types, which hid a lot of these problems.
To make code more robust, I would like to disallow the constant manager from returning an id when it is possible that there are multiple possible answers.
This can be enforced by not including non-unique types in the type_to_id_ map. A non-unique id will be defined by `Type::IsUnique`.
I don't know how much code will need to change, but fix will lead to more stable results. As it stands now, the order in with types are defined can be the difference between hiding or exposing a bug.
Contributor guide
Assessment
This issue has not been assessed yet.