summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Bytecode/Pass/DumpCFG.cpp
blob: e40b1bff177fb79f92040c4fc301cef10a54cc2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/*
 * Copyright (c) 2021, Ali Mohammad Pur <mpfard@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#include <LibJS/Bytecode/PassManager.h>

namespace JS::Bytecode::Passes {

void DumpCFG::perform(PassPipelineExecutable& executable)
{
    started();

    VERIFY(executable.cfg.has_value());
    outln(m_file, "CFG Dump for {} basic blocks:", executable.executable.basic_blocks.size());
    for (auto& entry : executable.cfg.value()) {
        for (auto& value : entry.value)
            outln(m_file, "{} -> {}", entry.key->name(), value->name());
    }
    outln(m_file);

    finished();
}

}