[spirv-writer] Hash names
This Cl hashes the OpName, OpEntryPoint and OpMemberName strings so we
are no longer passing user provided strings through into the resulting
SPIR-V binary.
Bug: tint:273
Change-Id: I0ca2c65d0cd2800c54d867ab698c7751c341778c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32061
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
diff --git a/BUILD.gn b/BUILD.gn
index ca9ce6c..d98b686 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -393,6 +393,8 @@
"src/inspector/inspector.h",
"src/inspector/scalar.cc",
"src/inspector/scalar.h",
+ "src/namer.cc",
+ "src/namer.h",
"src/reader/reader.cc",
"src/reader/reader.h",
"src/scope_stack.h",
@@ -790,6 +792,7 @@
"src/diagnostic/formatter_test.cc",
"src/diagnostic/printer_test.cc",
"src/inspector/inspector_test.cc",
+ "src/namer_test.cc",
"src/scope_stack_test.cc",
"src/transform/bound_array_accessors_transform_test.cc",
"src/transform/vertex_pulling_transform_test.cc",
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 0356719..65ef68d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -214,6 +214,8 @@
inspector/inspector.h
inspector/scalar.cc
inspector/scalar.h
+ namer.cc
+ namer.h
reader/reader.cc
reader/reader.h
scope_stack.h
@@ -400,6 +402,7 @@
diagnostic/formatter_test.cc
diagnostic/printer_test.cc
inspector/inspector_test.cc
+ namer_test.cc
scope_stack_test.cc
transform/bound_array_accessors_transform_test.cc
transform/vertex_pulling_transform_test.cc
diff --git a/src/inspector/inspector.cc b/src/inspector/inspector.cc
index 6af2d02..ed278af 100644
--- a/src/inspector/inspector.cc
+++ b/src/inspector/inspector.cc
@@ -30,6 +30,7 @@
#include "src/ast/type/struct_type.h"
#include "src/ast/type/type.h"
#include "src/ast/uint_literal.h"
+#include "src/namer.h"
namespace tint {
namespace inspector {
@@ -46,8 +47,9 @@
continue;
}
+ Namer namer;
EntryPoint entry_point;
- entry_point.name = func->name();
+ entry_point.name = namer.NameFor(func->name());
entry_point.stage = func->pipeline_stage();
std::tie(entry_point.workgroup_size_x, entry_point.workgroup_size_y,
entry_point.workgroup_size_z) = func->workgroup_size();
diff --git a/src/inspector/inspector_test.cc b/src/inspector/inspector_test.cc
index 689fbf4..d52001c 100644
--- a/src/inspector/inspector_test.cc
+++ b/src/inspector/inspector_test.cc
@@ -655,7 +655,7 @@
ASSERT_FALSE(inspector()->has_error()) << inspector()->error();
ASSERT_EQ(1u, result.size());
- EXPECT_EQ("foo", result[0].name);
+ EXPECT_EQ("tint_666f6f", result[0].name);
EXPECT_EQ(ast::PipelineStage::kVertex, result[0].stage);
}
@@ -674,9 +674,9 @@
ASSERT_FALSE(inspector()->has_error()) << inspector()->error();
ASSERT_EQ(2u, result.size());
- EXPECT_EQ("foo", result[0].name);
+ EXPECT_EQ("tint_666f6f", result[0].name);
EXPECT_EQ(ast::PipelineStage::kVertex, result[0].stage);
- EXPECT_EQ("bar", result[1].name);
+ EXPECT_EQ("tint_626172", result[1].name);
EXPECT_EQ(ast::PipelineStage::kCompute, result[1].stage);
}
@@ -698,9 +698,9 @@
EXPECT_FALSE(inspector()->has_error());
ASSERT_EQ(2u, result.size());
- EXPECT_EQ("foo", result[0].name);
+ EXPECT_EQ("tint_666f6f", result[0].name);
EXPECT_EQ(ast::PipelineStage::kVertex, result[0].stage);
- EXPECT_EQ("bar", result[1].name);
+ EXPECT_EQ("tint_626172", result[1].name);
EXPECT_EQ(ast::PipelineStage::kFragment, result[1].stage);
}
@@ -898,13 +898,13 @@
ASSERT_EQ(2u, result.size());
- ASSERT_EQ("foo", result[0].name);
+ ASSERT_EQ("tint_666f6f", result[0].name);
ASSERT_EQ(1u, result[0].input_variables.size());
EXPECT_EQ("in_var", result[0].input_variables[0]);
ASSERT_EQ(1u, result[0].output_variables.size());
EXPECT_EQ("out2_var", result[0].output_variables[0]);
- ASSERT_EQ("bar", result[1].name);
+ ASSERT_EQ("tint_626172", result[1].name);
ASSERT_EQ(1u, result[1].input_variables.size());
EXPECT_EQ("in2_var", result[1].input_variables[0]);
ASSERT_EQ(1u, result[1].output_variables.size());
@@ -935,7 +935,7 @@
ASSERT_EQ(2u, result.size());
- ASSERT_EQ("foo", result[0].name);
+ ASSERT_EQ("tint_666f6f", result[0].name);
EXPECT_EQ(2u, result[0].input_variables.size());
EXPECT_TRUE(ContainsString(result[0].input_variables, "in_var"));
EXPECT_TRUE(ContainsString(result[0].input_variables, "in2_var"));
@@ -943,7 +943,7 @@
EXPECT_TRUE(ContainsString(result[0].output_variables, "out_var"));
EXPECT_TRUE(ContainsString(result[0].output_variables, "out2_var"));
- ASSERT_EQ("bar", result[1].name);
+ ASSERT_EQ("tint_626172", result[1].name);
EXPECT_EQ(1u, result[1].input_variables.size());
EXPECT_EQ("in2_var", result[1].input_variables[0]);
EXPECT_EQ(1u, result[1].output_variables.size());
diff --git a/src/namer.cc b/src/namer.cc
new file mode 100644
index 0000000..3bd5bac
--- /dev/null
+++ b/src/namer.cc
@@ -0,0 +1,50 @@
+// Copyright 2020 The Tint Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "src/namer.h"
+
+#include <algorithm>
+#include <iomanip>
+#include <sstream>
+
+namespace tint {
+
+Namer::Namer() = default;
+
+Namer::~Namer() = default;
+
+std::string Namer::NameFor(const std::string& name) {
+ auto it = name_map_.find(name);
+ if (it != name_map_.end()) {
+ return it->second;
+ }
+
+ std::stringstream ret_name;
+ ret_name << "tint_";
+
+ ret_name << std::hex << std::setfill('0') << std::setw(2);
+ for (size_t i = 0; i < name.size(); ++i) {
+ ret_name << static_cast<uint32_t>(name[i]);
+ }
+
+ name_map_[name] = ret_name.str();
+ return ret_name.str();
+}
+
+bool Namer::IsMapped(const std::string& name) {
+ auto it = name_map_.find(name);
+ return it != name_map_.end();
+}
+
+} // namespace tint
diff --git a/src/namer.h b/src/namer.h
new file mode 100644
index 0000000..69acf00
--- /dev/null
+++ b/src/namer.h
@@ -0,0 +1,49 @@
+// Copyright 2020 The Tint Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef SRC_NAMER_H_
+#define SRC_NAMER_H_
+
+#include <string>
+#include <unordered_map>
+#include <unordered_set>
+
+namespace tint {
+
+/// Remaps maps names to a hashed version. This keeps the provided user input
+/// from traveling through to the backend compiler.
+class Namer {
+ public:
+ /// Constructor
+ Namer();
+ ~Namer();
+
+ /// Returns a sanitized version of |name|
+ /// @param name the name to sanitize
+ /// @returns the sanitized version of |name|
+ std::string NameFor(const std::string& name);
+
+ /// Returns if the given name has been mapped already
+ /// @param name the name to check
+ /// @returns true if the name has been mapped
+ bool IsMapped(const std::string& name);
+
+ private:
+ /// Map of original name to new name.
+ std::unordered_map<std::string, std::string> name_map_;
+};
+
+} // namespace tint
+
+#endif // SRC_NAMER_H_
diff --git a/src/namer_test.cc b/src/namer_test.cc
new file mode 100644
index 0000000..f6e64f7
--- /dev/null
+++ b/src/namer_test.cc
@@ -0,0 +1,44 @@
+// Copyright 2020 The Tint Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "src/namer.h"
+
+#include "gtest/gtest.h"
+
+namespace tint {
+namespace {
+
+using NamerTest = testing::Test;
+
+TEST_F(NamerTest, ReturnsName) {
+ Namer n;
+ EXPECT_EQ("tint_6d795f6e616d65", n.NameFor("my_name"));
+}
+
+TEST_F(NamerTest, ReturnsSameValueForSameName) {
+ Namer n;
+ EXPECT_EQ("tint_6e616d6531", n.NameFor("name1"));
+ EXPECT_EQ("tint_6e616d6532", n.NameFor("name2"));
+ EXPECT_EQ("tint_6e616d6531", n.NameFor("name1"));
+}
+
+TEST_F(NamerTest, IsMapped) {
+ Namer n;
+ EXPECT_FALSE(n.IsMapped("my_name"));
+ EXPECT_EQ("tint_6d795f6e616d65", n.NameFor("my_name"));
+ EXPECT_TRUE(n.IsMapped("my_name"));
+}
+
+} // namespace
+} // namespace tint
diff --git a/src/writer/spirv/builder.cc b/src/writer/spirv/builder.cc
index 054645f..3af0441 100644
--- a/src/writer/spirv/builder.cc
+++ b/src/writer/spirv/builder.cc
@@ -420,7 +420,7 @@
}
OperandList operands = {Operand::Int(stage), Operand::Int(id),
- Operand::String(func->name())};
+ Operand::String(namer_.NameFor(func->name()))};
for (const auto* var : func->referenced_module_variables()) {
// For SPIR-V 1.3 we only output Input/output variables. If we update to
@@ -502,8 +502,8 @@
auto func_op = result_op();
auto func_id = func_op.to_i();
- push_debug(spv::Op::OpName,
- {Operand::Int(func_id), Operand::String(func->name())});
+ push_debug(spv::Op::OpName, {Operand::Int(func_id),
+ Operand::String(namer_.NameFor(func->name()))});
auto ret_id = GenerateTypeIfNeeded(func->return_type());
if (ret_id == 0) {
@@ -528,7 +528,8 @@
}
push_debug(spv::Op::OpName,
- {Operand::Int(param_id), Operand::String(param->name())});
+ {Operand::Int(param_id),
+ Operand::String(namer_.NameFor(param->name()))});
params.push_back(Instruction{spv::Op::OpFunctionParameter,
{Operand::Int(param_type_id), param_op}});
@@ -617,8 +618,8 @@
return false;
}
- push_debug(spv::Op::OpName,
- {Operand::Int(var_id), Operand::String(var->name())});
+ push_debug(spv::Op::OpName, {Operand::Int(var_id),
+ Operand::String(namer_.NameFor(var->name()))});
// TODO(dsinclair) We could detect if the constructor is fully const and emit
// an initializer value for the variable instead of doing the OpLoad.
@@ -666,8 +667,8 @@
error_ = "missing constructor for constant";
return false;
}
- push_debug(spv::Op::OpName,
- {Operand::Int(init_id), Operand::String(var->name())});
+ push_debug(spv::Op::OpName, {Operand::Int(init_id),
+ Operand::String(namer_.NameFor(var->name()))});
scope_stack_.set_global(var->name(), init_id);
spirv_id_to_variable_[init_id] = var;
@@ -687,8 +688,8 @@
return false;
}
- push_debug(spv::Op::OpName,
- {Operand::Int(var_id), Operand::String(var->name())});
+ push_debug(spv::Op::OpName, {Operand::Int(var_id),
+ Operand::String(namer_.NameFor(var->name()))});
auto* type = var->type()->UnwrapAll();
@@ -2466,7 +2467,8 @@
if (!struct_type->name().empty()) {
push_debug(spv::Op::OpName,
- {Operand::Int(struct_id), Operand::String(struct_type->name())});
+ {Operand::Int(struct_id),
+ Operand::String(namer_.NameFor(struct_type->name()))});
}
OperandList ops;
@@ -2507,8 +2509,9 @@
uint32_t Builder::GenerateStructMember(uint32_t struct_id,
uint32_t idx,
ast::StructMember* member) {
- push_debug(spv::Op::OpMemberName, {Operand::Int(struct_id), Operand::Int(idx),
- Operand::String(member->name())});
+ push_debug(spv::Op::OpMemberName,
+ {Operand::Int(struct_id), Operand::Int(idx),
+ Operand::String(namer_.NameFor(member->name()))});
bool has_layout = false;
for (const auto& deco : member->decorations()) {
diff --git a/src/writer/spirv/builder.h b/src/writer/spirv/builder.h
index d0bc9b2..c639050 100644
--- a/src/writer/spirv/builder.h
+++ b/src/writer/spirv/builder.h
@@ -29,6 +29,7 @@
#include "src/ast/type/access_control_type.h"
#include "src/ast/type/storage_texture_type.h"
#include "src/ast/type_constructor_expression.h"
+#include "src/namer.h"
#include "src/scope_stack.h"
#include "src/writer/spirv/function.h"
#include "src/writer/spirv/instruction.h"
@@ -470,6 +471,7 @@
ast::Module* mod_;
std::string error_;
+ Namer namer_;
uint32_t next_id_ = 1;
uint32_t current_label_id_ = 0;
InstructionList capabilities_;
diff --git a/src/writer/spirv/builder_call_test.cc b/src/writer/spirv/builder_call_test.cc
index 2544a48..6a58806 100644
--- a/src/writer/spirv/builder_call_test.cc
+++ b/src/writer/spirv/builder_call_test.cc
@@ -81,10 +81,10 @@
ASSERT_TRUE(b.GenerateFunction(&func)) << b.error();
EXPECT_EQ(b.GenerateCallExpression(&expr), 14u) << b.error();
- EXPECT_EQ(DumpBuilder(b), R"(OpName %3 "a_func"
-OpName %4 "a"
-OpName %5 "b"
-OpName %12 "main"
+ EXPECT_EQ(DumpBuilder(b), R"(OpName %3 "tint_615f66756e63"
+OpName %4 "tint_61"
+OpName %5 "tint_62"
+OpName %12 "tint_6d61696e"
%2 = OpTypeFloat 32
%1 = OpTypeFunction %2 %2 %2
%11 = OpTypeVoid
@@ -149,10 +149,10 @@
ASSERT_TRUE(b.GenerateFunction(&func)) << b.error();
EXPECT_TRUE(b.GenerateStatement(&expr)) << b.error();
- EXPECT_EQ(DumpBuilder(b), R"(OpName %4 "a_func"
-OpName %5 "a"
-OpName %6 "b"
-OpName %12 "main"
+ EXPECT_EQ(DumpBuilder(b), R"(OpName %4 "tint_615f66756e63"
+OpName %5 "tint_61"
+OpName %6 "tint_62"
+OpName %12 "tint_6d61696e"
%2 = OpTypeVoid
%3 = OpTypeFloat 32
%1 = OpTypeFunction %2 %3 %3
diff --git a/src/writer/spirv/builder_function_decoration_test.cc b/src/writer/spirv/builder_function_decoration_test.cc
index 9d57e83..452efd2 100644
--- a/src/writer/spirv/builder_function_decoration_test.cc
+++ b/src/writer/spirv/builder_function_decoration_test.cc
@@ -48,7 +48,8 @@
ast::Module mod;
Builder b(&mod);
ASSERT_TRUE(b.GenerateFunction(&func)) << b.error();
- EXPECT_EQ(DumpInstructions(b.entry_points()), R"(OpEntryPoint Vertex %3 "main"
+ EXPECT_EQ(DumpInstructions(b.entry_points()),
+ R"(OpEntryPoint Vertex %3 "tint_6d61696e"
)");
}
@@ -116,10 +117,10 @@
mod.AddGlobalVariable(std::move(v_wg));
ASSERT_TRUE(b.GenerateFunction(&func)) << b.error();
- EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "my_in"
-OpName %4 "my_out"
-OpName %7 "my_wg"
-OpName %11 "main"
+ EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_6d795f696e"
+OpName %4 "tint_6d795f6f7574"
+OpName %7 "tint_6d795f7767"
+OpName %11 "tint_6d61696e"
)");
EXPECT_EQ(DumpInstructions(b.types()), R"(%3 = OpTypeFloat 32
%2 = OpTypePointer Input %3
@@ -133,7 +134,7 @@
%9 = OpTypeFunction %10
)");
EXPECT_EQ(DumpInstructions(b.entry_points()),
- R"(OpEntryPoint Vertex %11 "main"
+ R"(OpEntryPoint Vertex %11 "tint_6d61696e"
)");
}
@@ -185,10 +186,10 @@
mod.AddGlobalVariable(std::move(v_wg));
ASSERT_TRUE(b.GenerateFunction(&func)) << b.error();
- EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "my_in"
-OpName %4 "my_out"
-OpName %7 "my_wg"
-OpName %11 "main"
+ EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_6d795f696e"
+OpName %4 "tint_6d795f6f7574"
+OpName %7 "tint_6d795f7767"
+OpName %11 "tint_6d61696e"
)");
EXPECT_EQ(DumpInstructions(b.types()), R"(%3 = OpTypeFloat 32
%2 = OpTypePointer Input %3
@@ -202,7 +203,7 @@
%9 = OpTypeFunction %10
)");
EXPECT_EQ(DumpInstructions(b.entry_points()),
- R"(OpEntryPoint Vertex %11 "main" %4 %1
+ R"(OpEntryPoint Vertex %11 "tint_6d61696e" %4 %1
)");
}
@@ -269,12 +270,12 @@
ASSERT_TRUE(b.GenerateFunction(&func1)) << b.error();
ASSERT_TRUE(b.GenerateFunction(&func2)) << b.error();
EXPECT_EQ(DumpBuilder(b),
- R"(OpEntryPoint Fragment %3 "main1"
-OpEntryPoint Fragment %5 "main2"
+ R"(OpEntryPoint Fragment %3 "tint_6d61696e31"
+OpEntryPoint Fragment %5 "tint_6d61696e32"
OpExecutionMode %3 OriginUpperLeft
OpExecutionMode %5 OriginUpperLeft
-OpName %3 "main1"
-OpName %5 "main2"
+OpName %3 "tint_6d61696e31"
+OpName %5 "tint_6d61696e32"
%2 = OpTypeVoid
%1 = OpTypeFunction %2
%3 = OpFunction %2 None %1
diff --git a/src/writer/spirv/builder_function_test.cc b/src/writer/spirv/builder_function_test.cc
index 9ecc5f0..6b540de 100644
--- a/src/writer/spirv/builder_function_test.cc
+++ b/src/writer/spirv/builder_function_test.cc
@@ -53,7 +53,7 @@
Builder b(&mod);
ASSERT_TRUE(b.GenerateFunction(&func));
- EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %3 "a_func"
+ EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %3 "tint_615f66756e63"
)");
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeVoid
%1 = OpTypeFunction %2
@@ -96,9 +96,9 @@
Builder b(&mod);
ASSERT_TRUE(b.GenerateFunction(&func));
- EXPECT_EQ(DumpBuilder(b), R"(OpName %4 "a_func"
-OpName %5 "a"
-OpName %6 "b"
+ EXPECT_EQ(DumpBuilder(b), R"(OpName %4 "tint_615f66756e63"
+OpName %5 "tint_61"
+OpName %6 "tint_62"
%2 = OpTypeFloat 32
%3 = OpTypeInt 32 1
%1 = OpTypeFunction %2 %2 %3
@@ -123,7 +123,7 @@
ast::Module mod;
Builder b(&mod);
ASSERT_TRUE(b.GenerateFunction(&func));
- EXPECT_EQ(DumpBuilder(b), R"(OpName %3 "a_func"
+ EXPECT_EQ(DumpBuilder(b), R"(OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid
%1 = OpTypeFunction %2
%3 = OpFunction %2 None %1
@@ -261,17 +261,17 @@
ASSERT_TRUE(b.Build());
EXPECT_EQ(DumpBuilder(b), R"(OpCapability Shader
OpMemoryModel Logical GLSL450
-OpEntryPoint GLCompute %7 "a"
-OpEntryPoint GLCompute %17 "b"
+OpEntryPoint GLCompute %7 "tint_61"
+OpEntryPoint GLCompute %17 "tint_62"
OpExecutionMode %7 LocalSize 1 1 1
OpExecutionMode %17 LocalSize 1 1 1
-OpName %3 "Data"
-OpMemberName %3 0 "d"
-OpName %1 "data"
-OpName %7 "a"
-OpName %13 "v"
-OpName %17 "b"
-OpName %20 "v"
+OpName %3 "tint_44617461"
+OpMemberName %3 0 "tint_64"
+OpName %1 "tint_64617461"
+OpName %7 "tint_61"
+OpName %13 "tint_76"
+OpName %17 "tint_62"
+OpName %20 "tint_76"
OpDecorate %3 Block
OpMemberDecorate %3 0 Offset 0
OpDecorate %1 Binding 0
diff --git a/src/writer/spirv/builder_function_variable_test.cc b/src/writer/spirv/builder_function_variable_test.cc
index 0f39a2e..985a776 100644
--- a/src/writer/spirv/builder_function_variable_test.cc
+++ b/src/writer/spirv/builder_function_variable_test.cc
@@ -53,7 +53,7 @@
Builder b(&mod);
b.push_function(Function{});
EXPECT_TRUE(b.GenerateFunctionVariable(&v)) << b.error();
- EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "var"
+ EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_766172"
)");
EXPECT_EQ(DumpInstructions(b.types()), R"(%3 = OpTypeFloat 32
%2 = OpTypePointer Function %3
@@ -96,7 +96,7 @@
EXPECT_TRUE(b.GenerateFunctionVariable(&v)) << b.error();
ASSERT_FALSE(b.has_error()) << b.error();
- EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %6 "var"
+ EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %6 "tint_766172"
)");
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32
%1 = OpTypeVector %2 3
@@ -146,7 +146,7 @@
EXPECT_TRUE(b.GenerateFunctionVariable(&v)) << b.error();
ASSERT_FALSE(b.has_error()) << b.error();
- EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %7 "var"
+ EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %7 "tint_766172"
)");
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32
%1 = OpTypeVector %2 2
diff --git a/src/writer/spirv/builder_global_variable_test.cc b/src/writer/spirv/builder_global_variable_test.cc
index 3b9905f..9618580 100644
--- a/src/writer/spirv/builder_global_variable_test.cc
+++ b/src/writer/spirv/builder_global_variable_test.cc
@@ -57,7 +57,7 @@
ast::Module mod;
Builder b(&mod);
EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error();
- EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "var"
+ EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_766172"
)");
EXPECT_EQ(DumpInstructions(b.types()), R"(%3 = OpTypeFloat 32
%2 = OpTypePointer Private %3
@@ -73,7 +73,7 @@
ast::Module mod;
Builder b(&mod);
EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error();
- EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "var"
+ EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_766172"
)");
EXPECT_EQ(DumpInstructions(b.types()), R"(%3 = OpTypeFloat 32
%2 = OpTypePointer Output %3
@@ -89,7 +89,7 @@
ast::Module mod;
Builder b(&mod);
EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error();
- EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "var"
+ EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_766172"
)");
EXPECT_EQ(DumpInstructions(b.types()), R"(%3 = OpTypeFloat 32
%2 = OpTypePointer Input %3
@@ -125,7 +125,7 @@
EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error();
ASSERT_FALSE(b.has_error()) << b.error();
- EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %6 "var"
+ EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %6 "tint_766172"
)");
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32
%1 = OpTypeVector %2 3
@@ -166,7 +166,7 @@
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.debug()), R"(OpName %5 "tint_766172"
)");
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32
%1 = OpTypeVector %2 3
@@ -276,7 +276,7 @@
ast::Module mod;
Builder b(&mod);
EXPECT_TRUE(b.GenerateGlobalVariable(&dv)) << b.error();
- EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "var"
+ EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_766172"
)");
EXPECT_EQ(DumpInstructions(b.annots()), R"(OpDecorate %1 Location 5
)");
@@ -301,7 +301,7 @@
ast::Module mod;
Builder b(&mod);
EXPECT_TRUE(b.GenerateGlobalVariable(&dv)) << b.error();
- EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "var"
+ EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_766172"
)");
EXPECT_EQ(DumpInstructions(b.annots()), R"(OpDecorate %1 Binding 2
OpDecorate %1 DescriptorSet 3
@@ -327,7 +327,7 @@
ast::Module mod;
Builder b(&mod);
EXPECT_TRUE(b.GenerateGlobalVariable(&dv)) << b.error();
- EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "var"
+ EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_766172"
)");
EXPECT_EQ(DumpInstructions(b.annots()), R"(OpDecorate %1 BuiltIn Position
)");
@@ -353,7 +353,7 @@
ast::Module mod;
Builder b(&mod);
EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error();
- EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %3 "var"
+ EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %3 "tint_766172"
)");
EXPECT_EQ(DumpInstructions(b.annots()), R"(OpDecorate %2 SpecId 1200
)");
@@ -377,7 +377,7 @@
ast::Module mod;
Builder b(&mod);
EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error();
- EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "var"
+ EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_766172"
)");
EXPECT_EQ(DumpInstructions(b.annots()), R"(OpDecorate %4 SpecId 1200
)");
@@ -403,7 +403,7 @@
ast::Module mod;
Builder b(&mod);
EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error();
- EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %3 "var"
+ EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %3 "tint_766172"
)");
EXPECT_EQ(DumpInstructions(b.annots()), R"(OpDecorate %2 SpecId 0
)");
@@ -427,7 +427,7 @@
ast::Module mod;
Builder b(&mod);
EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error();
- EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "var"
+ EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_766172"
)");
EXPECT_EQ(DumpInstructions(b.annots()), R"(OpDecorate %4 SpecId 0
)");
@@ -451,7 +451,7 @@
ast::Module mod;
Builder b(&mod);
EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error();
- EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "var"
+ EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_766172"
)");
EXPECT_EQ(DumpInstructions(b.annots()), R"(OpDecorate %4 SpecId 0
)");
@@ -475,7 +475,7 @@
ast::Module mod;
Builder b(&mod);
EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error();
- EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "var"
+ EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_766172"
)");
EXPECT_EQ(DumpInstructions(b.annots()), R"(OpDecorate %4 SpecId 0
)");
@@ -551,10 +551,10 @@
EXPECT_EQ(DumpInstructions(b.annots()), R"(OpMemberDecorate %3 0 NonWritable
OpMemberDecorate %3 1 NonWritable
)");
- EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %3 "A"
-OpMemberName %3 0 "a"
-OpMemberName %3 1 "b"
-OpName %1 "b"
+ EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %3 "tint_41"
+OpMemberName %3 0 "tint_61"
+OpMemberName %3 1 "tint_62"
+OpName %1 "tint_62"
)");
EXPECT_EQ(DumpInstructions(b.types()), R"(%4 = OpTypeInt 32 1
%3 = OpTypeStruct %4 %4
@@ -590,9 +590,9 @@
EXPECT_EQ(DumpInstructions(b.annots()), R"(OpMemberDecorate %3 0 NonWritable
)");
- EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %3 "A"
-OpMemberName %3 0 "a"
-OpName %1 "b"
+ EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %3 "tint_41"
+OpMemberName %3 0 "tint_61"
+OpName %1 "tint_62"
)");
EXPECT_EQ(DumpInstructions(b.types()), R"(%4 = OpTypeInt 32 1
%3 = OpTypeStruct %4
@@ -628,9 +628,9 @@
EXPECT_EQ(DumpInstructions(b.annots()), R"(OpMemberDecorate %3 0 NonWritable
)");
- EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %3 "A"
-OpMemberName %3 0 "a"
-OpName %1 "b"
+ EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %3 "tint_41"
+OpMemberName %3 0 "tint_61"
+OpName %1 "tint_62"
)");
EXPECT_EQ(DumpInstructions(b.types()), R"(%4 = OpTypeInt 32 1
%3 = OpTypeStruct %4
@@ -668,12 +668,12 @@
EXPECT_EQ(DumpInstructions(b.annots()), R"(OpMemberDecorate %3 0 NonWritable
)");
- EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %3 "A"
-OpMemberName %3 0 "a"
-OpName %1 "b"
-OpName %7 "A"
-OpMemberName %7 0 "a"
-OpName %5 "c"
+ EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %3 "tint_41"
+OpMemberName %3 0 "tint_61"
+OpName %1 "tint_62"
+OpName %7 "tint_41"
+OpMemberName %7 0 "tint_61"
+OpName %5 "tint_63"
)");
EXPECT_EQ(DumpInstructions(b.types()), R"(%4 = OpTypeInt 32 1
%3 = OpTypeStruct %4
diff --git a/src/writer/spirv/builder_ident_expression_test.cc b/src/writer/spirv/builder_ident_expression_test.cc
index 147af57..b110319 100644
--- a/src/writer/spirv/builder_ident_expression_test.cc
+++ b/src/writer/spirv/builder_ident_expression_test.cc
@@ -92,7 +92,7 @@
Builder b(&mod);
b.push_function(Function{});
EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error();
- EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "var"
+ EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_766172"
)");
EXPECT_EQ(DumpInstructions(b.types()), R"(%3 = OpTypeFloat 32
%2 = OpTypePointer Output %3
@@ -158,7 +158,7 @@
Builder b(&mod);
b.push_function(Function{});
EXPECT_TRUE(b.GenerateFunctionVariable(&v)) << b.error();
- EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "var"
+ EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_766172"
)");
EXPECT_EQ(DumpInstructions(b.types()), R"(%3 = OpTypeFloat 32
%2 = OpTypePointer Function %3
diff --git a/src/writer/spirv/builder_intrinsic_test.cc b/src/writer/spirv/builder_intrinsic_test.cc
index 2118f3d..289d966 100644
--- a/src/writer/spirv/builder_intrinsic_test.cc
+++ b/src/writer/spirv/builder_intrinsic_test.cc
@@ -1409,8 +1409,8 @@
EXPECT_EQ(b.GenerateCallExpression(&expr), 9u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%10 = OpExtInstImport "GLSL.std.450"
-OpName %1 "ident"
-OpName %7 "a_func"
+OpName %1 "tint_6964656e74"
+OpName %7 "tint_615f66756e63"
%3 = OpTypeFloat 32
%2 = OpTypePointer Private %3
%4 = OpConstantNull %3
@@ -1454,7 +1454,7 @@
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450"
-OpName %3 "a_func"
+OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid
%1 = OpTypeFunction %2
%6 = OpTypeFloat 32
@@ -1501,7 +1501,7 @@
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450"
-OpName %3 "a_func"
+OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid
%1 = OpTypeFunction %2
%7 = OpTypeFloat 32
@@ -1565,7 +1565,7 @@
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450"
-OpName %3 "a_func"
+OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid
%1 = OpTypeFunction %2
%6 = OpTypeFloat 32
@@ -1608,7 +1608,7 @@
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450"
-OpName %3 "a_func"
+OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid
%1 = OpTypeFunction %2
%6 = OpTypeFloat 32
@@ -1654,7 +1654,7 @@
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450"
-OpName %3 "a_func"
+OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid
%1 = OpTypeFunction %2
%7 = OpTypeFloat 32
@@ -1699,7 +1699,7 @@
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450"
-OpName %3 "a_func"
+OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid
%1 = OpTypeFunction %2
%6 = OpTypeFloat 32
@@ -1754,7 +1754,7 @@
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450"
-OpName %3 "a_func"
+OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid
%1 = OpTypeFunction %2
%7 = OpTypeFloat 32
@@ -1804,7 +1804,7 @@
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450"
-OpName %3 "a_func"
+OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid
%1 = OpTypeFunction %2
%6 = OpTypeFloat 32
@@ -1856,7 +1856,7 @@
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450"
-OpName %3 "a_func"
+OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid
%1 = OpTypeFunction %2
%6 = OpTypeFloat 32
@@ -1913,7 +1913,7 @@
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450"
-OpName %3 "a_func"
+OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid
%1 = OpTypeFunction %2
%7 = OpTypeFloat 32
@@ -1960,7 +1960,7 @@
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450"
-OpName %3 "a_func"
+OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid
%1 = OpTypeFunction %2
%6 = OpTypeFloat 32
@@ -2023,7 +2023,7 @@
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450"
-OpName %3 "a_func"
+OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid
%1 = OpTypeFunction %2
%7 = OpTypeFloat 32
@@ -2076,7 +2076,7 @@
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450"
-OpName %3 "a_func"
+OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid
%1 = OpTypeFunction %2
%6 = OpTypeInt 32 1
@@ -2123,7 +2123,7 @@
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450"
-OpName %3 "a_func"
+OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid
%1 = OpTypeFunction %2
%7 = OpTypeInt 32 1
@@ -2170,7 +2170,7 @@
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450"
-OpName %3 "a_func"
+OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid
%1 = OpTypeFunction %2
%6 = OpTypeInt 32 0
@@ -2217,7 +2217,7 @@
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450"
-OpName %3 "a_func"
+OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid
%1 = OpTypeFunction %2
%7 = OpTypeInt 32 0
@@ -2266,7 +2266,7 @@
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450"
-OpName %3 "a_func"
+OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid
%1 = OpTypeFunction %2
%6 = OpTypeInt 32 1
@@ -2321,7 +2321,7 @@
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450"
-OpName %3 "a_func"
+OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid
%1 = OpTypeFunction %2
%7 = OpTypeInt 32 1
@@ -2371,7 +2371,7 @@
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450"
-OpName %3 "a_func"
+OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid
%1 = OpTypeFunction %2
%6 = OpTypeInt 32 0
@@ -2426,7 +2426,7 @@
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450"
-OpName %3 "a_func"
+OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid
%1 = OpTypeFunction %2
%7 = OpTypeInt 32 0
@@ -2478,7 +2478,7 @@
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450"
-OpName %3 "a_func"
+OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid
%1 = OpTypeFunction %2
%6 = OpTypeInt 32 1
@@ -2541,7 +2541,7 @@
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450"
-OpName %3 "a_func"
+OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid
%1 = OpTypeFunction %2
%7 = OpTypeInt 32 1
@@ -2592,7 +2592,7 @@
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%7 = OpExtInstImport "GLSL.std.450"
-OpName %3 "a_func"
+OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid
%1 = OpTypeFunction %2
%6 = OpTypeInt 32 0
@@ -2655,7 +2655,7 @@
EXPECT_EQ(b.GenerateCallExpression(&expr), 5u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%8 = OpExtInstImport "GLSL.std.450"
-OpName %3 "a_func"
+OpName %3 "tint_615f66756e63"
%2 = OpTypeVoid
%1 = OpTypeFunction %2
%7 = OpTypeInt 32 0
@@ -2704,8 +2704,8 @@
EXPECT_EQ(b.GenerateCallExpression(&expr), 11u) << b.error();
EXPECT_EQ(DumpBuilder(b), R"(%12 = OpExtInstImport "GLSL.std.450"
-OpName %3 "a_func"
-OpName %5 "var"
+OpName %3 "tint_615f66756e63"
+OpName %5 "tint_766172"
%2 = OpTypeVoid
%1 = OpTypeFunction %2
%9 = OpTypeFloat 32
diff --git a/src/writer/spirv/builder_switch_test.cc b/src/writer/spirv/builder_switch_test.cc
index 28a0b36..7d30580 100644
--- a/src/writer/spirv/builder_switch_test.cc
+++ b/src/writer/spirv/builder_switch_test.cc
@@ -128,9 +128,9 @@
EXPECT_TRUE(b.GenerateSwitchStatement(&expr)) << b.error();
- EXPECT_EQ(DumpBuilder(b), R"(OpName %1 "v"
-OpName %5 "a"
-OpName %7 "a_func"
+ EXPECT_EQ(DumpBuilder(b), R"(OpName %1 "tint_76"
+OpName %5 "tint_61"
+OpName %7 "tint_615f66756e63"
%3 = OpTypeInt 32 1
%2 = OpTypePointer Private %3
%4 = OpConstantNull %3
@@ -199,9 +199,9 @@
EXPECT_TRUE(b.GenerateSwitchStatement(&expr)) << b.error();
- EXPECT_EQ(DumpBuilder(b), R"(OpName %1 "v"
-OpName %5 "a"
-OpName %7 "a_func"
+ EXPECT_EQ(DumpBuilder(b), R"(OpName %1 "tint_76"
+OpName %5 "tint_61"
+OpName %7 "tint_615f66756e63"
%3 = OpTypeInt 32 1
%2 = OpTypePointer Private %3
%4 = OpConstantNull %3
@@ -291,9 +291,9 @@
EXPECT_TRUE(b.GenerateSwitchStatement(&expr)) << b.error();
- EXPECT_EQ(DumpBuilder(b), R"(OpName %1 "v"
-OpName %5 "a"
-OpName %7 "a_func"
+ EXPECT_EQ(DumpBuilder(b), R"(OpName %1 "tint_76"
+OpName %5 "tint_61"
+OpName %7 "tint_615f66756e63"
%3 = OpTypeInt 32 1
%2 = OpTypePointer Private %3
%4 = OpConstantNull %3
@@ -392,9 +392,9 @@
EXPECT_TRUE(b.GenerateSwitchStatement(&expr)) << b.error();
- EXPECT_EQ(DumpBuilder(b), R"(OpName %1 "v"
-OpName %5 "a"
-OpName %7 "a_func"
+ EXPECT_EQ(DumpBuilder(b), R"(OpName %1 "tint_76"
+OpName %5 "tint_61"
+OpName %7 "tint_615f66756e63"
%3 = OpTypeInt 32 1
%2 = OpTypePointer Private %3
%4 = OpConstantNull %3
@@ -529,9 +529,9 @@
EXPECT_TRUE(b.GenerateSwitchStatement(&expr)) << b.error();
- EXPECT_EQ(DumpBuilder(b), R"(OpName %1 "v"
-OpName %5 "a"
-OpName %7 "a_func"
+ EXPECT_EQ(DumpBuilder(b), R"(OpName %1 "tint_76"
+OpName %5 "tint_61"
+OpName %7 "tint_615f66756e63"
%3 = OpTypeInt 32 1
%2 = OpTypePointer Private %3
%4 = OpConstantNull %3
diff --git a/src/writer/spirv/builder_type_test.cc b/src/writer/spirv/builder_type_test.cc
index 51211a4..2759e16 100644
--- a/src/writer/spirv/builder_type_test.cc
+++ b/src/writer/spirv/builder_type_test.cc
@@ -322,7 +322,7 @@
EXPECT_EQ(id, 1u);
EXPECT_EQ(b.types().size(), 1u);
- EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "S"
+ EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_53"
)");
EXPECT_EQ(DumpInstructions(b.types()), R"(%1 = OpTypeStruct
)");
@@ -348,8 +348,8 @@
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32
%1 = OpTypeStruct %2
)");
- EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "my_struct"
-OpMemberName %1 0 "a"
+ EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_6d795f737472756374"
+OpMemberName %1 0 "tint_61"
)");
}
@@ -378,8 +378,8 @@
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32
%1 = OpTypeStruct %2
)");
- EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "my_struct"
-OpMemberName %1 0 "a"
+ EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_6d795f737472756374"
+OpMemberName %1 0 "tint_61"
)");
EXPECT_EQ(DumpInstructions(b.annots()), R"(OpDecorate %1 Block
)");
@@ -413,9 +413,9 @@
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32
%1 = OpTypeStruct %2 %2
)");
- EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "S"
-OpMemberName %1 0 "a"
-OpMemberName %1 1 "b"
+ EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_53"
+OpMemberName %1 0 "tint_61"
+OpMemberName %1 1 "tint_62"
)");
EXPECT_EQ(DumpInstructions(b.annots()), R"(OpMemberDecorate %1 0 Offset 0
OpMemberDecorate %1 1 Offset 8
@@ -458,10 +458,10 @@
%7 = OpTypeMatrix %8 4
%1 = OpTypeStruct %2 %5 %7
)");
- EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "S"
-OpMemberName %1 0 "a"
-OpMemberName %1 1 "b"
-OpMemberName %1 2 "c"
+ EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_53"
+OpMemberName %1 0 "tint_61"
+OpMemberName %1 1 "tint_62"
+OpMemberName %1 2 "tint_63"
)");
EXPECT_EQ(DumpInstructions(b.annots()), "");
}
@@ -509,10 +509,10 @@
%7 = OpTypeMatrix %8 4
%1 = OpTypeStruct %2 %5 %7
)");
- EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "S"
-OpMemberName %1 0 "a"
-OpMemberName %1 1 "b"
-OpMemberName %1 2 "c"
+ EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_53"
+OpMemberName %1 0 "tint_61"
+OpMemberName %1 1 "tint_62"
+OpMemberName %1 2 "tint_63"
)");
EXPECT_EQ(DumpInstructions(b.annots()), R"(OpMemberDecorate %1 0 Offset 0
OpMemberDecorate %1 0 ColMajor
@@ -578,10 +578,10 @@
%7 = OpTypeMatrix %8 4
%1 = OpTypeStruct %2 %5 %7
)");
- EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "S"
-OpMemberName %1 0 "a"
-OpMemberName %1 1 "b"
-OpMemberName %1 2 "c"
+ EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "tint_53"
+OpMemberName %1 0 "tint_61"
+OpMemberName %1 1 "tint_62"
+OpMemberName %1 2 "tint_63"
)");
EXPECT_EQ(DumpInstructions(b.annots()), R"(OpMemberDecorate %1 0 Offset 0
OpMemberDecorate %1 0 ColMajor