From 898f67ca3b2b727ab7f4f4e74f10a8daed19365b Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Tue, 24 Jan 2017 11:45:47 +0100 Subject: [PATCH] Directly assign initializers to variables in variable declarations .. instead of first assigning to a temporary and then assigning the temporary to the argument/local. Change-Id: I15a6c2073b78c5cfc829c7edef07c6bf48be7886 Reviewed-by: Lars Knoll --- src/qml/compiler/qv4codegen.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index d9c1e90125..7d3ad38f97 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -842,9 +842,16 @@ void Codegen::variableDeclaration(VariableDeclaration *ast) Q_ASSERT(expr.code); initializer = *expr; - int initialized = _block->newTemp(); - move(_block->TEMP(initialized), initializer); - move(identifier(ast->name.toString(), ast->identifierToken.startLine, ast->identifierToken.startColumn), _block->TEMP(initialized)); + IR::Expr *lhs = identifier(ast->name.toString(), ast->identifierToken.startLine, + ast->identifierToken.startColumn); + + if (lhs->asArgLocal()) { + move(lhs, initializer); + } else { + int initialized = _block->newTemp(); + move(_block->TEMP(initialized), initializer); + move(lhs, _block->TEMP(initialized)); + } } void Codegen::variableDeclarationList(VariableDeclarationList *ast)