diff --git a/bolt/include/bolt/Core/BinaryLoop.h b/bolt/include/bolt/Core/BinaryDomTree.h copy from bolt/include/bolt/Core/BinaryLoop.h copy to bolt/include/bolt/Core/BinaryDomTree.h --- a/bolt/include/bolt/Core/BinaryLoop.h +++ b/bolt/include/bolt/Core/BinaryDomTree.h @@ -1,4 +1,4 @@ -//===- bolt/Core/BinaryLoop.h - Loop info at low-level IR -------*- C++ -*-===// +//==- bolt/Core/BinaryDomTree.h - Dominator Tree at low-level IR -*- C++ -*-==// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,63 +6,24 @@ // //===----------------------------------------------------------------------===// // -// This file defines the BinaryLoop class, which represents a loop in the -// CFG of a binary function, and the BinaryLoopInfo class, which stores -// information about all the loops of a binary function. +// This file defines the BinaryDomTree class, which represents a dominator tree +// in the CFG of a binary function. // //===----------------------------------------------------------------------===// -#ifndef BOLT_CORE_BINARY_LOOP_H -#define BOLT_CORE_BINARY_LOOP_H +#ifndef BOLT_CORE_BINARY_DOMTREE_H +#define BOLT_CORE_BINARY_DOMTREE_H -#include "llvm/ADT/DepthFirstIterator.h" -#include "llvm/Analysis/LoopInfoImpl.h" #include "llvm/Support/GenericDomTreeConstruction.h" namespace llvm { namespace bolt { class BinaryBasicBlock; - using BinaryDomTreeNode = DomTreeNodeBase; using BinaryDominatorTree = DomTreeBase; -class BinaryLoop : public LoopBase { -public: - BinaryLoop() : LoopBase() {} - - // The total count of all the back edges of this loop. - uint64_t TotalBackEdgeCount{0}; - - // The times the loop is entered from outside. - uint64_t EntryCount{0}; - - // The times the loop is exited. - uint64_t ExitCount{0}; - - // Most of the public interface is provided by LoopBase. - -protected: - friend class LoopInfoBase; - explicit BinaryLoop(BinaryBasicBlock *BB) - : LoopBase(BB) {} -}; - -class BinaryLoopInfo : public LoopInfoBase { -public: - BinaryLoopInfo() {} - - unsigned OuterLoops{0}; - unsigned TotalLoops{0}; - unsigned MaximumDepth{0}; - - // Most of the public interface is provided by LoopInfoBase. -}; - } // namespace bolt -} // namespace llvm - -namespace llvm { // BinaryDominatorTree GraphTraits specializations. template <> diff --git a/bolt/include/bolt/Core/BinaryLoop.h b/bolt/include/bolt/Core/BinaryLoop.h --- a/bolt/include/bolt/Core/BinaryLoop.h +++ b/bolt/include/bolt/Core/BinaryLoop.h @@ -15,18 +15,13 @@ #ifndef BOLT_CORE_BINARY_LOOP_H #define BOLT_CORE_BINARY_LOOP_H -#include "llvm/ADT/DepthFirstIterator.h" #include "llvm/Analysis/LoopInfoImpl.h" -#include "llvm/Support/GenericDomTreeConstruction.h" namespace llvm { namespace bolt { class BinaryBasicBlock; -using BinaryDomTreeNode = DomTreeNodeBase; -using BinaryDominatorTree = DomTreeBase; - class BinaryLoop : public LoopBase { public: BinaryLoop() : LoopBase() {} @@ -62,35 +57,4 @@ } // namespace bolt } // namespace llvm -namespace llvm { - -// BinaryDominatorTree GraphTraits specializations. -template <> -struct GraphTraits - : public DomTreeGraphTraitsBase {}; - -template <> -struct GraphTraits - : public DomTreeGraphTraitsBase {}; - -template <> -struct GraphTraits - : public GraphTraits { - static NodeRef getEntryNode(bolt::BinaryDominatorTree *DT) { - return DT->getRootNode(); - } - - static nodes_iterator nodes_begin(bolt::BinaryDominatorTree *N) { - return df_begin(getEntryNode(N)); - } - - static nodes_iterator nodes_end(bolt::BinaryDominatorTree *N) { - return df_end(getEntryNode(N)); - } -}; - -} // namespace llvm - #endif diff --git a/bolt/lib/Core/BinaryFunction.cpp b/bolt/lib/Core/BinaryFunction.cpp --- a/bolt/lib/Core/BinaryFunction.cpp +++ b/bolt/lib/Core/BinaryFunction.cpp @@ -12,6 +12,7 @@ #include "bolt/Core/BinaryFunction.h" #include "bolt/Core/BinaryBasicBlock.h" +#include "bolt/Core/BinaryDomTree.h" #include "bolt/Core/DynoStats.h" #include "bolt/Core/MCPlusBuilder.h" #include "bolt/Utils/NameResolver.h"