SpirvShader: Silence warnings of unexpected opcodes
... between the `OpFunction` and `OpLabel`.
It is legal to have `OpLine`s between here, which we were incorrectly warning about.
The `OpenCL.Debug.Info` opcodes can also sit here, which are numerous. Just silence the warning, we're only scanning forward for the `OpLabel` here.
Bug: b/148401179
Change-Id: Ia9b8b024a1a15bbf431abec8f8ec47e2b735ed1b
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/42328
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Tested-by: Ben Clayton <bclayton@google.com>
diff --git a/src/Pipeline/SpirvShader.cpp b/src/Pipeline/SpirvShader.cpp
index 4e50f2d..6327acf 100644
--- a/src/Pipeline/SpirvShader.cpp
+++ b/src/Pipeline/SpirvShader.cpp
@@ -400,18 +400,12 @@
function.result = Type::ID(insn.word(1));
function.type = Type::ID(insn.word(4));
// Scan forward to find the function's label.
- for(auto it = insn; it != end() && function.entry == 0; it++)
+ for(auto it = insn; it != end(); it++)
{
- switch(it.opcode())
+ if(it.opcode() == spv::OpLabel)
{
- case spv::OpFunction:
- case spv::OpFunctionParameter:
- break;
- case spv::OpLabel:
- function.entry = Block::ID(it.word(1));
- break;
- default:
- WARN("Unexpected opcode '%s' following OpFunction", OpcodeName(it.opcode()).c_str());
+ function.entry = Block::ID(it.word(1));
+ break;
}
}
ASSERT_MSG(function.entry != 0, "Function<%d> has no label", currentFunction.value());