diff options
author | Erik Verbruggen <erik.verbruggen@digia.com> | 2015-03-02 14:22:24 +0100 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@theqtcompany.com> | 2015-03-03 10:03:56 +0000 |
commit | b368fe0167666cc7ce264705653107ffc21ac8cc (patch) | |
tree | 271fd9dedb9bcc93ce6efa03f6905495012aaabd /src/qml/jit | |
parent | ac4dcc585f4fb02b9b04867c75a883e4ad23693e (diff) |
V4: fix phi node use position calculation.
As phi-nodes get transformed into moves, and the moves end up right
before the terminator of the basic block of the incoming edge, the
use by that phi-node is the position of that terminator minus one.
However, when checking if uses need a register, this was not taken into
account, resulting in an invalid life-time interval split position
calculation.
Task-number: QTBUG-44687
Change-Id: I0edd416f7ee5c8ea16bf7133870be45d0e6efea9
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@theqtcompany.com>
Diffstat (limited to 'src/qml/jit')
-rw-r--r-- | src/qml/jit/qv4regalloc.cpp | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/src/qml/jit/qv4regalloc.cpp b/src/qml/jit/qv4regalloc.cpp index 4bc8e14fbf..b34cd7bd68 100644 --- a/src/qml/jit/qv4regalloc.cpp +++ b/src/qml/jit/qv4regalloc.cpp @@ -185,21 +185,7 @@ public: const std::vector<Use> &uses(const Temp &t) const { - return _uses[t.index]; - } - - bool useMustHaveReg(const Temp &t, int position) { - foreach (const Use &use, uses(t)) - if (use.pos == position) - return use.mustHaveRegister(); - return false; - } - - bool isUsedAt(const Temp &t, int position) { - foreach (const Use &use, uses(t)) - if (use.pos == position) - return true; - return false; + return _uses.at(t.index); } bool canHaveRegister(const Temp &t) const { @@ -699,9 +685,13 @@ protected: // IRDecoder virtual void visitPhi(IR::Phi *s) { addDef(s->targetTemp, true); - foreach (Expr *e, s->d->incoming) { + for (int i = 0, ei = s->d->incoming.size(); i < ei; ++i) { + Expr *e = s->d->incoming.at(i); if (Temp *t = e->asTemp()) { - addUses(t, Use::CouldHaveRegister); + // The actual use of an incoming value in a phi node is right before the terminator + // of the other side of the incoming edge. + const int usePos = _lifeTimeIntervals->positionForStatement(_currentBB->in.at(i)->terminator()) - 1; + addUses(t, Use::CouldHaveRegister, usePos); addHint(s->targetTemp, t); addHint(t, s->targetTemp); } @@ -747,6 +737,11 @@ private: void addUses(Expr *e, Use::RegisterFlag flag) { const int usePos = usePosition(_currentStmt); + addUses(e, flag, usePos); + } + + void addUses(Expr *e, Use::RegisterFlag flag, int usePos) + { Q_ASSERT(usePos > 0); if (!e) return; |