diff options
author | Alon Zakai <alonzakai@gmail.com> | 2015-12-11 18:09:39 -0500 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2015-12-11 18:09:39 -0500 |
commit | 927242bc9be3c5aaace97fd01de9eb44f6c71abd (patch) | |
tree | 5641bdef0fbb6bb17b8217298c75cd9280cfc647 /src/s2wasm.h | |
parent | 7fbb349bde8ede4542b81b14cea52dcc3e93a02d (diff) | |
download | binaryen-927242bc9be3c5aaace97fd01de9eb44f6c71abd.tar.gz binaryen-927242bc9be3c5aaace97fd01de9eb44f6c71abd.tar.bz2 binaryen-927242bc9be3c5aaace97fd01de9eb44f6c71abd.zip |
fix out label in loop in s2wasm
Diffstat (limited to 'src/s2wasm.h')
-rw-r--r-- | src/s2wasm.h | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/s2wasm.h b/src/s2wasm.h index a04ab65bd..9766471f7 100644 --- a/src/s2wasm.h +++ b/src/s2wasm.h @@ -279,6 +279,7 @@ private: typedef std::pair<Const*, Name> Addressing; std::vector<Addressing> addressings; std::vector<Block*> loopBlocks; // we need to clear their names + std::set<Name> seenLabels; // if we already used a label, we don't need it in a loop (there is a block above it, with that label) // main loop while (1) { skipWhitespace(); @@ -354,6 +355,7 @@ private: curr->name = getStr(); bstack.back()->list.push_back(curr); bstack.push_back(curr); + seenLabels.insert(curr->name); } else if (match("BB")) { s -= 2; Name name = getStrToColon(); @@ -373,11 +375,14 @@ private: if (*s == 'l') { auto curr = allocator.alloc<Loop>(); bstack.back()->list.push_back(curr); - curr->out = name; + curr->in = name; mustMatch("loop"); - curr->in = getStr(); + Name out = getStr(); + if (seenLabels.count(out) == 0) { + curr->out = out; + } auto block = allocator.alloc<Block>(); - block->name = curr->in; // temporary, fake + block->name = out; // temporary, fake curr->body = block; loopBlocks.push_back(block); bstack.push_back(block); |