Jlm
Loading...
Searching...
No Matches
CfgValidityTests.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2020 Nico Reißmann <nico.reissmann@gmail.com>
3 * See COPYING for terms of redistribution.
4 */
5
6#include <gtest/gtest.h>
7
9#include <jlm/llvm/ir/cfg.hpp>
12#include <jlm/llvm/ir/print.hpp>
14
15TEST(ControlFlowGraphValidityTests, test_single_operand_phi)
16{
17 using namespace jlm::llvm;
18
20
22
23 ControlFlowGraph cfg(im);
24 auto arg = cfg.entry()->append_argument(Argument::create("arg", vt));
25
26 auto bb0 = BasicBlock::create(cfg);
27 bb0->append_first(SsaPhiOperation::create({ { arg, cfg.entry() } }, vt));
28
29 cfg.exit()->divert_inedges(bb0);
30 bb0->add_outedge(cfg.exit());
31 cfg.exit()->append_result(bb0->last()->result(0));
32
33 std::cout << ControlFlowGraph::ToAscii(cfg) << std::flush;
34
35 EXPECT_TRUE(is_valid(cfg));
36}
TEST(ControlFlowGraphValidityTests, test_single_operand_phi)
static const auto vt
Definition PullTests.cpp:16
void divert_inedges(llvm::ControlFlowGraphNode *new_successor)
Definition cfg-node.hpp:171
ExitNode * exit() const noexcept
Definition cfg.hpp:212
EntryNode * entry() const noexcept
Definition cfg.hpp:206
llvm::Argument * append_argument(std::unique_ptr< llvm::Argument > arg)
Definition cfg.hpp:100
void append_result(const Variable *v)
Definition cfg.hpp:143
static std::shared_ptr< const TestType > createValueType()
Definition TestType.cpp:67
Global memory state passed between functions.