From f32719ff85f06657204202668055b63b77d72e1e Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Sat, 17 Apr 2021 06:01:41 +0000 Subject: [PATCH] reader/spirv: Don't create detatched AST nodes EmitControlBarrier() was calling MakeOperand() to create ast::Expressions that held a ScalarConstructorExpression, which held a IntLiteral. The literal value was then taken, and the rest was discarded. Detached AST nodes will become an ICE, so do the work to find the literal value. Bug: tint:469 Change-Id: I522bfe8db84e853e189c714b18598feb0d49e58b Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48049 Commit-Queue: Ben Clayton Reviewed-by: James Price --- src/reader/spirv/function.cc | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/reader/spirv/function.cc b/src/reader/spirv/function.cc index 96191b3e07..9c5b8b4af8 100644 --- a/src/reader/spirv/function.cc +++ b/src/reader/spirv/function.cc @@ -4201,14 +4201,12 @@ bool FunctionEmitter::EmitControlBarrier( const spvtools::opt::Instruction& inst) { uint32_t operands[3]; for (int i = 0; i < 3; i++) { - if (auto* op = MakeOperand(inst, i).expr) { - auto* lit = As(op)->literal(); - if (auto* int_lit = lit->As()) { - operands[i] = int_lit->value_as_u32(); - continue; - } + auto id = inst.GetSingleWordInOperand(i); + if (auto* constant = constant_mgr_->FindDeclaredConstant(id)) { + operands[i] = constant->GetU32(); + } else { + return Fail() << "invalid or missing operands for control barrier"; } - return Fail() << "invalid or missing operands for control barrier"; } uint32_t execution = operands[0];