From c7b85b0cdcba7e0aecb210b04d5a99f77ec4375c Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Mon, 11 Aug 2014 13:20:07 +0200 Subject: V4 RegAlloc: fix use position calculation for phi node arguments. The correct calculation was already done, but the value was discarded. Change-Id: I600aeb9414736a3b7924a4a607233ab9bf6c02b6 Reviewed-by: Simon Hausmann --- src/qml/jit/qv4regalloc.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'src/qml/jit') diff --git a/src/qml/jit/qv4regalloc.cpp b/src/qml/jit/qv4regalloc.cpp index 2192b8e60b..50f35e3db5 100644 --- a/src/qml/jit/qv4regalloc.cpp +++ b/src/qml/jit/qv4regalloc.cpp @@ -53,7 +53,8 @@ struct Use { unsigned pos : 31; Use(): flag(MustHaveRegister), pos(0) {} - Use(int pos, RegisterFlag flag): flag(flag), pos(pos) {} + Use(int position, RegisterFlag flag): flag(flag), pos(position) + { Q_ASSERT(position >= 0); } bool mustHaveRegister() const { return flag == MustHaveRegister; } }; @@ -162,14 +163,12 @@ class RegAllocInfo: public IRDecoder std::vector _calls; std::vector > _hints; - int defPosition(Stmt *s) const - { - return usePosition(s) + 1; - } - int usePosition(Stmt *s) const { - return _lifeTimeIntervals->positionForStatement(s); + int usePos = _lifeTimeIntervals->positionForStatement(s); + if (usePos == Stmt::InvalidId) // phi-node operand, so: + usePos = _lifeTimeIntervals->startPosition(_currentBB); + return usePos; } public: @@ -752,9 +751,7 @@ private: void addUses(Expr *e, Use::RegisterFlag flag) { - int usePos = usePosition(_currentStmt); - if (usePos == Stmt::InvalidId) - usePos = _lifeTimeIntervals->startPosition(_currentBB); + const int usePos = usePosition(_currentStmt); Q_ASSERT(usePos > 0); if (!e) return; @@ -762,7 +759,7 @@ private: if (!t) return; if (t && t->kind == Temp::VirtualRegister) - _uses[t->index].push_back(Use(usePosition(_currentStmt), flag)); + _uses[t->index].push_back(Use(usePos, flag)); } void addUses(ExprList *l, Use::RegisterFlag flag) -- cgit v1.2.3