Subzero: add subzeroDumpEnabled flag
When enabled, coupled with ALLOW_DUMP = 1, will enable verbose and
unbuffered logging. Helpful for debugging Subzero bugs.
Bug: b/144688789
Change-Id: Ia5ae4456e4ec43dcf616f7f14cf88cd0911fe17b
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/38477
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Tested-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
diff --git a/src/Reactor/SubzeroReactor.cpp b/src/Reactor/SubzeroReactor.cpp
index 93db311..06409ff 100644
--- a/src/Reactor/SubzeroReactor.cpp
+++ b/src/Reactor/SubzeroReactor.cpp
@@ -160,6 +160,12 @@
const bool CPUID::SSE4_1 = CPUID::detectSSE4_1();
const bool emulateIntrinsics = false;
const bool emulateMismatchedBitCast = CPUID::ARM;
+
+ constexpr bool subzeroDumpEnabled = false;
+
+#if !ALLOW_DUMP
+ static_assert(!subzeroDumpEnabled, "Compile Subzero with ALLOW_DUMP=1 for subzeroDumpEnabled");
+#endif
}
namespace rr
@@ -588,7 +594,7 @@
Flags.setOutFileType(Ice::FT_Elf);
Flags.setOptLevel(toIce(getDefaultConfig().getOptimization().getLevel()));
Flags.setApplicationBinaryInterface(Ice::ABI_Platform);
- Flags.setVerbose(false ? Ice::IceV_Most : Ice::IceV_None);
+ Flags.setVerbose(subzeroDumpEnabled ? Ice::IceV_Most : Ice::IceV_None);
Flags.setDisableHybridAssembly(true);
static llvm::raw_os_ostream cout(std::cout);
@@ -644,6 +650,12 @@
std::shared_ptr<Routine> Nucleus::acquireRoutine(const char *name, const Config::Edit &cfgEdit /* = Config::Edit::None */)
{
+ if (subzeroDumpEnabled)
+ {
+ // Output dump strings immediately, rather than once buffer is full. Useful for debugging.
+ context->getStrDump().SetUnbuffered();
+ }
+
if(basicBlock->getInsts().empty() || basicBlock->getInsts().back().getKind() != Ice::Inst::Ret)
{
createRetVoid();