Unplug SPIR-V instruction profiling support

Similar to the shader debugging support this feature is not actively
used and there are no unit tests to prevent it from bitrotting. It gets
in the way of refactorings which will make the SpirvShader class solely
responsible for SPIR-V parsing and independent of Reactor code emit.

It should be straightforward to revive if we need it again and make an
effort to properly maintain it.

Bug: b/251802301
Change-Id: I5f54fa937bd5461057afa8f4d8d61679ac642f4d
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/68848
Reviewed-by: Alexis Hétu <sugoi@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Pipeline/SpirvShader.cpp b/src/Pipeline/SpirvShader.cpp
index 0cc55b6..26ec28f 100644
--- a/src/Pipeline/SpirvShader.cpp
+++ b/src/Pipeline/SpirvShader.cpp
@@ -33,13 +33,11 @@
     const SpirvBinary &insns,
     const vk::RenderPass *renderPass,
     uint32_t subpassIndex,
-    bool robustBufferAccess,
-    std::shared_ptr<SpirvProfiler> profiler)
+    bool robustBufferAccess)
     : insns{ insns }
     , inputs{ MAX_INTERFACE_COMPONENTS }
     , outputs{ MAX_INTERFACE_COMPONENTS }
     , robustBufferAccess(robustBufferAccess)
-    , profiler(profiler)
 {
 	ASSERT(insns.size() > 0);
 
@@ -1772,11 +1770,6 @@
 
 void SpirvShader::emitProlog(SpirvRoutine *routine) const
 {
-	if(IsProfilingEnabled())
-	{
-		routine->profData = std::make_unique<SpirvProfileData>();
-	}
-
 	for(auto insn : *this)
 	{
 		switch(insn.opcode())
@@ -1868,12 +1861,6 @@
 {
 	auto opcode = insn.opcode();
 
-	if(IsProfilingEnabled() && IsStatement(opcode))
-	{
-		int64_t *counter = &state->routine->profData->spvOpExecutionCount[opcode];
-		AddAtomic(Pointer<Long>(ConstantPointer(counter)), 1);
-	}
-
 #if SPIRV_SHADER_ENABLE_DBG
 	{
 		auto text = spvtools::spvInstructionBinaryToText(
@@ -2737,11 +2724,6 @@
 			break;
 		}
 	}
-
-	if(IsProfilingEnabled())
-	{
-		profiler->RegisterShaderForProfiling(std::to_string(insns.getIdentifier()) + "_" + std::to_string((uintptr_t)routine), std::move(routine->profData));
-	}
 }
 
 void SpirvShader::clearPhis(SpirvRoutine *routine) const
diff --git a/src/Pipeline/SpirvShader.hpp b/src/Pipeline/SpirvShader.hpp
index 92aa459..ebfceb2 100644
--- a/src/Pipeline/SpirvShader.hpp
+++ b/src/Pipeline/SpirvShader.hpp
@@ -19,7 +19,6 @@
 #include "ShaderCore.hpp"
 #include "SpirvBinary.hpp"
 #include "SpirvID.hpp"
-#include "SpirvProfiler.hpp"
 #include "Device/Config.hpp"
 #include "Device/Sampler.hpp"
 #include "System/Debug.hpp"
@@ -651,8 +650,7 @@
 	            const SpirvBinary &insns,
 	            const vk::RenderPass *renderPass,
 	            uint32_t subpassIndex,
-	            bool robustBufferAccess,
-	            std::shared_ptr<SpirvProfiler> profiler);
+	            bool robustBufferAccess);
 
 	~SpirvShader();
 
@@ -973,13 +971,6 @@
 	HandleMap<Function> functions;
 	std::unordered_map<StringID, String> strings;
 
-	std::shared_ptr<SpirvProfiler> profiler;
-
-	bool IsProfilingEnabled() const
-	{
-		return profiler != nullptr;
-	}
-
 	// DeclareType creates a Type for the given OpTypeX instruction, storing
 	// it into the types map. It is called from the analysis pass (constructor).
 	void DeclareType(InsnIterator insn);
@@ -1642,13 +1633,12 @@
 	}
 
 private:
-	// The phis and the profile data are only accessible to SpirvShader
+	// The phis are only accessible to SpirvShader
 	// as they are only used and exist between calls to
 	// SpirvShader::emitProlog() and SpirvShader::emitEpilog().
 	friend class SpirvShader;
 
 	std::unordered_map<SpirvShader::Object::ID, Variable> phis;
-	std::unique_ptr<SpirvProfileData> profData;
 };
 
 }  // namespace sw
diff --git a/src/Vulkan/VkPipeline.cpp b/src/Vulkan/VkPipeline.cpp
index 0a9f74c..f014a95 100644
--- a/src/Vulkan/VkPipeline.cpp
+++ b/src/Vulkan/VkPipeline.cpp
@@ -32,13 +32,6 @@
 
 namespace {
 
-std::shared_ptr<sw::SpirvProfiler> getOrCreateSpirvProfiler()
-{
-	const sw::Configuration &config = sw::getConfiguration();
-	static std::shared_ptr<sw::SpirvProfiler> profiler = sw::getConfiguration().enableSpirvProfiling ? std::make_shared<sw::SpirvProfiler>(config) : nullptr;
-	return profiler;
-}
-
 // optimizeSpirv() applies and freezes specializations into constants, and runs spirv-opt.
 sw::SpirvBinary optimizeSpirv(const vk::PipelineCache::SpirvBinaryKey &key)
 {
@@ -553,7 +546,7 @@
 
 		// TODO(b/201798871): use allocator.
 		auto shader = std::make_shared<sw::SpirvShader>(stageInfo.stage, stageInfo.pName, spirv,
-		                                                vk::Cast(pCreateInfo->renderPass), pCreateInfo->subpass, stageRobustBufferAccess, getOrCreateSpirvProfiler());
+		                                                vk::Cast(pCreateInfo->renderPass), pCreateInfo->subpass, stageRobustBufferAccess);
 
 		setShader(stageInfo.stage, shader);
 
@@ -630,7 +623,7 @@
 
 	// TODO(b/201798871): use allocator.
 	shader = std::make_shared<sw::SpirvShader>(stage.stage, stage.pName, spirv,
-	                                           nullptr, 0, stageRobustBufferAccess, getOrCreateSpirvProfiler());
+	                                           nullptr, 0, stageRobustBufferAccess);
 
 	const PipelineCache::ComputeProgramKey programKey(shader->getIdentifier(), layout->identifier);