Handle DebugGlobalVariable using DebugInfoNone
Bug: b/148401179
Change-Id: I89023b33b01bca848f44bda1f77c49496a9419af
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/47931
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Tested-by: Jaebaek Seo <jaebaek@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Pipeline/SpirvShaderDebugger.cpp b/src/Pipeline/SpirvShaderDebugger.cpp
index 795fd78..c5a663d 100644
--- a/src/Pipeline/SpirvShaderDebugger.cpp
+++ b/src/Pipeline/SpirvShaderDebugger.cpp
@@ -1264,11 +1264,15 @@
var->column = insn.word(9);
var->parent = get(debug::Scope::ID(insn.word(10)));
var->linkage = shader->getString(insn.word(11));
- var->variable = insn.word(12);
+ var->variable = isNone(insn.word(12)) ? 0 : insn.word(12);
var->flags = insn.word(13);
// static member declaration: word(14)
- exposeVariable(shader, var->name.c_str(), &debug::Scope::Global, var->type, var->variable, state);
+ // TODO(b/148401179): Instead of simply hiding variables that have been stripped by optimizations, show them in the debugger as `<optimized-away>`
+ if(var->variable != 0)
+ {
+ exposeVariable(shader, var->name.c_str(), &debug::Scope::Global, var->type, var->variable, state);
+ }
});
break;
case OpenCLDebugInfo100DebugFunction: