diff options
Diffstat (limited to 'src/passes/ReorderLocals.cpp')
-rw-r--r-- | src/passes/ReorderLocals.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/passes/ReorderLocals.cpp b/src/passes/ReorderLocals.cpp index 04e9c274b..9eea0b73c 100644 --- a/src/passes/ReorderLocals.cpp +++ b/src/passes/ReorderLocals.cpp @@ -37,19 +37,20 @@ struct ReorderLocals : public WalkerPass<PostWalker<ReorderLocals>> { // local index => times it is used std::vector<Index> counts; // local index => how many locals we saw before this one, before a use of - // this one appeared. that is, one local has 0, another has 1, and so forth, - // in the order in which we saw the first uses of them. + // this one appeared. that is, one local has 1, another has 2, and so forth, + // in the order in which we saw the first uses of them (we use "0" to mark + // locals we have not yet seen). std::vector<Index> firstUses; - Index firstUseIndex = 0; + Index firstUseIndex = 1; - static const Index UNSEEN = -1; + enum { Unseen = 0 }; void doWalkFunction(Function* curr) { Index num = curr->getNumLocals(); counts.resize(num); std::fill(counts.begin(), counts.end(), 0); firstUses.resize(num); - std::fill(firstUses.begin(), firstUses.end(), UNSEEN); + std::fill(firstUses.begin(), firstUses.end(), Unseen); // Gather information about local usages. walk(curr->body); // Use the information about local usages. @@ -141,14 +142,14 @@ struct ReorderLocals : public WalkerPass<PostWalker<ReorderLocals>> { void visitLocalGet(LocalGet* curr) { counts[curr->index]++; - if (firstUses[curr->index] == UNSEEN) { + if (firstUses[curr->index] == Unseen) { firstUses[curr->index] = firstUseIndex++; } } void visitLocalSet(LocalSet* curr) { counts[curr->index]++; - if (firstUses[curr->index] == UNSEEN) { + if (firstUses[curr->index] == Unseen) { firstUses[curr->index] = firstUseIndex++; } } |