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

@@ -10,12 +10,12 @@ Linked fragment stage:
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 265
// Id's are bound by 267
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 73 223
EntryPoint Fragment 4 "main" 75 225
ExecutionMode 4 OriginLowerLeft
Source ESSL 310
Name 4 "main"
@@ -27,30 +27,30 @@ Linked fragment stage:
Name 17 "v1"
Name 18 "v2"
Name 19 "i1"
Name 58 "local"
Name 60 "c"
Name 71 "f"
Name 73 "x"
Name 127 "d"
Name 153 "i"
Name 172 "j"
Name 223 "color"
Name 229 "v"
Name 230 "param"
Name 60 "local"
Name 62 "c"
Name 73 "f"
Name 75 "x"
Name 129 "d"
Name 155 "i"
Name 174 "j"
Name 225 "color"
Name 231 "v"
Name 232 "param"
Name 234 "param"
Name 242 "param"
Name 236 "param"
Name 244 "param"
Name 246 "param"
Decorate 58(local) RelaxedPrecision
Decorate 60(c) RelaxedPrecision
Decorate 71(f) RelaxedPrecision
Decorate 73(x) RelaxedPrecision
Decorate 127(d) RelaxedPrecision
Decorate 153(i) RelaxedPrecision
Decorate 172(j) RelaxedPrecision
Decorate 223(color) RelaxedPrecision
Decorate 229(v) RelaxedPrecision
Name 248 "param"
Decorate 60(local) RelaxedPrecision
Decorate 62(c) RelaxedPrecision
Decorate 73(f) RelaxedPrecision
Decorate 75(x) RelaxedPrecision
Decorate 129(d) RelaxedPrecision
Decorate 155(i) RelaxedPrecision
Decorate 174(j) RelaxedPrecision
Decorate 225(color) RelaxedPrecision
Decorate 231(v) RelaxedPrecision
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
@@ -61,291 +61,291 @@ Linked fragment stage:
11: TypeFunction 7(fvec4) 8(ptr) 8(ptr) 10(ptr)
36: 6(float) Constant 0
37: 7(fvec4) ConstantComposite 36 36 36 36
47: 6(float) Constant 1065353216
48: 7(fvec4) ConstantComposite 47 47 47 47
59: TypePointer UniformConstant 9(int)
60(c): 59(ptr) Variable UniformConstant
63: 9(int) Constant 1
70: TypePointer Function 6(float)
72: TypePointer Input 6(float)
73(x): 72(ptr) Variable Input
127(d): 59(ptr) Variable UniformConstant
154: 9(int) Constant 0
160: 9(int) Constant 10
161: TypeBool
173: 9(int) Constant 20
179: 9(int) Constant 30
184: 6(float) Constant 1120429670
204: 6(float) Constant 1079739679
222: TypePointer Output 6(float)
223(color): 222(ptr) Variable Output
228: TypePointer UniformConstant 7(fvec4)
229(v): 228(ptr) Variable UniformConstant
237: TypeInt 32 0
238: 237(int) Constant 1
249: 237(int) Constant 2
48: 6(float) Constant 1065353216
49: 7(fvec4) ConstantComposite 48 48 48 48
61: TypePointer UniformConstant 9(int)
62(c): 61(ptr) Variable UniformConstant
65: 9(int) Constant 1
72: TypePointer Function 6(float)
74: TypePointer Input 6(float)
75(x): 74(ptr) Variable Input
129(d): 61(ptr) Variable UniformConstant
156: 9(int) Constant 0
162: 9(int) Constant 10
163: TypeBool
175: 9(int) Constant 20
181: 9(int) Constant 30
186: 6(float) Constant 1120429670
206: 6(float) Constant 1079739679
224: TypePointer Output 6(float)
225(color): 224(ptr) Variable Output
230: TypePointer UniformConstant 7(fvec4)
231(v): 230(ptr) Variable UniformConstant
239: TypeInt 32 0
240: 239(int) Constant 1
251: 239(int) Constant 2
4(main): 2 Function None 3
5: Label
58(local): 10(ptr) Variable Function
71(f): 70(ptr) Variable Function
153(i): 10(ptr) Variable Function
172(j): 10(ptr) Variable Function
230(param): 8(ptr) Variable Function
60(local): 10(ptr) Variable Function
73(f): 72(ptr) Variable Function
155(i): 10(ptr) Variable Function
174(j): 10(ptr) Variable Function
232(param): 8(ptr) Variable Function
234(param): 10(ptr) Variable Function
242(param): 8(ptr) Variable Function
234(param): 8(ptr) Variable Function
236(param): 10(ptr) Variable Function
244(param): 8(ptr) Variable Function
246(param): 10(ptr) Variable Function
61: 9(int) Load 60(c)
Store 58(local) 61
62: 9(int) Load 58(local)
64: 9(int) IAdd 62 63
Store 58(local) 64
65: 9(int) Load 60(c)
SelectionMerge 69 None
Switch 65 68
case 1: 66
case 2: 67
246(param): 8(ptr) Variable Function
248(param): 10(ptr) Variable Function
63: 9(int) Load 62(c)
Store 60(local) 63
64: 9(int) Load 60(local)
66: 9(int) IAdd 64 65
Store 60(local) 66
67: 9(int) Load 62(c)
SelectionMerge 71 None
Switch 67 70
case 1: 68
case 2: 69
70: Label
82: 6(float) Load 75(x)
83: 6(float) ExtInst 1(GLSL.std.450) 15(Tan) 82
Store 73(f) 83
Branch 71
68: Label
80: 6(float) Load 73(x)
81: 6(float) ExtInst 1(GLSL.std.450) 15(Tan) 80
Store 71(f) 81
Branch 69
66: Label
74: 6(float) Load 73(x)
75: 6(float) ExtInst 1(GLSL.std.450) 13(Sin) 74
Store 71(f) 75
Branch 69
67: Label
77: 6(float) Load 73(x)
78: 6(float) ExtInst 1(GLSL.std.450) 14(Cos) 77
Store 71(f) 78
Branch 69
69: Label
83: 9(int) Load 60(c)
SelectionMerge 87 None
Switch 83 86
case 1: 84
case 2: 85
76: 6(float) Load 75(x)
77: 6(float) ExtInst 1(GLSL.std.450) 13(Sin) 76
Store 73(f) 77
Branch 71
69: Label
79: 6(float) Load 75(x)
80: 6(float) ExtInst 1(GLSL.std.450) 14(Cos) 79
Store 73(f) 80
Branch 71
71: Label
85: 9(int) Load 62(c)
SelectionMerge 89 None
Switch 85 88
case 1: 86
case 2: 87
88: Label
99: 6(float) Load 75(x)
100: 6(float) ExtInst 1(GLSL.std.450) 15(Tan) 99
101: 6(float) Load 73(f)
102: 6(float) FAdd 101 100
Store 73(f) 102
Branch 89
86: Label
97: 6(float) Load 73(x)
98: 6(float) ExtInst 1(GLSL.std.450) 15(Tan) 97
99: 6(float) Load 71(f)
100: 6(float) FAdd 99 98
Store 71(f) 100
90: 6(float) Load 75(x)
91: 6(float) ExtInst 1(GLSL.std.450) 13(Sin) 90
92: 6(float) Load 73(f)
93: 6(float) FAdd 92 91
Store 73(f) 93
Branch 87
84: Label
88: 6(float) Load 73(x)
89: 6(float) ExtInst 1(GLSL.std.450) 13(Sin) 88
90: 6(float) Load 71(f)
91: 6(float) FAdd 90 89
Store 71(f) 91
Branch 85
85: Label
92: 6(float) Load 73(x)
93: 6(float) ExtInst 1(GLSL.std.450) 14(Cos) 92
94: 6(float) Load 71(f)
95: 6(float) FAdd 94 93
Store 71(f) 95
Branch 87
87: Label
102: 9(int) Load 60(c)
SelectionMerge 105 None
Switch 102 105
case 1: 103
case 2: 104
103: Label
106: 6(float) Load 73(x)
107: 6(float) ExtInst 1(GLSL.std.450) 13(Sin) 106
108: 6(float) Load 71(f)
109: 6(float) FAdd 108 107
Store 71(f) 109
Branch 105
104: Label
111: 6(float) Load 73(x)
112: 6(float) ExtInst 1(GLSL.std.450) 14(Cos) 111
113: 6(float) Load 71(f)
114: 6(float) FAdd 113 112
Store 71(f) 114
Branch 105
105: Label
117: 9(int) Load 60(c)
SelectionMerge 121 None
Switch 117 120
case 1: 118
case 2: 119
87: Label
94: 6(float) Load 75(x)
95: 6(float) ExtInst 1(GLSL.std.450) 14(Cos) 94
96: 6(float) Load 73(f)
97: 6(float) FAdd 96 95
Store 73(f) 97
Branch 89
89: Label
104: 9(int) Load 62(c)
SelectionMerge 107 None
Switch 104 107
case 1: 105
case 2: 106
105: Label
108: 6(float) Load 75(x)
109: 6(float) ExtInst 1(GLSL.std.450) 13(Sin) 108
110: 6(float) Load 73(f)
111: 6(float) FAdd 110 109
Store 73(f) 111
Branch 107
106: Label
113: 6(float) Load 75(x)
114: 6(float) ExtInst 1(GLSL.std.450) 14(Cos) 113
115: 6(float) Load 73(f)
116: 6(float) FAdd 115 114
Store 73(f) 116
Branch 107
107: Label
119: 9(int) Load 62(c)
SelectionMerge 123 None
Switch 119 122
case 1: 120
case 2: 121
122: Label
150: 6(float) Load 75(x)
151: 6(float) ExtInst 1(GLSL.std.450) 15(Tan) 150
152: 6(float) Load 73(f)
153: 6(float) FAdd 152 151
Store 73(f) 153
Branch 123
120: Label
148: 6(float) Load 73(x)
149: 6(float) ExtInst 1(GLSL.std.450) 15(Tan) 148
150: 6(float) Load 71(f)
151: 6(float) FAdd 150 149
Store 71(f) 151
Branch 121
118: Label
122: 6(float) Load 73(x)
123: 6(float) ExtInst 1(GLSL.std.450) 13(Sin) 122
124: 6(float) Load 71(f)
125: 6(float) FAdd 124 123
Store 71(f) 125
Branch 121
119: Label
128: 9(int) Load 127(d)
SelectionMerge 131 None
Switch 128 131
case 1: 129
case 2: 130
129: Label
132: 6(float) Load 73(x)
133: 6(float) Load 73(x)
134: 6(float) FMul 132 133
135: 6(float) Load 73(x)
124: 6(float) Load 75(x)
125: 6(float) ExtInst 1(GLSL.std.450) 13(Sin) 124
126: 6(float) Load 73(f)
127: 6(float) FAdd 126 125
Store 73(f) 127
Branch 123
121: Label
130: 9(int) Load 129(d)
SelectionMerge 133 None
Switch 130 133
case 1: 131
case 2: 132
131: Label
134: 6(float) Load 75(x)
135: 6(float) Load 75(x)
136: 6(float) FMul 134 135
137: 6(float) Load 71(f)
138: 6(float) FAdd 137 136
Store 71(f) 138
Branch 131
130: Label
140: 6(float) Load 73(x)
141: 6(float) Load 73(x)
142: 6(float) FMul 140 141
143: 6(float) Load 71(f)
144: 6(float) FAdd 143 142
Store 71(f) 144
Branch 131
131: Label
Branch 121
121: Label
Store 153(i) 154
Branch 155
155: Label
159: 9(int) Load 153(i)
162: 161(bool) SLessThan 159 160
LoopMerge 157 158 None
BranchConditional 162 156 157
156: Label
163: 9(int) Load 60(c)
SelectionMerge 167 None
Switch 163 166
case 1: 164
case 2: 165
166: Label
198: 6(float) Load 73(x)
199: 6(float) ExtInst 1(GLSL.std.450) 15(Tan) 198
200: 6(float) Load 71(f)
201: 6(float) FAdd 200 199
Store 71(f) 201
Branch 167
164: Label
168: 6(float) Load 73(x)
169: 6(float) ExtInst 1(GLSL.std.450) 13(Sin) 168
170: 6(float) Load 71(f)
171: 6(float) FAdd 170 169
Store 71(f) 171
Store 172(j) 173
Branch 174
174: Label
178: 9(int) Load 172(j)
180: 161(bool) SLessThan 178 179
LoopMerge 176 177 None
BranchConditional 180 175 176
175: Label
181: 6(float) Load 71(f)
182: 6(float) FAdd 181 47
Store 71(f) 182
183: 6(float) Load 71(f)
185: 161(bool) FOrdLessThan 183 184
SelectionMerge 187 None
BranchConditional 185 186 187
186: Label
Branch 176
187: Label
Branch 177
177: Label
189: 9(int) Load 172(j)
190: 9(int) IAdd 189 63
Store 172(j) 190
Branch 174
176: Label
Branch 167
165: Label
192: 6(float) Load 73(x)
193: 6(float) ExtInst 1(GLSL.std.450) 14(Cos) 192
194: 6(float) Load 71(f)
195: 6(float) FAdd 194 193
Store 71(f) 195
Branch 167
167: Label
203: 6(float) Load 71(f)
205: 161(bool) FOrdLessThan 203 204
SelectionMerge 207 None
BranchConditional 205 206 207
206: Label
Branch 157
207: Label
Branch 158
158: Label
209: 9(int) Load 153(i)
210: 9(int) IAdd 209 63
Store 153(i) 210
Branch 155
137: 6(float) Load 75(x)
138: 6(float) FMul 136 137
139: 6(float) Load 73(f)
140: 6(float) FAdd 139 138
Store 73(f) 140
Branch 133
132: Label
142: 6(float) Load 75(x)
143: 6(float) Load 75(x)
144: 6(float) FMul 142 143
145: 6(float) Load 73(f)
146: 6(float) FAdd 145 144
Store 73(f) 146
Branch 133
133: Label
Branch 123
123: Label
Store 155(i) 156
Branch 157
157: Label
211: 9(int) Load 60(c)
SelectionMerge 214 None
Switch 211 214
case 1: 212
case 2: 213
212: Label
215: 6(float) Load 73(x)
216: 6(float) ExtInst 1(GLSL.std.450) 13(Sin) 215
217: 6(float) Load 71(f)
218: 6(float) FAdd 217 216
Store 71(f) 218
Branch 214
213: Label
Branch 214
214: Label
224: 6(float) Load 71(f)
225: 9(int) Load 58(local)
226: 6(float) ConvertSToF 225
227: 6(float) FAdd 224 226
Store 223(color) 227
231: 7(fvec4) Load 229(v)
Store 230(param) 231
233: 7(fvec4) Load 229(v)
161: 9(int) Load 155(i)
164: 163(bool) SLessThan 161 162
LoopMerge 159 160 None
BranchConditional 164 158 159
158: Label
165: 9(int) Load 62(c)
SelectionMerge 169 None
Switch 165 168
case 1: 166
case 2: 167
168: Label
200: 6(float) Load 75(x)
201: 6(float) ExtInst 1(GLSL.std.450) 15(Tan) 200
202: 6(float) Load 73(f)
203: 6(float) FAdd 202 201
Store 73(f) 203
Branch 169
166: Label
170: 6(float) Load 75(x)
171: 6(float) ExtInst 1(GLSL.std.450) 13(Sin) 170
172: 6(float) Load 73(f)
173: 6(float) FAdd 172 171
Store 73(f) 173
Store 174(j) 175
Branch 176
176: Label
180: 9(int) Load 174(j)
182: 163(bool) SLessThan 180 181
LoopMerge 178 179 None
BranchConditional 182 177 178
177: Label
183: 6(float) Load 73(f)
184: 6(float) FAdd 183 48
Store 73(f) 184
185: 6(float) Load 73(f)
187: 163(bool) FOrdLessThan 185 186
SelectionMerge 189 None
BranchConditional 187 188 189
188: Label
Branch 178
189: Label
Branch 179
179: Label
191: 9(int) Load 174(j)
192: 9(int) IAdd 191 65
Store 174(j) 192
Branch 176
178: Label
Branch 169
167: Label
194: 6(float) Load 75(x)
195: 6(float) ExtInst 1(GLSL.std.450) 14(Cos) 194
196: 6(float) Load 73(f)
197: 6(float) FAdd 196 195
Store 73(f) 197
Branch 169
169: Label
205: 6(float) Load 73(f)
207: 163(bool) FOrdLessThan 205 206
SelectionMerge 209 None
BranchConditional 207 208 209
208: Label
Branch 159
209: Label
Branch 160
160: Label
211: 9(int) Load 155(i)
212: 9(int) IAdd 211 65
Store 155(i) 212
Branch 157
159: Label
213: 9(int) Load 62(c)
SelectionMerge 216 None
Switch 213 216
case 1: 214
case 2: 215
214: Label
217: 6(float) Load 75(x)
218: 6(float) ExtInst 1(GLSL.std.450) 13(Sin) 217
219: 6(float) Load 73(f)
220: 6(float) FAdd 219 218
Store 73(f) 220
Branch 216
215: Label
Branch 216
216: Label
226: 6(float) Load 73(f)
227: 9(int) Load 60(local)
228: 6(float) ConvertSToF 227
229: 6(float) FAdd 226 228
Store 225(color) 229
233: 7(fvec4) Load 231(v)
Store 232(param) 233
235: 9(int) Load 60(c)
235: 7(fvec4) Load 231(v)
Store 234(param) 235
236: 7(fvec4) FunctionCall 15(foo1(vf4;vf4;i1;) 230(param) 232(param) 234(param)
239: 6(float) CompositeExtract 236 1
240: 6(float) Load 223(color)
241: 6(float) FAdd 240 239
Store 223(color) 241
243: 7(fvec4) Load 229(v)
Store 242(param) 243
245: 7(fvec4) Load 229(v)
237: 9(int) Load 62(c)
Store 236(param) 237
238: 7(fvec4) FunctionCall 15(foo1(vf4;vf4;i1;) 232(param) 234(param) 236(param)
241: 6(float) CompositeExtract 238 1
242: 6(float) Load 225(color)
243: 6(float) FAdd 242 241
Store 225(color) 243
245: 7(fvec4) Load 231(v)
Store 244(param) 245
247: 9(int) Load 60(c)
247: 7(fvec4) Load 231(v)
Store 246(param) 247
248: 7(fvec4) FunctionCall 20(foo2(vf4;vf4;i1;) 242(param) 244(param) 246(param)
250: 6(float) CompositeExtract 248 2
251: 6(float) Load 223(color)
252: 6(float) FAdd 251 250
Store 223(color) 252
253: 9(int) Load 60(c)
SelectionMerge 256 None
Switch 253 255
case 0: 254
255: Label
Branch 256
254: Label
Branch 256
256: Label
260: 9(int) Load 60(c)
SelectionMerge 262 None
Switch 260 261
261: Label
Branch 262
262: Label
249: 9(int) Load 62(c)
Store 248(param) 249
250: 7(fvec4) FunctionCall 20(foo2(vf4;vf4;i1;) 244(param) 246(param) 248(param)
252: 6(float) CompositeExtract 250 2
253: 6(float) Load 225(color)
254: 6(float) FAdd 253 252
Store 225(color) 254
255: 9(int) Load 62(c)
SelectionMerge 258 None
Switch 255 257
case 0: 256
257: Label
Branch 258
256: Label
Branch 258
258: Label
262: 9(int) Load 62(c)
SelectionMerge 264 None
Switch 262 263
263: Label
Branch 264
264: Label
Return
FunctionEnd
15(foo1(vf4;vf4;i1;): 7(fvec4) Function None 11
@@ -379,26 +379,26 @@ Linked fragment stage:
18(v2): 8(ptr) FunctionParameter
19(i1): 10(ptr) FunctionParameter
21: Label
39: 9(int) Load 19(i1)
SelectionMerge 44 None
Switch 39 44
case 0: 40
case 2: 41
case 1: 42
case 3: 43
40: Label
45: 7(fvec4) Load 17(v1)
ReturnValue 45
40: 9(int) Load 19(i1)
SelectionMerge 45 None
Switch 40 45
case 0: 41
case 2: 42
case 1: 43
case 3: 44
41: Label
ReturnValue 48
46: 7(fvec4) Load 17(v1)
ReturnValue 46
42: Label
50: 7(fvec4) Load 18(v2)
ReturnValue 50
ReturnValue 49
43: Label
52: 7(fvec4) Load 17(v1)
53: 7(fvec4) Load 18(v2)
54: 7(fvec4) FMul 52 53
ReturnValue 54
44: Label
51: 7(fvec4) Load 18(v2)
ReturnValue 51
44: Label
53: 7(fvec4) Load 17(v1)
54: 7(fvec4) Load 18(v2)
55: 7(fvec4) FMul 53 54
ReturnValue 55
45: Label
ReturnValue 37
FunctionEnd