Wrong result for SPIR-V file containing OpPhi instructions
I've attached an archive containing an amber file output_mismatch.amber and the plain SPIR-V version of it. The amber file contains a test that should force a particular path to be taken in the SPIR-V CFG. Whenever a basic block in the CFG is visited, its block id is written to an output buffer. It is then possible to check that the correct path was taken by using an amber EXPECT statement to check that the ids in the output buffer match the expected ids in the path. In this particular case, the path is:
8 -> 9 -> <12> -> 13 -> 15 -> <18> -> <21> -> edge_0 -> 20 -> <18> -> <21> -> edge_0 -> 20 -> <18> -> <21> -> edge_0 -> 20 -> <18> -> <19> -> <16> -> 29 -> <10> -> 31 -> 30
note: <x> -> edge_y -> <z> means that there was a switch statement in block x and the yth arm of the switch was taken to get to z.
Line 441 contains the EXPECT statement on the output buffer. The EXPECT statement is EXPECT output IDX 0 EQ 8 9 12 13 15 18 21 20 18 21 20 18 21 20 18 19 16 29 10 31 30. If the output buffer does not match the expectation, then something has gone wrong. In this case, the error is Verifier failed: 0 == 20, at index 7
which means there was a mismatch at index 7 where we expected to get 20, but got 0 instead. The output buffer is initialized to contain all 0, so this suggests that nothing is being written to the output buffer.
I believe this is likely to be a bug in mesa as the test executes successfully when using the Nvidia and SwiftShader drivers. This test was designed to test OpPhi instructions, so it may be a source of the error.
Reproduction steps:
amber -t spv1.3 -v 1.1 output_mismatch.amber
Gives the following error:
output_mismatch.amber: Line 441: Verifier failed: 0 == 20, at index 7
Summary of Failures:
output_mismatch.amber
Summary: 0 pass, 1 fail
Device: Mesa Intel(R) Xe Graphics (TGL GT2). I can reproduce this using the mesa 22.1.0 tag.