Commit af26cfe3 by Ben Clayton

SpirvShader: Minor changes for ASSERTs

sw::Intermediate would only clear the contents to zero in debug builds, but would always validate that these were nullptr in release (ASSERT still warns in release). Given the cost nullifying this memory is negligable in comparison to the actual LLVM JIT, always clear. Changed a bunch of ASSERT()s to ASSERT_MSG() where the additional information is useful. Replaced a few remaining calls to assert() with ASSERT() Bug: b/127433389 Change-Id: Ifac89ca061bf7d61ff7d0de1792eeda18fad275c Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/27568 Presubmit-Ready: Ben Clayton <bclayton@google.com> Tested-by: 's avatarBen Clayton <headlessclayton@gmail.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarChris Forbes <chrisforbes@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 4d3cdbc2
...@@ -318,7 +318,7 @@ namespace sw ...@@ -318,7 +318,7 @@ namespace sw
case spv::OpSpecConstantTrue: case spv::OpSpecConstantTrue:
// These should have all been removed by preprocessing passes. If we see them here, // These should have all been removed by preprocessing passes. If we see them here,
// our assumptions are wrong and we will probably generate wrong code. // our assumptions are wrong and we will probably generate wrong code.
UNIMPLEMENTED("These instructions should have already been lowered."); UNIMPLEMENTED("%s should have already been lowered.", OpcodeName(insn.opcode()).c_str());
break; break;
case spv::OpFConvert: case spv::OpFConvert:
...@@ -2038,7 +2038,7 @@ namespace sw ...@@ -2038,7 +2038,7 @@ namespace sw
void SpirvShader::EmitDot(InsnIterator insn, SpirvRoutine *routine) const void SpirvShader::EmitDot(InsnIterator insn, SpirvRoutine *routine) const
{ {
auto &type = getType(insn.word(1)); auto &type = getType(insn.word(1));
assert(type.sizeInComponents == 1); ASSERT(type.sizeInComponents == 1);
auto &dst = routine->createIntermediate(insn.word(2), type.sizeInComponents); auto &dst = routine->createIntermediate(insn.word(2), type.sizeInComponents);
auto &lhsType = getType(getObject(insn.word(3)).type); auto &lhsType = getType(getObject(insn.word(3)).type);
auto lhs = GenericValue(this, routine, insn.word(3)); auto lhs = GenericValue(this, routine, insn.word(3));
...@@ -2405,7 +2405,7 @@ namespace sw ...@@ -2405,7 +2405,7 @@ namespace sw
void SpirvShader::EmitAny(InsnIterator insn, SpirvRoutine *routine) const void SpirvShader::EmitAny(InsnIterator insn, SpirvRoutine *routine) const
{ {
auto &type = getType(insn.word(1)); auto &type = getType(insn.word(1));
assert(type.sizeInComponents == 1); ASSERT(type.sizeInComponents == 1);
auto &dst = routine->createIntermediate(insn.word(2), type.sizeInComponents); auto &dst = routine->createIntermediate(insn.word(2), type.sizeInComponents);
auto &srcType = getType(getObject(insn.word(3)).type); auto &srcType = getType(getObject(insn.word(3)).type);
auto src = GenericValue(this, routine, insn.word(3)); auto src = GenericValue(this, routine, insn.word(3));
...@@ -2423,7 +2423,7 @@ namespace sw ...@@ -2423,7 +2423,7 @@ namespace sw
void SpirvShader::EmitAll(InsnIterator insn, SpirvRoutine *routine) const void SpirvShader::EmitAll(InsnIterator insn, SpirvRoutine *routine) const
{ {
auto &type = getType(insn.word(1)); auto &type = getType(insn.word(1));
assert(type.sizeInComponents == 1); ASSERT(type.sizeInComponents == 1);
auto &dst = routine->createIntermediate(insn.word(2), type.sizeInComponents); auto &dst = routine->createIntermediate(insn.word(2), type.sizeInComponents);
auto &srcType = getType(getObject(insn.word(3)).type); auto &srcType = getType(getObject(insn.word(3)).type);
auto src = GenericValue(this, routine, insn.word(3)); auto src = GenericValue(this, routine, insn.word(3));
......
...@@ -67,9 +67,7 @@ namespace sw ...@@ -67,9 +67,7 @@ namespace sw
{ {
public: public:
Intermediate(uint32_t size) : scalar(new rr::Value*[size]), size(size) { Intermediate(uint32_t size) : scalar(new rr::Value*[size]), size(size) {
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
memset(scalar, 0, sizeof(rr::Value*) * size); memset(scalar, 0, sizeof(rr::Value*) * size);
#endif
} }
~Intermediate() ~Intermediate()
...@@ -412,7 +410,7 @@ namespace sw ...@@ -412,7 +410,7 @@ namespace sw
Block const &getBlock(Block::ID id) const Block const &getBlock(Block::ID id) const
{ {
auto it = blocks.find(id); auto it = blocks.find(id);
ASSERT(it != blocks.end()); ASSERT_MSG(it != blocks.end(), "Unknown block %d", id.value());
return it->second; return it->second;
} }
...@@ -549,21 +547,21 @@ namespace sw ...@@ -549,21 +547,21 @@ namespace sw
Value& getValue(SpirvShader::Object::ID id) Value& getValue(SpirvShader::Object::ID id)
{ {
auto it = lvalues.find(id); auto it = lvalues.find(id);
ASSERT(it != lvalues.end()); ASSERT_MSG(it != lvalues.end(), "Unknown value %d", id.value());
return it->second; return it->second;
} }
Intermediate const& getIntermediate(SpirvShader::Object::ID id) const Intermediate const& getIntermediate(SpirvShader::Object::ID id) const
{ {
auto it = intermediates.find(id); auto it = intermediates.find(id);
ASSERT(it != intermediates.end()); ASSERT_MSG(it != intermediates.end(), "Unknown intermediate %d", id.value());
return it->second; return it->second;
} }
Pointer<Byte>& getPhysicalPointer(SpirvShader::Object::ID id) Pointer<Byte>& getPhysicalPointer(SpirvShader::Object::ID id)
{ {
auto it = physicalPointers.find(id); auto it = physicalPointers.find(id);
assert(it != physicalPointers.end()); ASSERT_MSG(it != physicalPointers.end(), "Unknown physical pointer %d", id.value());
return it->second; return it->second;
} }
}; };
......
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