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: Ben Clayton <headlessclayton@gmail.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Pipeline/SpirvShader.cpp b/src/Pipeline/SpirvShader.cpp
index 0405a34..15307d4 100644
--- a/src/Pipeline/SpirvShader.cpp
+++ b/src/Pipeline/SpirvShader.cpp
@@ -318,7 +318,7 @@
 			case spv::OpSpecConstantTrue:
 				// 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.
-				UNIMPLEMENTED("These instructions should have already been lowered.");
+				UNIMPLEMENTED("%s should have already been lowered.", OpcodeName(insn.opcode()).c_str());
 				break;
 
 			case spv::OpFConvert:
@@ -2038,7 +2038,7 @@
 	void SpirvShader::EmitDot(InsnIterator insn, SpirvRoutine *routine) const
 	{
 		auto &type = getType(insn.word(1));
-		assert(type.sizeInComponents == 1);
+		ASSERT(type.sizeInComponents == 1);
 		auto &dst = routine->createIntermediate(insn.word(2), type.sizeInComponents);
 		auto &lhsType = getType(getObject(insn.word(3)).type);
 		auto lhs = GenericValue(this, routine, insn.word(3));
@@ -2405,7 +2405,7 @@
 	void SpirvShader::EmitAny(InsnIterator insn, SpirvRoutine *routine) const
 	{
 		auto &type = getType(insn.word(1));
-		assert(type.sizeInComponents == 1);
+		ASSERT(type.sizeInComponents == 1);
 		auto &dst = routine->createIntermediate(insn.word(2), type.sizeInComponents);
 		auto &srcType = getType(getObject(insn.word(3)).type);
 		auto src = GenericValue(this, routine, insn.word(3));
@@ -2423,7 +2423,7 @@
 	void SpirvShader::EmitAll(InsnIterator insn, SpirvRoutine *routine) const
 	{
 		auto &type = getType(insn.word(1));
-		assert(type.sizeInComponents == 1);
+		ASSERT(type.sizeInComponents == 1);
 		auto &dst = routine->createIntermediate(insn.word(2), type.sizeInComponents);
 		auto &srcType = getType(getObject(insn.word(3)).type);
 		auto src = GenericValue(this, routine, insn.word(3));
diff --git a/src/Pipeline/SpirvShader.hpp b/src/Pipeline/SpirvShader.hpp
index 084e13a..d02c40e 100644
--- a/src/Pipeline/SpirvShader.hpp
+++ b/src/Pipeline/SpirvShader.hpp
@@ -67,9 +67,7 @@
 	{
 	public:
 		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);
-#endif
 		}
 
 		~Intermediate()
@@ -412,7 +410,7 @@
 		Block const &getBlock(Block::ID id) const
 		{
 			auto it = blocks.find(id);
-			ASSERT(it != blocks.end());
+			ASSERT_MSG(it != blocks.end(), "Unknown block %d", id.value());
 			return it->second;
 		}
 
@@ -549,21 +547,21 @@
 		Value& getValue(SpirvShader::Object::ID id)
 		{
 			auto it = lvalues.find(id);
-			ASSERT(it != lvalues.end());
+			ASSERT_MSG(it != lvalues.end(), "Unknown value %d", id.value());
 			return it->second;
 		}
 
 		Intermediate const& getIntermediate(SpirvShader::Object::ID id) const
 		{
 			auto it = intermediates.find(id);
-			ASSERT(it != intermediates.end());
+			ASSERT_MSG(it != intermediates.end(), "Unknown intermediate %d", id.value());
 			return it->second;
 		}
 
 		Pointer<Byte>& getPhysicalPointer(SpirvShader::Object::ID id)
 		{
 			auto it = physicalPointers.find(id);
-			assert(it != physicalPointers.end());
+			ASSERT_MSG(it != physicalPointers.end(), "Unknown physical pointer %d", id.value());
 			return it->second;
 		}
 	};