Commit 8a77b0c
authored
PIX shader debugger: Support dynamic indices for local arrays (microsoft#7536)
The root of the problem being addressed here is this line from the
previous version of DxilAnnotateWithVirtualRegister.cpp at (old) line
251 in function GetStructOffset:
```
auto *pArrayIndex =
llvm::dyn_cast<llvm::ConstantInt>(pGEP->getOperand(GEPOperandIndex++));
```
When an array is dynamically indexed, this dyn_cast of course returns
nullptr, and this function returns a zero, which eventually caused the
values of all dynamically-indexed array elements in PIX's shader
debugger to be reported as the value of the zeroth element in the array.
The next issue was that stores to an alloca-backed dynamic array weren't
being properly recognized as significant events from PIX debugger's
point of view. PIX adds its own "fake" alloca stores to help tie its
debug output with the debug info that ends up in the PDB, so it's easy
enough to co-opt that machinery to cover stores to "real" allocas, i.e.
function-local array storage. To do so, the "AnnotateStore" function
needs some of the metadata (i.e. PIX instruction number) that is added
during runOnModule here. This necessitated rearranging runOnModule and
putting stores into a vector that we then iterate over at the end of
runOnModule.
Now that indices aren't collapsed into just the zeroth, PIX needs to
know how much storage to allocate for the full array, which is the
motivation for the change in DxilDebugInstrumentation.cpp to return some
metadata that PIX can parse.
DxilDbgValueToDbgDeclare.cpp's changes are just a variable rename to aid
readability.
The rearrangement of runOnModule can induce some allocas to be visited
more than once, so there are changes in DxilPIXVirtualRegisters.cpp to
make sure we don't overwrite an existing alloca ordinal with a new one
(which would confuse previously-established references to that alloca).
file-check tests have been added to validate that
-the stores to local arrays are being noticed properly.
-the debug pass correctly outputs the metadata that informs PIX about
alloca sizes
The majority of these changes really needs end-to-end testing in PIX,
where I can gather real debug output as generated by the GPU in response
to the instrumentation, then match those results up with PDB data and
finally show HLSL variable contents in the shader debugger, so there are
some tests waiting on the PIX side for when this change makes its way
there.1 parent f94396d commit 8a77b0c
7 files changed
Lines changed: 178 additions & 55 deletions
File tree
- lib/DxilPIXPasses
- tools/clang
- test/HLSLFileCheck/pix
- unittests/HLSL
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
80 | | - | |
| 79 | + | |
| 80 | + | |
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
88 | 92 | | |
89 | 93 | | |
90 | 94 | | |
91 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
92 | 102 | | |
93 | 103 | | |
94 | 104 | | |
| |||
129 | 139 | | |
130 | 140 | | |
131 | 141 | | |
132 | | - | |
133 | | - | |
134 | 142 | | |
135 | 143 | | |
136 | 144 | | |
137 | 145 | | |
138 | 146 | | |
139 | 147 | | |
140 | 148 | | |
141 | | - | |
| 149 | + | |
142 | 150 | | |
143 | 151 | | |
144 | 152 | | |
| |||
151 | 159 | | |
152 | 160 | | |
153 | 161 | | |
| 162 | + | |
154 | 163 | | |
155 | 164 | | |
156 | | - | |
157 | | - | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
158 | 174 | | |
159 | 175 | | |
160 | 176 | | |
161 | 177 | | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
162 | 185 | | |
163 | | - | |
164 | | - | |
| 186 | + | |
| 187 | + | |
165 | 188 | | |
166 | 189 | | |
167 | 190 | | |
| |||
171 | 194 | | |
172 | 195 | | |
173 | 196 | | |
174 | | - | |
175 | | - | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
176 | 200 | | |
177 | 201 | | |
178 | 202 | | |
| |||
188 | 212 | | |
189 | 213 | | |
190 | 214 | | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
191 | 220 | | |
192 | 221 | | |
193 | 222 | | |
194 | 223 | | |
195 | 224 | | |
196 | | - | |
| 225 | + | |
197 | 226 | | |
198 | 227 | | |
199 | 228 | | |
| |||
210 | 239 | | |
211 | 240 | | |
212 | 241 | | |
213 | | - | |
| 242 | + | |
| 243 | + | |
214 | 244 | | |
215 | 245 | | |
216 | 246 | | |
| |||
226 | 256 | | |
227 | 257 | | |
228 | 258 | | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
229 | 273 | | |
230 | | - | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
231 | 292 | | |
232 | 293 | | |
233 | | - | |
234 | | - | |
235 | | - | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
236 | 298 | | |
237 | | - | |
| 299 | + | |
238 | 300 | | |
239 | 301 | | |
240 | 302 | | |
| |||
248 | 310 | | |
249 | 311 | | |
250 | 312 | | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
| 313 | + | |
257 | 314 | | |
258 | | - | |
259 | 315 | | |
260 | | - | |
261 | | - | |
262 | | - | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
263 | 320 | | |
264 | 321 | | |
265 | 322 | | |
| |||
268 | 325 | | |
269 | 326 | | |
270 | 327 | | |
271 | | - | |
| 328 | + | |
272 | 329 | | |
273 | 330 | | |
274 | 331 | | |
| |||
278 | 335 | | |
279 | 336 | | |
280 | 337 | | |
281 | | - | |
282 | | - | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
283 | 342 | | |
284 | | - | |
| 343 | + | |
285 | 344 | | |
286 | 345 | | |
287 | 346 | | |
288 | 347 | | |
289 | 348 | | |
290 | | - | |
291 | 349 | | |
292 | 350 | | |
293 | 351 | | |
| |||
366 | 424 | | |
367 | 425 | | |
368 | 426 | | |
369 | | - | |
| 427 | + | |
| 428 | + | |
370 | 429 | | |
371 | 430 | | |
372 | 431 | | |
| |||
383 | 442 | | |
384 | 443 | | |
385 | 444 | | |
386 | | - | |
| 445 | + | |
387 | 446 | | |
388 | 447 | | |
389 | 448 | | |
| |||
463 | 522 | | |
464 | 523 | | |
465 | 524 | | |
466 | | - | |
467 | | - | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
468 | 529 | | |
469 | 530 | | |
470 | | - | |
471 | | - | |
| 531 | + | |
472 | 532 | | |
473 | 533 | | |
474 | 534 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
859 | 859 | | |
860 | 860 | | |
861 | 861 | | |
862 | | - | |
863 | | - | |
| 862 | + | |
| 863 | + | |
864 | 864 | | |
865 | 865 | | |
866 | 866 | | |
| |||
873 | 873 | | |
874 | 874 | | |
875 | 875 | | |
876 | | - | |
| 876 | + | |
877 | 877 | | |
878 | 878 | | |
879 | 879 | | |
880 | 880 | | |
881 | 881 | | |
882 | | - | |
| 882 | + | |
883 | 883 | | |
884 | 884 | | |
885 | 885 | | |
886 | 886 | | |
887 | 887 | | |
888 | 888 | | |
889 | | - | |
| 889 | + | |
890 | 890 | | |
891 | 891 | | |
892 | 892 | | |
| |||
931 | 931 | | |
932 | 932 | | |
933 | 933 | | |
934 | | - | |
| 934 | + | |
935 | 935 | | |
936 | 936 | | |
937 | 937 | | |
| |||
950 | 950 | | |
951 | 951 | | |
952 | 952 | | |
953 | | - | |
| 953 | + | |
| 954 | + | |
954 | 955 | | |
955 | 956 | | |
956 | 957 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1356 | 1356 | | |
1357 | 1357 | | |
1358 | 1358 | | |
1359 | | - | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
1360 | 1372 | | |
1361 | 1373 | | |
1362 | 1374 | | |
| |||
1374 | 1386 | | |
1375 | 1387 | | |
1376 | 1388 | | |
1377 | | - | |
| 1389 | + | |
| 1390 | + | |
1378 | 1391 | | |
1379 | 1392 | | |
1380 | 1393 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
128 | | - | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
129 | 131 | | |
130 | 132 | | |
131 | 133 | | |
| |||
144 | 146 | | |
145 | 147 | | |
146 | 148 | | |
147 | | - | |
148 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
149 | 153 | | |
150 | 154 | | |
151 | 155 | | |
| |||
0 commit comments