summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-09-14 20:38:16 -0700
committerAlon Zakai <alonzakai@gmail.com>2016-09-14 20:38:16 -0700
commitd90f13b7fd15b688f03fd8f1dad481d2f2236a59 (patch)
tree5089141bb7f4562147c2eef588cfb3c60724afaf /src
parent76a621f50b579e24f4210c1e2d35a9b3f72b0f94 (diff)
downloadbinaryen-d90f13b7fd15b688f03fd8f1dad481d2f2236a59.tar.gz
binaryen-d90f13b7fd15b688f03fd8f1dad481d2f2236a59.tar.bz2
binaryen-d90f13b7fd15b688f03fd8f1dad481d2f2236a59.zip
allocate newCopies on demand in coalesce-locals, to avoid n^2 allocation when in practice we need a lot less (and on e.g. sqlite, n^2 is very large)
Diffstat (limited to 'src')
-rw-r--r--src/passes/CoalesceLocals.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/passes/CoalesceLocals.cpp b/src/passes/CoalesceLocals.cpp
index 503b7ad2a..d74500bb5 100644
--- a/src/passes/CoalesceLocals.cpp
+++ b/src/passes/CoalesceLocals.cpp
@@ -440,7 +440,7 @@ void CoalesceLocals::pickIndicesFromOrder(std::vector<Index>& order, std::vector
newInterferences.resize(numLocals * numLocals);
std::fill(newInterferences.begin(), newInterferences.end(), 0);
auto numParams = getFunction()->getNumParams();
- newCopies.resize(numLocals * numLocals);
+ newCopies.resize(numParams * numLocals); // start with enough room for the params
std::fill(newCopies.begin(), newCopies.end(), 0);
Index nextFree = 0;
removedCopies = 0;
@@ -476,6 +476,7 @@ void CoalesceLocals::pickIndicesFromOrder(std::vector<Index>& order, std::vector
types[found] = getFunction()->getLocalType(actual);
nextFree++;
removedCopies += getCopies(found, actual);
+ newCopies.resize(nextFree * numLocals);
} else {
removedCopies += foundCopies;
}