Commit 54d16b89 by Ben Clayton

SpirvShaderDebugger: Ignore non-statements

Many opcode are not actual statements, but opcodes for declaring types, decorations, capabilities, etc. Single line stepping over these is pointless as they do not actually do anything at execution time. Just ignore them. Bug: b/148778720 Change-Id: I0f55fe4b7308f33119dcea4012bc837c375ad5c3 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/40830 Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarAntonio Maiorano <amaiorano@google.com> Tested-by: 's avatarBen Clayton <bclayton@google.com>
parent 4bc07ade
...@@ -1160,6 +1160,11 @@ private: ...@@ -1160,6 +1160,11 @@ private:
static std::string OpcodeName(spv::Op op); static std::string OpcodeName(spv::Op op);
static std::memory_order MemoryOrder(spv::MemorySemanticsMask memorySemantics); static std::memory_order MemoryOrder(spv::MemorySemanticsMask memorySemantics);
// IsStatement() returns true if the given opcode actually performs
// work (as opposed to declaring a type, defining a function start / end,
// etc).
static bool IsStatement(spv::Op op);
// Helper as we often need to take dot products as part of doing other things. // Helper as we often need to take dot products as part of doing other things.
SIMD::Float Dot(unsigned numComponents, GenericValue const &x, GenericValue const &y) const; SIMD::Float Dot(unsigned numComponents, GenericValue const &x, GenericValue const &y) const;
......
...@@ -1373,6 +1373,10 @@ void SpirvShader::dbgBeginEmitInstruction(InsnIterator insn, EmitState *state) c ...@@ -1373,6 +1373,10 @@ void SpirvShader::dbgBeginEmitInstruction(InsnIterator insn, EmitState *state) c
if(extensionsImported.count(Extension::OpenCLDebugInfo100) == 0) if(extensionsImported.count(Extension::OpenCLDebugInfo100) == 0)
{ {
// We're emitting debugger logic for SPIR-V.
// Only single line step over statement instructions.
if(IsStatement(insn.opcode()))
{
auto dbg = impl.debugger; auto dbg = impl.debugger;
if(!dbg) { return; } if(!dbg) { return; }
...@@ -1380,6 +1384,7 @@ void SpirvShader::dbgBeginEmitInstruction(InsnIterator insn, EmitState *state) c ...@@ -1380,6 +1384,7 @@ void SpirvShader::dbgBeginEmitInstruction(InsnIterator insn, EmitState *state) c
auto column = 0; auto column = 0;
rr::Call(&Impl::Debugger::State::update, state->routine->dbgState, dbg->spirvFile->id, line, column); rr::Call(&Impl::Debugger::State::update, state->routine->dbgState, dbg->spirvFile->id, line, column);
} }
}
} }
void SpirvShader::dbgEndEmitInstruction(InsnIterator insn, EmitState *state) const void SpirvShader::dbgEndEmitInstruction(InsnIterator insn, EmitState *state) const
......
// Copyright 2020 The SwiftShader Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "SpirvShader.hpp"
#include <spirv/unified1/spirv.hpp>
#define CONCAT(a, b) a##b
#define CONCAT2(a, b) CONCAT(a, b)
namespace {
// checkForNoMissingOps() is an unused function that simply exists to try and
// detect missing opcodes in "SpirvShaderInstructions.inc".
// If there are missing opcodes, then some compilers will warn that not all
// enum values are handled by the switch case below.
constexpr void checkForNoMissingOps(spv::Op op)
{
// self-reference to avoid unused-function warnings.
(void)&checkForNoMissingOps;
switch(op)
{
#define DECORATE_OP(isStatement, op) \
case spv::op: \
return;
#include "SpirvShaderInstructions.inc"
#undef DECORATE_OP
case spv::OpMax: return;
}
}
} // anonymous namespace
namespace sw {
bool SpirvShader::IsStatement(spv::Op op)
{
switch(op)
{
#define IS_STATEMENT_T(op) case spv::op:
#define IS_STATEMENT_F(op)
#define DECORATE_OP(isStatement, op) \
CONCAT2(IS_STATEMENT_, isStatement) \
(op)
#include "SpirvShaderInstructions.inc"
#undef IS_STATEMENT_T
#undef IS_STATEMENT_F
#undef DECORATE_OP
return true;
default:
return false;
}
}
} // namespace sw
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment