Jlm
jlm
llvm
ir
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
8
#include <
jlm/llvm/ir/cfg-structure.hpp
>
9
#include <
jlm/llvm/ir/cfg.hpp
>
10
#include <
jlm/llvm/ir/ipgraph-module.hpp
>
11
#include <
jlm/llvm/ir/operators/operators.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
19
auto
vt
=
jlm::rvsdg::TestType::createValueType
();
20
21
InterProceduralGraphModule
im(
jlm::util::FilePath
(
""
),
""
,
""
);
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
TEST(ControlFlowGraphValidityTests, test_single_operand_phi)
Definition:
CfgValidityTests.cpp:15
vt
static const auto vt
Definition:
PullTests.cpp:16
TestType.hpp
cfg-structure.hpp
cfg.hpp
jlm::llvm::Argument::create
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
jlm::llvm::BasicBlock::create
static BasicBlock * create(ControlFlowGraph &cfg)
Definition:
basic-block.cpp:37
jlm::llvm::ControlFlowGraphNode::divert_inedges
void divert_inedges(llvm::ControlFlowGraphNode *new_successor)
Definition:
cfg-node.hpp:171
jlm::llvm::ControlFlowGraph
Definition:
cfg.hpp:159
jlm::llvm::ControlFlowGraph::ToAscii
static std::string ToAscii(const ControlFlowGraph &controlFlowGraph)
Definition:
cfg.cpp:151
jlm::llvm::ControlFlowGraph::entry
EntryNode * entry() const noexcept
Definition:
cfg.hpp:206
jlm::llvm::ControlFlowGraph::exit
ExitNode * exit() const noexcept
Definition:
cfg.hpp:212
jlm::llvm::EntryNode::append_argument
llvm::Argument * append_argument(std::unique_ptr< llvm::Argument > arg)
Definition:
cfg.hpp:100
jlm::llvm::ExitNode::append_result
void append_result(const Variable *v)
Definition:
cfg.hpp:143
jlm::llvm::InterProceduralGraphModule
Definition:
ipgraph-module.hpp:55
jlm::llvm::SsaPhiOperation::create
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
jlm::rvsdg::TestType::createValueType
static std::shared_ptr< const TestType > createValueType()
Definition:
TestType.cpp:67
jlm::util::FilePath
Definition:
file.hpp:19
ipgraph-module.hpp
jlm::llvm
Global memory state passed between functions.
Definition:
IpGraphToLlvmConverter.cpp:36
jlm::llvm::is_valid
bool is_valid(const ControlFlowGraph &cfg)
Definition:
cfg-structure.cpp:547
operators.hpp
print.hpp
Generated by
1.9.1