From 432f5e6081837cfb6fcf9db9f41769a323b873e0 Mon Sep 17 00:00:00 2001 From: Alex Light Date: Fri, 31 Jan 2025 12:25:32 -0800 Subject: [PATCH] Avoid copying interp-values in EvalCreateTuple This could cause significant memory use. Fixes: https://github.com/google/xls/issues/1897 PiperOrigin-RevId: 721862074 --- xls/dslx/bytecode/bytecode_interpreter.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xls/dslx/bytecode/bytecode_interpreter.cc b/xls/dslx/bytecode/bytecode_interpreter.cc index 2625447740..886561ceb6 100644 --- a/xls/dslx/bytecode/bytecode_interpreter.cc +++ b/xls/dslx/bytecode/bytecode_interpreter.cc @@ -762,12 +762,12 @@ absl::Status BytecodeInterpreter::EvalCreateTuple(const Bytecode& bytecode) { elements.reserve(tuple_size.value()); for (int64_t i = 0; i < tuple_size.value(); i++) { XLS_ASSIGN_OR_RETURN(InterpValue value, Pop()); - elements.push_back(value); + elements.push_back(std::move(value)); } std::reverse(elements.begin(), elements.end()); - stack_.Push(InterpValue::MakeTuple(elements)); + stack_.Push(InterpValue::MakeTuple(std::move(elements))); return absl::OkStatus(); }