Don't remove SPIR-V blocks before codegen.

A removed block releases its instructions, so Module::idToInstruction
suddenly contains dangling references.  The original motivation for
block removal was to skip some unreachable blocks, but that's already
achieved by InReadableOrder.cpp.

Also updated stale comments.
This commit is contained in:
Dejan Mircevski
2016-01-19 21:13:38 -05:00
parent 33782795d9
commit ed55bcd9f8
17 changed files with 1233 additions and 1252 deletions

View File

@@ -7,12 +7,12 @@ Linked fragment stage:
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 153
// Id's are bound by 156
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 149
EntryPoint Fragment 4 "main" 152
ExecutionMode 4 OriginLowerLeft
Source GLSL 400
Name 4 "main"
@@ -29,25 +29,25 @@ Linked fragment stage:
Name 24 "r"
Name 28 "foo3("
Name 30 "sum"
Name 74 "u"
Name 86 "t"
Name 89 "s"
MemberName 89(s) 0 "t"
Name 91 "f"
Name 95 "color"
Name 101 "e"
Name 102 "param"
Name 103 "param"
Name 104 "param"
Name 76 "u"
Name 89 "t"
Name 92 "s"
MemberName 92(s) 0 "t"
Name 94 "f"
Name 98 "color"
Name 104 "e"
Name 105 "param"
Name 120 "ret"
Name 122 "tempReturn"
Name 127 "tempArg"
Name 128 "param"
Name 129 "param"
Name 130 "param"
Name 133 "arg"
Name 149 "gl_FragColor"
Name 106 "param"
Name 107 "param"
Name 108 "param"
Name 123 "ret"
Name 125 "tempReturn"
Name 130 "tempArg"
Name 131 "param"
Name 132 "param"
Name 133 "param"
Name 136 "arg"
Name 152 "gl_FragColor"
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 1
@@ -61,103 +61,103 @@ Linked fragment stage:
27: TypeFunction 6(int)
38: 6(int) Constant 64
43: 6(int) Constant 1024
61: 17(float) Constant 1077936128
65: 17(float) Constant 1084227584
66: TypeInt 32 0
67: 66(int) Constant 1
73: TypePointer UniformConstant 17(float)
74(u): 73(ptr) Variable UniformConstant
76: 17(float) Constant 1078774989
77: TypeBool
82: 6(int) Constant 1000000
84: 6(int) Constant 2000000
87: 6(int) Constant 2
88: TypeVector 6(int) 4
89(s): TypeStruct 88(ivec4)
90: TypePointer Function 89(s)
92: 6(int) Constant 0
93: 6(int) Constant 32
96: 6(int) Constant 1
100: 6(int) Constant 8
112: 6(int) Constant 128
121: TypePointer Private 6(int)
122(tempReturn): 121(ptr) Variable Private
123: 17(float) Constant 1082130432
124: 17(float) Constant 1065353216
125: 17(float) Constant 1073741824
126: 19(fvec3) ConstantComposite 124 125 61
147: TypeVector 17(float) 4
148: TypePointer Output 147(fvec4)
149(gl_FragColor): 148(ptr) Variable Output
62: 17(float) Constant 1077936128
66: 17(float) Constant 1084227584
67: TypeInt 32 0
68: 67(int) Constant 1
75: TypePointer UniformConstant 17(float)
76(u): 75(ptr) Variable UniformConstant
78: 17(float) Constant 1078774989
79: TypeBool
84: 6(int) Constant 1000000
86: 6(int) Constant 2000000
90: 6(int) Constant 2
91: TypeVector 6(int) 4
92(s): TypeStruct 91(ivec4)
93: TypePointer Function 92(s)
95: 6(int) Constant 0
96: 6(int) Constant 32
99: 6(int) Constant 1
103: 6(int) Constant 8
115: 6(int) Constant 128
124: TypePointer Private 6(int)
125(tempReturn): 124(ptr) Variable Private
126: 17(float) Constant 1082130432
127: 17(float) Constant 1065353216
128: 17(float) Constant 1073741824
129: 19(fvec3) ConstantComposite 127 128 62
150: TypeVector 17(float) 4
151: TypePointer Output 150(fvec4)
152(gl_FragColor): 151(ptr) Variable Output
4(main): 2 Function None 3
5: Label
86(t): 7(ptr) Variable Function
91(f): 90(ptr) Variable Function
95(color): 7(ptr) Variable Function
101(e): 7(ptr) Variable Function
102(param): 7(ptr) Variable Function
103(param): 7(ptr) Variable Function
104(param): 7(ptr) Variable Function
89(t): 7(ptr) Variable Function
94(f): 93(ptr) Variable Function
98(color): 7(ptr) Variable Function
104(e): 7(ptr) Variable Function
105(param): 7(ptr) Variable Function
120(ret): 18(ptr) Variable Function
127(tempArg): 7(ptr) Variable Function
128(param): 18(ptr) Variable Function
129(param): 20(ptr) Variable Function
130(param): 7(ptr) Variable Function
133(arg): 18(ptr) Variable Function
Store 86(t) 87
94: 7(ptr) AccessChain 91(f) 92 67
Store 94 93
97: 6(int) Load 86(t)
98: 6(int) Load 86(t)
99: 6(int) IAdd 97 98
Store 102(param) 96
Store 103(param) 99
106: 7(ptr) AccessChain 91(f) 92 67
107: 6(int) Load 106
Store 105(param) 107
108: 6(int) FunctionCall 15(foo(i1;i1;i1;i1;i1;i1;) 102(param) 87 103(param) 100 104(param) 105(param)
109: 6(int) Load 104(param)
Store 101(e) 109
110: 6(int) Load 105(param)
111: 7(ptr) AccessChain 91(f) 92 67
Store 111 110
Store 95(color) 108
113: 6(int) Load 101(e)
114: 7(ptr) AccessChain 91(f) 92 67
115: 6(int) Load 114
116: 6(int) IAdd 113 115
117: 6(int) IMul 112 116
118: 6(int) Load 95(color)
119: 6(int) IAdd 118 117
Store 95(color) 119
Store 128(param) 123
Store 129(param) 126
131: 6(int) FunctionCall 25(foo2(f1;vf3;i1;) 128(param) 129(param) 130(param)
132: 6(int) Load 130(param)
Store 127(tempArg) 132
Store 122(tempReturn) 131
134: 6(int) Load 127(tempArg)
135: 17(float) ConvertSToF 134
Store 133(arg) 135
136: 6(int) Load 122(tempReturn)
137: 17(float) ConvertSToF 136
Store 120(ret) 137
138: 17(float) Load 120(ret)
139: 17(float) Load 133(arg)
140: 17(float) FAdd 138 139
141: 6(int) ConvertFToS 140
142: 6(int) Load 95(color)
143: 6(int) IAdd 142 141
Store 95(color) 143
144: 6(int) FunctionCall 28(foo3()
145: 6(int) Load 95(color)
106(param): 7(ptr) Variable Function
107(param): 7(ptr) Variable Function
108(param): 7(ptr) Variable Function
123(ret): 18(ptr) Variable Function
130(tempArg): 7(ptr) Variable Function
131(param): 18(ptr) Variable Function
132(param): 20(ptr) Variable Function
133(param): 7(ptr) Variable Function
136(arg): 18(ptr) Variable Function
Store 89(t) 90
97: 7(ptr) AccessChain 94(f) 95 68
Store 97 96
100: 6(int) Load 89(t)
101: 6(int) Load 89(t)
102: 6(int) IAdd 100 101
Store 105(param) 99
Store 106(param) 102
109: 7(ptr) AccessChain 94(f) 95 68
110: 6(int) Load 109
Store 108(param) 110
111: 6(int) FunctionCall 15(foo(i1;i1;i1;i1;i1;i1;) 105(param) 90 106(param) 103 107(param) 108(param)
112: 6(int) Load 107(param)
Store 104(e) 112
113: 6(int) Load 108(param)
114: 7(ptr) AccessChain 94(f) 95 68
Store 114 113
Store 98(color) 111
116: 6(int) Load 104(e)
117: 7(ptr) AccessChain 94(f) 95 68
118: 6(int) Load 117
119: 6(int) IAdd 116 118
120: 6(int) IMul 115 119
121: 6(int) Load 98(color)
122: 6(int) IAdd 121 120
Store 98(color) 122
Store 131(param) 126
Store 132(param) 129
134: 6(int) FunctionCall 25(foo2(f1;vf3;i1;) 131(param) 132(param) 133(param)
135: 6(int) Load 133(param)
Store 130(tempArg) 135
Store 125(tempReturn) 134
137: 6(int) Load 130(tempArg)
138: 17(float) ConvertSToF 137
Store 136(arg) 138
139: 6(int) Load 125(tempReturn)
140: 17(float) ConvertSToF 139
Store 123(ret) 140
141: 17(float) Load 123(ret)
142: 17(float) Load 136(arg)
143: 17(float) FAdd 141 142
144: 6(int) ConvertFToS 143
145: 6(int) Load 98(color)
146: 6(int) IAdd 145 144
Store 95(color) 146
150: 6(int) Load 95(color)
151: 17(float) ConvertSToF 150
152: 147(fvec4) CompositeConstruct 151 151 151 151
Store 149(gl_FragColor) 152
Store 98(color) 146
147: 6(int) FunctionCall 28(foo3()
148: 6(int) Load 98(color)
149: 6(int) IAdd 148 147
Store 98(color) 149
153: 6(int) Load 98(color)
154: 17(float) ConvertSToF 153
155: 150(fvec4) CompositeConstruct 154 154 154 154
Store 152(gl_FragColor) 155
Return
FunctionEnd
15(foo(i1;i1;i1;i1;i1;i1;): 6(int) Function None 8
@@ -209,24 +209,24 @@ Linked fragment stage:
23(b): 20(ptr) FunctionParameter
24(r): 7(ptr) FunctionParameter
26: Label
62: 17(float) Load 22(a)
63: 17(float) FMul 61 62
64: 6(int) ConvertFToS 63
Store 24(r) 64
68: 18(ptr) AccessChain 23(b) 67
69: 17(float) Load 68
70: 17(float) FMul 65 69
71: 6(int) ConvertFToS 70
ReturnValue 71
63: 17(float) Load 22(a)
64: 17(float) FMul 62 63
65: 6(int) ConvertFToS 64
Store 24(r) 65
69: 18(ptr) AccessChain 23(b) 68
70: 17(float) Load 69
71: 17(float) FMul 66 70
72: 6(int) ConvertFToS 71
ReturnValue 72
FunctionEnd
28(foo3(): 6(int) Function None 27
29: Label
75: 17(float) Load 74(u)
78: 77(bool) FOrdGreaterThan 75 76
SelectionMerge 80 None
BranchConditional 78 79 80
79: Label
77: 17(float) Load 76(u)
80: 79(bool) FOrdGreaterThan 77 78
SelectionMerge 82 None
BranchConditional 80 81 82
81: Label
Kill
80: Label
ReturnValue 84
82: Label
ReturnValue 86
FunctionEnd