diff options
author | Alon Zakai <azakai@google.com> | 2023-10-24 10:17:40 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-24 10:17:40 -0700 |
commit | cce277fc649d7406f446f52778286192367a35ad (patch) | |
tree | 1e3a931d38f44875fd29cf10bdfd4124f667d5d3 /src/ir/LocalGraph.cpp | |
parent | 2134d9a32b89b5b30121956bbfb070b8c9ee2bd5 (diff) | |
download | binaryen-cce277fc649d7406f446f52778286192367a35ad.tar.gz binaryen-cce277fc649d7406f446f52778286192367a35ad.tar.bz2 binaryen-cce277fc649d7406f446f52778286192367a35ad.zip |
[NFC] LocalGraph: Move definition to logical place (#6045)
allGets was declared in a scope that kept it alive for all blocks, and at
the end of the loop we clear the gets for a particular block. That's clumsy,
and makes a followup harder, so this PR moves it to the natural place for it.
(That is, it moves it to the scope that handles a particular block, and removes
the manual clearing-out of the get at the end of the loop iteration.) Optimizing
compilers are smart enough to be efficient about stack allocations
of objects inside loops anyhow (which I measured).
Helps #6042.
Diffstat (limited to 'src/ir/LocalGraph.cpp')
-rw-r--r-- | src/ir/LocalGraph.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/ir/LocalGraph.cpp b/src/ir/LocalGraph.cpp index af3a71d1f..9bdb6765f 100644 --- a/src/ir/LocalGraph.cpp +++ b/src/ir/LocalGraph.cpp @@ -104,8 +104,6 @@ struct Flower : public CFGWalker<Flower, Visitor<Flower>, Info> { }; auto numLocals = func->getNumLocals(); - std::vector<std::vector<LocalGet*>> allGets; - allGets.resize(numLocals); std::vector<FlowBlock*> work; // Convert input blocks (basicBlocks) into more efficient flow blocks to @@ -157,9 +155,14 @@ struct Flower : public CFGWalker<Flower, Visitor<Flower>, Info> { std::cout << " last set " << val.second << '\n'; } #endif + + // Track all gets in this block, by index. + std::vector<std::vector<LocalGet*>> allGets(numLocals); + // go through the block, finding each get and adding it to its index, // and seeing how sets affect that auto& actions = block.actions; + // move towards the front, handling things as we go for (int i = int(actions.size()) - 1; i >= 0; i--) { auto* action = actions[i]; @@ -222,7 +225,6 @@ struct Flower : public CFGWalker<Flower, Visitor<Flower>, Info> { } } } - gets.clear(); currentIteration++; } } |