Commit c1287aeb authored by Manos Koukoutos's avatar Manos Koukoutos Committed by V8 LUCI CQ

[wasm] Do not unroll unreachable loops

Bug: v8:11298, v8:13292
Change-Id: Ifabcbb64889012778439fb14e22a7cf885965b1e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3905724
Commit-Queue: Manos Koukoutos <manoskouk@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#83363}
parent b588a3c6
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "src/codegen/reloc-info.h" #include "src/codegen/reloc-info.h"
#include "src/common/high-allocation-throughput-scope.h" #include "src/common/high-allocation-throughput-scope.h"
#include "src/compiler/add-type-assertions-reducer.h" #include "src/compiler/add-type-assertions-reducer.h"
#include "src/compiler/all-nodes.h"
#include "src/compiler/backend/code-generator.h" #include "src/compiler/backend/code-generator.h"
#include "src/compiler/backend/frame-elider.h" #include "src/compiler/backend/frame-elider.h"
#include "src/compiler/backend/instruction-selector.h" #include "src/compiler/backend/instruction-selector.h"
...@@ -1699,8 +1700,11 @@ struct WasmLoopUnrollingPhase { ...@@ -1699,8 +1700,11 @@ struct WasmLoopUnrollingPhase {
void Run(PipelineData* data, Zone* temp_zone, void Run(PipelineData* data, Zone* temp_zone,
std::vector<compiler::WasmLoopInfo>* loop_infos) { std::vector<compiler::WasmLoopInfo>* loop_infos) {
if (loop_infos->empty()) return;
AllNodes all_nodes(temp_zone, data->graph(), data->graph()->end());
for (WasmLoopInfo& loop_info : *loop_infos) { for (WasmLoopInfo& loop_info : *loop_infos) {
if (loop_info.can_be_innermost) { if (!loop_info.can_be_innermost) continue;
if (!all_nodes.IsReachable(loop_info.header)) continue;
ZoneUnorderedSet<Node*>* loop = ZoneUnorderedSet<Node*>* loop =
LoopFinder::FindSmallInnermostLoopFromHeader( LoopFinder::FindSmallInnermostLoopFromHeader(
loop_info.header, temp_zone, loop_info.header, temp_zone,
...@@ -1708,10 +1712,9 @@ struct WasmLoopUnrollingPhase { ...@@ -1708,10 +1712,9 @@ struct WasmLoopUnrollingPhase {
// size for its depth. // size for its depth.
maximum_unrollable_size(loop_info.nesting_depth), true); maximum_unrollable_size(loop_info.nesting_depth), true);
if (loop == nullptr) continue; if (loop == nullptr) continue;
UnrollLoop(loop_info.header, loop, loop_info.nesting_depth, UnrollLoop(loop_info.header, loop, loop_info.nesting_depth, data->graph(),
data->graph(), data->common(), temp_zone, data->common(), temp_zone, data->source_positions(),
data->source_positions(), data->node_origins()); data->node_origins());
}
} }
EliminateLoopExits(loop_infos); EliminateLoopExits(loop_infos);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment