Jlm
Loading...
Searching...
No Matches
CfgPurgeTests.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2021 Nico Reißmann <nico.reissmann@gmail.com>
3 * See COPYING for terms of redistribution.
4 */
5
6#include <gtest/gtest.h>
7
11#include <jlm/llvm/ir/print.hpp>
12
13TEST(ControLFlowGraphPurgeTests, test)
14{
15 using namespace jlm::llvm;
16
18
19 ControlFlowGraph cfg(module);
20 auto bb0 = BasicBlock::create(cfg);
21 auto bb1 = BasicBlock::create(cfg);
22
23 auto op = std::make_unique<jlm::rvsdg::ControlConstantOperation>(
25 bb0->append_last(ThreeAddressCode::create(std::move(op), {}));
26 bb0->append_last(BranchOperation::create(2, bb0->last()->result(0)));
27
28 cfg.exit()->divert_inedges(bb0);
29 bb0->add_outedge(bb1);
30 bb0->add_outedge(cfg.exit());
31 bb1->add_outedge(bb1);
32
33 std::cout << ControlFlowGraph::ToAscii(cfg) << std::flush;
34
35 purge(cfg);
36
37 EXPECT_EQ(cfg.nnodes(), 2u);
38}
TEST(ControLFlowGraphPurgeTests, test)
void divert_inedges(llvm::ControlFlowGraphNode *new_successor)
Definition cfg-node.hpp:171
ExitNode * exit() const noexcept
Definition cfg.hpp:212
size_t nnodes() const noexcept
Definition cfg.hpp:241
Global memory state passed between functions.