aboutsummaryrefslogtreecommitdiffstats
path: root/moth
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@digia.com>2012-12-19 15:48:42 +0100
committerLars Knoll <lars.knoll@digia.com>2012-12-20 09:44:57 +0100
commit274583f2dbf53ec296e50f0e68a7907d90482cee (patch)
treeea0d0e3f6295731b5bbe5c31bcf0e57aef2b814b /moth
parent278eba11a464d2a2b2b842018508d2e02aac9df1 (diff)
Another fix to the temp compression.
Pin all temps that escape BBs, not only the return value. Change-Id: Idf21d117bfd12224cbff4cef35766c454189a5fa Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'moth')
-rw-r--r--moth/qv4isel_moth.cpp32
1 files changed, 17 insertions, 15 deletions
diff --git a/moth/qv4isel_moth.cpp b/moth/qv4isel_moth.cpp
index 0277fc60f1..8f1dfa3143 100644
--- a/moth/qv4isel_moth.cpp
+++ b/moth/qv4isel_moth.cpp
@@ -37,7 +37,21 @@ public:
_nextFree = 0;
_active.reserve(function->tempCount);
_localCount = function->locals.size();
- pinReturnTemp(function);
+
+ QVector<int> pinned;
+ foreach (IR::BasicBlock *block, function->basicBlocks) {
+ if (IR::Stmt *last = block->terminator()) {
+ const QBitArray &liveOut = last->d->liveOut;
+ for (int i = 0, ei = liveOut.size(); i < ei; ++i) {
+ if (liveOut.at(i) && !pinned.contains(i)) {
+ pinned.append(i);
+ add(i - _localCount, _nextFree);
+ }
+ }
+ }
+ }
+ _pinnedCount = _nextFree;
+
int maxUsed = _nextFree;
foreach (IR::BasicBlock *block, function->basicBlocks) {
@@ -66,18 +80,6 @@ public:
}
private:
- void pinReturnTemp(IR::Function *function) {
- const IR::BasicBlock *returnBlock = function->basicBlocks.last();
- assert(returnBlock);
- IR::Ret *ret = returnBlock->terminator()->asRet();
- assert(ret);
- IR::Temp *t = ret->expr->asTemp();
- assert(t);
- assert(t->index >= 0);
- _pinnedReturnValue = _nextFree;
- add(t->index, _pinnedReturnValue);
- }
-
virtual void visitConst(IR::Const *) {}
virtual void visitString(IR::String *) {}
virtual void visitRegExp(IR::RegExp *) {}
@@ -157,7 +159,7 @@ private:
while (i < _active.size()) {
const QPair<int, int> &p = _active[i];
- if (p.second == _pinnedReturnValue) {
+ if (p.second < _pinnedCount) {
inUse.setBit(p.second);
++i;
continue;
@@ -186,7 +188,7 @@ private:
IR::Stmt *_currentStatement;
int _localCount;
int _nextFree;
- int _pinnedReturnValue;
+ int _pinnedCount;
};
} // anonymous namespace