diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2016-11-22 15:16:09 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2016-11-22 15:40:58 +0000 |
commit | c4ebe96c34c2179d0ebdc555afdce179e3de52e8 (patch) | |
tree | 37402695319c25c016ddebeebfe4d241d2b02201 /src/qml/compiler/qv4ssa.cpp | |
parent | 5ffd0d8be35cea57acbf1e8d7a740d3fab5cbe43 (diff) |
Improved robustness of the optimizer when removing expressions
For example during dead code elimination we may invalidate statements,
but at the same time there may still be instances left in the work list
of optimizeSSA(). When we encounter then, we should not process them any
further.
Task-number: QTBUG-56255
Change-Id: I4c24b1a225ce1bde112172e9606f91c426c19f19
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4ssa.cpp')
-rw-r--r-- | src/qml/compiler/qv4ssa.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/qml/compiler/qv4ssa.cpp b/src/qml/compiler/qv4ssa.cpp index f20dbbf4fe..93692b3996 100644 --- a/src/qml/compiler/qv4ssa.cpp +++ b/src/qml/compiler/qv4ssa.cpp @@ -1968,14 +1968,9 @@ public: return *this; } - bool isEmpty() const - { - return worklistSize == 0; - } - Stmt *takeNext(Stmt *last) { - if (isEmpty()) + if (worklistSize == 0) return 0; const int startAt = last ? last->id() + 1 : 0; @@ -1991,6 +1986,10 @@ public: --worklistSize; Stmt *s = stmts.at(pos); Q_ASSERT(s); + + if (removed.at(s->id())) + return takeNext(s); + return s; } @@ -3960,9 +3959,7 @@ void optimizeSSA(StatementWorklist &W, DefUses &defUses, DominatorTree &df) ExprReplacer replaceUses(defUses, function); Stmt *s = 0; - while (!W.isEmpty()) { - s = W.takeNext(s); - Q_ASSERT(s); + while ((s = W.takeNext(s))) { if (Phi *phi = s->asPhi()) { // dead code elimination: |