474 changes: 0 additions & 474 deletions llvm/include/llvm/Support/CfgTraits.h

This file was deleted.

597 changes: 347 additions & 250 deletions llvm/include/llvm/Support/GenericDomTree.h

Large diffs are not rendered by default.

25 changes: 9 additions & 16 deletions llvm/include/llvm/Support/GenericDomTreeConstruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ namespace DomTreeBuilder {

template <typename DomTreeT>
struct SemiNCAInfo {
using CfgTraits = typename DomTreeT::CfgTraits;
using NodePtr = typename DomTreeT::NodePtr;
using NodeT = typename DomTreeT::NodeType;
using TreeNodePtr = DomTreeNodeBase<NodeT> *;
Expand Down Expand Up @@ -138,7 +137,7 @@ struct SemiNCAInfo {
// immediate dominator.
NodePtr IDom = getIDom(BB);

assert(IDom || DT.DomTreeNodes[CfgBlockRef{}]);
assert(IDom || DT.DomTreeNodes[nullptr]);
TreeNodePtr IDomNode = getNodeForBlock(IDom, DT);

// Add a new tree node for this NodeT, and link it as a child of
Expand Down Expand Up @@ -594,7 +593,7 @@ struct SemiNCAInfo {
NodePtr Root = IsPostDom ? nullptr : DT.Roots[0];

DT.RootNode = DT.createNode(Root);
SNCA.attachNewSubtree(DT, DT.getRootNode());
SNCA.attachNewSubtree(DT, DT.RootNode);
}

void attachNewSubtree(DomTreeT& DT, const TreeNodePtr AttachTo) {
Expand All @@ -605,8 +604,7 @@ struct SemiNCAInfo {
NodePtr W = NumToNode[i];

// Don't replace this with 'count', the insertion side effect is important
if (DT.DomTreeNodes[CfgTraits::wrapRef(W)])
continue; // Haven't calculated this node yet?
if (DT.DomTreeNodes[W]) continue; // Haven't calculated this node yet?

NodePtr ImmDom = getIDom(W);

Expand Down Expand Up @@ -1144,7 +1142,7 @@ struct SemiNCAInfo {
std::swap(*ChIt, IDom->Children.back());
IDom->Children.pop_back();

DT.DomTreeNodes.erase(CfgTraits::wrapRef(TN->getBlock()));
DT.DomTreeNodes.erase(TN->getBlock());
}

//~~
Expand Down Expand Up @@ -1270,8 +1268,7 @@ struct SemiNCAInfo {
doFullDFSWalk(DT, AlwaysDescend);

for (auto &NodeToTN : DT.DomTreeNodes) {
const TreeNodePtr TN =
static_cast<const TreeNodePtr>(NodeToTN.second.get());
const TreeNodePtr TN = NodeToTN.second.get();
const NodePtr BB = TN->getBlock();

// Virtual root has a corresponding virtual CFG node.
Expand Down Expand Up @@ -1304,8 +1301,7 @@ struct SemiNCAInfo {
// Running time: O(N).
static bool VerifyLevels(const DomTreeT &DT) {
for (auto &NodeToTN : DT.DomTreeNodes) {
const TreeNodePtr TN =
static_cast<const TreeNodePtr>(NodeToTN.second.get());
const TreeNodePtr TN = NodeToTN.second.get();
const NodePtr BB = TN->getBlock();
if (!BB) continue;

Expand Down Expand Up @@ -1360,8 +1356,7 @@ struct SemiNCAInfo {
// For each tree node verify if children's DFS numbers cover their parent's
// DFS numbers with no gaps.
for (const auto &NodeToTN : DT.DomTreeNodes) {
const TreeNodePtr Node =
static_cast<const TreeNodePtr>(NodeToTN.second.get());
const TreeNodePtr Node = NodeToTN.second.get();

// Handle tree leaves.
if (Node->isLeaf()) {
Expand Down Expand Up @@ -1474,8 +1469,7 @@ struct SemiNCAInfo {
// the nodes it dominated previously will now become unreachable.
bool verifyParentProperty(const DomTreeT &DT) {
for (auto &NodeToTN : DT.DomTreeNodes) {
const TreeNodePtr TN =
static_cast<const TreeNodePtr>(NodeToTN.second.get());
const TreeNodePtr TN = NodeToTN.second.get();
const NodePtr BB = TN->getBlock();
if (!BB || TN->isLeaf())
continue;
Expand Down Expand Up @@ -1509,8 +1503,7 @@ struct SemiNCAInfo {
// siblings will now still be reachable.
bool verifySiblingProperty(const DomTreeT &DT) {
for (auto &NodeToTN : DT.DomTreeNodes) {
const TreeNodePtr TN =
static_cast<const TreeNodePtr>(NodeToTN.second.get());
const TreeNodePtr TN = NodeToTN.second.get();
const NodePtr BB = TN->getBlock();
if (!BB || TN->isLeaf())
continue;
Expand Down
1 change: 0 additions & 1 deletion llvm/lib/CodeGen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ add_llvm_component_library(LLVMCodeGen
MachineBlockFrequencyInfo.cpp
MachineBlockPlacement.cpp
MachineBranchProbabilityInfo.cpp
MachineCfgTraits.cpp
MachineCombiner.cpp
MachineCopyPropagation.cpp
MachineCSE.cpp
Expand Down
30 changes: 0 additions & 30 deletions llvm/lib/CodeGen/MachineCfgTraits.cpp

This file was deleted.

56 changes: 0 additions & 56 deletions llvm/lib/IR/CFG.cpp

This file was deleted.

1 change: 0 additions & 1 deletion llvm/lib/IR/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ add_llvm_component_library(LLVMCore
Attributes.cpp
AutoUpgrade.cpp
BasicBlock.cpp
CFG.cpp
Comdat.cpp
ConstantFold.cpp
ConstantRange.cpp
Expand Down
2 changes: 0 additions & 2 deletions llvm/lib/Support/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ add_llvm_component_library(LLVMSupport
BranchProbability.cpp
BuryPointer.cpp
CachePruning.cpp
CfgTraits.cpp
circular_raw_ostream.cpp
Chrono.cpp
COM.cpp
Expand Down Expand Up @@ -125,7 +124,6 @@ add_llvm_component_library(LLVMSupport
FoldingSet.cpp
FormattedStream.cpp
FormatVariadic.cpp
GenericDomTree.cpp
GlobPattern.cpp
GraphWriter.cpp
Hashing.cpp
Expand Down
14 changes: 0 additions & 14 deletions llvm/lib/Support/CfgTraits.cpp

This file was deleted.

278 changes: 0 additions & 278 deletions llvm/lib/Support/GenericDomTree.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Scalar/ADCE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ void AggressiveDeadCodeElimination::initialize() {
// return of the function.
// We do this by seeing which of the postdomtree root children exit the
// program, and for all others, mark the subtree live.
for (auto *PDTChild : children<DomTreeNode *>(PDT.getRootNode())) {
for (auto &PDTChild : children<DomTreeNode *>(PDT.getRootNode())) {
auto *BB = PDTChild->getBlock();
auto &Info = BlockInfo[BB];
// Real function return
Expand Down
8 changes: 3 additions & 5 deletions llvm/lib/Transforms/Scalar/NewGVN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ class NewGVN {
unsigned int NumFuncArgs = 0;

// RPOOrdering of basic blocks
DenseMap<const GenericDomTreeNodeBase *, unsigned> RPOOrdering;
DenseMap<const DomTreeNode *, unsigned> RPOOrdering;

// Congruence class info.

Expand Down Expand Up @@ -3388,10 +3388,8 @@ bool NewGVN::runGVN() {
for (auto &B : RPOT) {
auto *Node = DT->getNode(B);
if (Node->getNumChildren() > 1)
llvm::sort(Node->GenericDomTreeNodeBase::begin(),
Node->GenericDomTreeNodeBase::end(),
[&](const GenericDomTreeNodeBase *A,
const GenericDomTreeNodeBase *B) {
llvm::sort(Node->begin(), Node->end(),
[&](const DomTreeNode *A, const DomTreeNode *B) {
return RPOOrdering[A] < RPOOrdering[B];
});
}
Expand Down
33 changes: 0 additions & 33 deletions llvm/lib/Transforms/Vectorize/VPlanDominatorTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,42 +18,9 @@
#include "VPlan.h"
#include "llvm/ADT/GraphTraits.h"
#include "llvm/IR/Dominators.h"
#include "llvm/Support/CfgTraits.h"

namespace llvm {

/// Partial CFG traits for VPlan's CFG, without a value type.
class VPCfgTraitsBase : public CfgTraitsBase {
public:
using ParentType = VPRegionBlock;
using BlockRef = VPBlockBase *;
using ValueRef = void;

static CfgBlockRef wrapRef(BlockRef block) {
return makeOpaque<CfgBlockRefTag>(block);
}
static BlockRef unwrapRef(CfgBlockRef block) {
return static_cast<BlockRef>(getOpaque(block));
}
};

class VPCfgTraits : public CfgTraits<VPCfgTraitsBase, VPCfgTraits> {
public:
static VPRegionBlock *getBlockParent(VPBlockBase *block) {
return block->getParent();
}

static auto predecessors(VPBlockBase *block) {
return llvm::inverse_children<VPBlockBase *>(block);
}

static auto successors(VPBlockBase *block) {
return llvm::children<VPBlockBase *>(block);
}
};

template <> struct CfgTraitsFor<VPBlockBase> { using CfgTraits = VPCfgTraits; };

/// Template specialization of the standard LLVM dominator tree utility for
/// VPBlockBases.
using VPDominatorTree = DomTreeBase<VPBlockBase>;
Expand Down
39 changes: 0 additions & 39 deletions mlir/include/mlir/IR/Dominance.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,47 +10,8 @@
#define MLIR_IR_DOMINANCE_H

#include "mlir/IR/RegionGraphTraits.h"
#include "llvm/Support/CfgTraits.h"
#include "llvm/Support/GenericDomTree.h"

namespace mlir {

/// Partial CFG traits for MLIR's CFG, without a value type.
class CfgTraitsBase : public llvm::CfgTraitsBase {
public:
using ParentType = Region;
using BlockRef = Block *;
using ValueRef = void;

static llvm::CfgBlockRef wrapRef(BlockRef block) {
return makeOpaque<llvm::CfgBlockRefTag>(block);
}
static BlockRef unwrapRef(llvm::CfgBlockRef block) {
return static_cast<BlockRef>(getOpaque(block));
}
};

class CfgTraits : public llvm::CfgTraits<CfgTraitsBase, CfgTraits> {
public:
static Region *getBlockParent(Block *block) { return block->getParent(); }

static auto predecessors(Block *block) {
return llvm::inverse_children<Block *>(block);
}

static auto successors(Block *block) {
return llvm::children<Block *>(block);
}
};

} // namespace mlir

namespace llvm {
template <> struct CfgTraitsFor<mlir::Block> {
using CfgTraits = mlir::CfgTraits;
};
} // namespace llvm

extern template class llvm::DominatorTreeBase<mlir::Block, false>;
extern template class llvm::DominatorTreeBase<mlir::Block, true>;

Expand Down