[spirv-reader][ir] Add OpSpecConstantComposite id's to the id stack.
When creating a constant composite we were replacing the id meaning, but
not inserting the ID into the scope stack, so it did not appear to be
in scope when subsequently used.
Use the `AddValue` helper instead of inserting the value directly so
it's added to the id scope stack.
Bug: 429651458
Change-Id: I77db090d5f2fe59aa92ce31818cb679369ea99d9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/250876
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: James Price <jrprice@google.com>
diff --git a/src/tint/lang/spirv/reader/parser/parser.cc b/src/tint/lang/spirv/reader/parser/parser.cc
index 1e2e580..d185d62 100644
--- a/src/tint/lang/spirv/reader/parser/parser.cc
+++ b/src/tint/lang/spirv/reader/parser/parser.cc
@@ -1221,7 +1221,7 @@
auto* construct = b_.Construct(iter->second.type, args);
current_block_->Append(construct);
- values_.Replace(id, construct->Result());
+ AddValue(id, construct->Result());
return construct->Result();
}
diff --git a/src/tint/lang/spirv/reader/parser/var_test.cc b/src/tint/lang/spirv/reader/parser/var_test.cc
index 63ab072..0140c63 100644
--- a/src/tint/lang/spirv/reader/parser/var_test.cc
+++ b/src/tint/lang/spirv/reader/parser/var_test.cc
@@ -3102,6 +3102,47 @@
)");
}
+TEST_F(SpirvParserTest, Var_OpSpecConstantComposite_Extracted) {
+ EXPECT_IR(R"(
+ OpCapability Shader
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint GLCompute %main "main"
+ OpExecutionMode %main LocalSize 1 1 1
+ OpName %1 "myconst"
+ OpDecorate %one SpecId 1
+ OpDecorate %two SpecId 2
+ %void = OpTypeVoid
+ %i32 = OpTypeInt 32 1
+ %v2i = OpTypeVector %i32 2
+ %one = OpSpecConstant %i32 1
+ %two = OpSpecConstant %i32 2
+ %1 = OpSpecConstantComposite %v2i %one %two
+ %foo = OpSpecConstantOp %i32 CompositeExtract %1 1
+ %voidfn = OpTypeFunction %void
+ %main = OpFunction %void None %voidfn
+ %main_entry = OpLabel
+ %3 = OpIAdd %i32 %foo %foo
+ OpReturn
+ OpFunctionEnd
+)",
+ R"(
+$B1: { # root
+ %1:i32 = override 1i @id(1)
+ %2:i32 = override 2i @id(2)
+ %3:vec2<i32> = construct %1, %2
+ %4:i32 = access %3, 1u
+ %5:i32 = override %4
+}
+
+%main = @compute @workgroup_size(1u, 1u, 1u) func():void {
+ $B2: {
+ %7:i32 = spirv.add<i32> %5, %5
+ ret
+ }
+}
+)");
+}
+
TEST_F(SpirvParserTest, InterpolationFlatNoLocation) {
EXPECT_IR(R"(
OpCapability Shader