From 4ebd6f29822f33da30e055daebb287d23404167e Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Wed, 14 Nov 2012 12:18:50 +0100 Subject: Fix optimisation for passing a single argument to a call. Change-Id: I57a881ccd9f86a36d2d2ea5451046652ac0aca21 Reviewed-by: Lars Knoll --- moth/qv4isel_moth.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'moth') diff --git a/moth/qv4isel_moth.cpp b/moth/qv4isel_moth.cpp index 9550bb6f8e..d66673d0be 100644 --- a/moth/qv4isel_moth.cpp +++ b/moth/qv4isel_moth.cpp @@ -244,15 +244,22 @@ void InstructionSelection::prepareCallArgs(IR::ExprList *e, quint32 &argc, quint argc = 0; args = 0; - /* - int locals = _function->tempCount - _function->locals.size() + _function->maxNumberOfArguments; + bool singleArgIsTemp = false; + if (e && e->next == 0) { + // ok, only 1 argument in the cal... + const int idx = e->expr->asTemp()->index; + if (idx >= 0) { + // not an argument to this function... + // so if it's not a local, we're in: + singleArgIsTemp = idx >= _function->locals.size(); + } + } - The condition for this case is wrong: the locals check is incorrect: - if (e && e->next == 0 && e->expr->asTemp()->index >= 0 && e->expr->asTemp()->index < locals) { - // We pass single arguments as references to the stack + if (singleArgIsTemp) { + // We pass single arguments as references to the stack, but only if it's not a local or an argument. argc = 1; args = e->expr->asTemp()->index; - } else */if (e) { + } else if (e) { // We need to move all the temps into the function arg array int argLocation = _function->tempCount - _function->locals.size(); assert(argLocation >= 0); -- cgit v1.2.3