Reimplement the DecorationManager
authorPierre Moreau <dev@pmoreau.org>
Tue, 20 Feb 2018 18:19:57 +0000 (19:19 +0100)
committerSteven Perron <stevenperron@google.com>
Mon, 12 Mar 2018 13:56:14 +0000 (09:56 -0400)
commit5bd55f10cd17333bf0e5deec2471ab79389c0cc9
treeba81d49313902a34e2f74044f7d3fbdca19bc4ea
parent340370eddbb9f0e7d26b6a4f7e22c1b98150e5e1
Reimplement the DecorationManager

This reimplementation fixes several issues when removing decorations associated
to an ID (partially addresses #1174 and gives tools for fixing #898), as well
as making it easier to remove groups; a few additional tests have been added.

DecorationManager::RemoveDecoration() will still not delete dead decorations it
created, but I do not think it is its job either; given the following input

```
OpCapability Shader
OpCapability Linkage
OpMemoryModel Logical GLSL450
OpDecorate %2 Restrict
%2      = OpDecorationGroup
OpGroupDecorate %2 %1 %3
OpDecorate %4 Invariant
%4      = OpDecorationGroup
OpGroupDecorate %4 %2
%uint   = OpTypeInt 32 0
%1      = OpVariable %uint Uniform
%3      = OpVariable %uint Uniform
```

which of the following two outputs would you expect RemoveDecoration(2) to produce:

```
OpCapability Shader
OpCapability Linkage
OpMemoryModel Logical GLSL450
%uint = OpTypeInt 32 0
%1 = OpVariable %uint Uniform
%3 = OpVariable %uint Uniform
```

or

```
OpCapability Shader
OpCapability Linkage
OpMemoryModel Logical GLSL450
OpDecorate %4 Invariant
%4      = OpDecorationGroup
%uint   = OpTypeInt 32 0
%1      = OpVariable %uint Uniform
%3      = OpVariable %uint Uniform
```

Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/924
Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/1174
source/opt/decoration_manager.cpp
source/opt/decoration_manager.h
source/opt/inline_pass.cpp
source/opt/inline_pass.h
source/opt/instruction.h
test/opt/decoration_manager_test.cpp