Jlm
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>
13 #include <jlm/rvsdg/TestType.hpp>
14 
15 TEST(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
static std::unique_ptr< Argument > create(const std::string &name, std::shared_ptr< const jlm::rvsdg::Type > type, const AttributeSet &attributes)
Definition: cfg.hpp:59
static BasicBlock * create(ControlFlowGraph &cfg)
Definition: basic-block.cpp:37
void divert_inedges(llvm::ControlFlowGraphNode *new_successor)
Definition: cfg-node.hpp:171
static std::string ToAscii(const ControlFlowGraph &controlFlowGraph)
Definition: cfg.cpp:151
EntryNode * entry() const noexcept
Definition: cfg.hpp:206
ExitNode * exit() const noexcept
Definition: cfg.hpp:212
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::unique_ptr< llvm::ThreeAddressCode > create(const std::vector< std::pair< const Variable *, ControlFlowGraphNode * >> &arguments, std::shared_ptr< const jlm::rvsdg::Type > type)
Definition: operators.hpp:76
static std::shared_ptr< const TestType > createValueType()
Definition: TestType.cpp:67
Global memory state passed between functions.
bool is_valid(const ControlFlowGraph &cfg)