6 #include <gtest/gtest.h>
12 #include <unordered_set>
19 const std::unordered_set<const jlm::llvm::ControlFlowGraphNode *> & children)
21 EXPECT_EQ(dnode->
node(), node);
23 for (
auto & child : *dnode)
24 EXPECT_NE(children.find(child->node()), children.end());
30 for (
const auto & child : *root)
32 if (child->node() == node)
36 throw std::logic_error(
"Node does not exist in dominator tree");
39 TEST(DominatorTreeTests, test)
54 bb1->add_outedge(bb2);
55 bb1->add_outedge(bb3);
56 bb2->add_outedge(bb3);
57 bb2->add_outedge(bb4);
58 bb3->add_outedge(bb4);
59 bb4->add_outedge(cfg.
exit());
64 check<1>(root.get(), cfg.
entry(), { bb1 });
66 auto dtbb1 = root->child(0);
67 check<3>(dtbb1, bb1, { bb2, bb3, bb4 });
70 check<0>(dtbb2, bb2, {});
73 check<0>(dtbb3, bb3, {});
76 check<1>(dtbb4, bb4, { cfg.
exit() });
78 auto dtexit = dtbb4->child(0);
79 check<0>(dtexit, cfg.
exit(), {});
static void check(const jlm::llvm::DominatorTreeNode *dnode, const jlm::llvm::ControlFlowGraphNode *node, const std::unordered_set< const jlm::llvm::ControlFlowGraphNode * > &children)
TEST(DominatorTreeTests, test)
static const jlm::llvm::DominatorTreeNode * get_child(const jlm::llvm::DominatorTreeNode *root, const jlm::llvm::ControlFlowGraphNode *node)
static BasicBlock * create(ControlFlowGraph &cfg)
void divert_inedges(llvm::ControlFlowGraphNode *new_successor)
EntryNode * entry() const noexcept
ExitNode * exit() const noexcept
ControlFlowGraphNode * node() const noexcept
size_t nchildren() const noexcept
Global memory state passed between functions.
std::unique_ptr< DominatorTreeNode > domtree(ControlFlowGraph &cfg)