diff --git a/src/writer/spirv/builder.cc b/src/writer/spirv/builder.cc index 4fc5e7d3f9..ec18b62ca5 100644 --- a/src/writer/spirv/builder.cc +++ b/src/writer/spirv/builder.cc @@ -556,6 +556,9 @@ bool Builder::GenerateGlobalVariable(ast::Variable* var) { error_ = "missing constructor for constant"; return false; } + push_debug(spv::Op::OpName, + {Operand::Int(init_id), Operand::String(var->name())}); + scope_stack_.set_global(var->name(), init_id); spirv_id_to_variable_[init_id] = var; return true; diff --git a/src/writer/spirv/builder_global_variable_test.cc b/src/writer/spirv/builder_global_variable_test.cc index 703dc5d862..5ab3ce2ae3 100644 --- a/src/writer/spirv/builder_global_variable_test.cc +++ b/src/writer/spirv/builder_global_variable_test.cc @@ -157,6 +157,8 @@ TEST_F(BuilderTest, GlobalVar_Const) { EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error(); ASSERT_FALSE(b.has_error()) << b.error(); + EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %5 "var" +)"); EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32 %1 = OpTypeVector %2 3 %3 = OpConstant %2 1