summaryrefslogtreecommitdiff
path: root/src/passes/Outlining.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [Outlining] Sort sequences by order appeared in function (#7164)Ashley Nelson2024-12-191-5/+14
| | | | | | | | | | | During function reconstruction, a walker iterates thru each instruction of a function, incrementing a counter to find matching sequences. As a result, the sequences of a function must be sorted by smallest start index, otherwise reconstruction will miss outlining a repeat sequence. I considered making a test for this commit, but the sort wasn't needed until the tests started running on GitHub infra. I'm not sure what specific architecture is causing the discrepancy in vector ordering, but let's introduce the sort to be safe.
* [NFC] Finalize blocks with explicit breakability in IRBuilder (#7085)Thomas Lively2024-11-181-0/+8
| | | | | | Since IRBuilder already knows what labels are used by branches, it is easy for it to pass that information when finalizing blocks. This avoids finalization having to walk the blocks looking for branches, speeding up a future version of the binary parser that uses IRBuilder by 10%.
* Reset function context when ending a function in IRBuilder (#7081)Thomas Lively2024-11-151-6/+12
| | | | | | | | | | | | | | | | | | | IRBuilder contains a pointer to the current function that is used to create scratch locals, look up the operand types for returns, etc. This pointer is nullable because IRBuilder can also be used in non-function contexts such as global initializers. Visiting the start of a function sets the function pointer, and after this change visiting the end of a function resets the pointer to null. This avoids potential problems where code outside a function would be able to incorrectly use scratch locals and returns if the IRBuilder had previously been used to build a function. This change requires some adjustments to Outlining, which visits code out of order, so ends up visiting code from inside a function after visiting the end of the function. To support this use case, add a `setFunction` method to IRBuilder that lets the user explicitly control its function context. Also remove the optional function pointer parameter to the IRBuilder constructor since it is less flexible and not used.
* [Outlining] Fixes break reconstruction (#6352)Ashley Nelson2024-02-271-1/+13
| | | Adds new visitBreakWithType and visitSwitchWithType functions to the IRBuilder API. These functions work around an assumption in IRBuilder that the module is being traversed in the fully nested format, i.e., that the destination scope of a break or switch has been visited before visiting the break or switch. Instead, the type of the destination scope is passed to IRBuilder.
* [Outlining] Add loop instruction supportAshley Nelson2023-12-071-0/+3
| | | | | | | | | | Adds support for the loop instruction to be outlined and a test showing a repeat loop being outlined. Reviewers: tlively Reviewed By: tlively Pull Request: https://github.com/WebAssembly/binaryen/pull/6141
* [Outlining] Improve debug loggingAshley Nelson2023-12-071-20/+22
| | | | | | | | | | | | - Change outlining debug logs to use std::cerr - Add controlFlowQueue push log - Fix build error with wasm-ir-builder log's use of ShallowExpression Reviewers: tlively Reviewed By: tlively Pull Request: https://github.com/WebAssembly/binaryen/pull/6140
* [Outlining] Fix outlining control flowAshley Nelson2023-12-061-0/+12
| | | | | | | | | | Changes the controlFlowQueue used in stringify-walker to push values of Expression*, This ensures that we walk the Wasm module in the same order, regardless of whether the control flow expression is outlined. Reviewers: tlively Reviewed By: tlively Pull Request: https://github.com/WebAssembly/binaryen/pull/6139
* Update IRBuilder to visit control flow correctly (#6124)Thomas Lively2023-11-161-0/+5
| | | | | | | | | | | Besides If, no control flow structure consumes values from the stack. Fix a bug in IRBuilder that was causing it to pop control flow children. Also fix a follow on bug in outlining where it did not make the If condition available on the stack when starting to visit an If. This required making push() part of the public API of IRBuilder. As a drive-by, also add helpful debug logging to IRBuilder. Co-authored-by: Ashley Nelson <nashley@google.com>
* [Outlining] Adding more tests (#6117)Ashley Nelson2023-11-151-9/+43
| | | | | | Checking a couple of testing TODOs off and adding more tests of the outlining pass for outlining: - a sequence at the beginning of an existing function - a sequence that is outlined into a function that takes no arguments - multiple sequences from the same source function into different outlined functions
* [Outlining] Adds Outlining pass (#6110)Ashley Nelson2023-11-131-0/+329
Adds an outlining pass that performs outlining on a module end to end, and two tests.