Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/Analysis/IteratedDominanceFrontier.h
Line
Count
Source
1
//===- IteratedDominanceFrontier.h - Calculate IDF --------------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#ifndef LLVM_ANALYSIS_IDF_H
10
#define LLVM_ANALYSIS_IDF_H
11
12
#include "llvm/IR/CFGDiff.h"
13
#include "llvm/Support/GenericIteratedDominanceFrontier.h"
14
15
namespace llvm {
16
17
class BasicBlock;
18
19
namespace IDFCalculatorDetail {
20
21
/// Specialization for BasicBlock for the optional use of GraphDiff.
22
template <bool IsPostDom> struct ChildrenGetterTy<BasicBlock, IsPostDom> {
23
  using NodeRef = BasicBlock *;
24
  using ChildrenTy = SmallVector<BasicBlock *, 8>;
25
26
1.16M
  ChildrenGetterTy() = default;
llvm::IDFCalculatorDetail::ChildrenGetterTy<llvm::BasicBlock, false>::ChildrenGetterTy()
Line
Count
Source
26
1.00M
  ChildrenGetterTy() = default;
llvm::IDFCalculatorDetail::ChildrenGetterTy<llvm::BasicBlock, true>::ChildrenGetterTy()
Line
Count
Source
26
161k
  ChildrenGetterTy() = default;
27
115
  ChildrenGetterTy(const GraphDiff<BasicBlock *, IsPostDom> *GD) : GD(GD) {
28
115
    assert(GD);
29
115
  }
30
31
  ChildrenTy get(const NodeRef &N);
32
33
  const GraphDiff<BasicBlock *, IsPostDom> *GD = nullptr;
34
};
35
36
} // end of namespace IDFCalculatorDetail
37
38
template <bool IsPostDom>
39
class IDFCalculator final : public IDFCalculatorBase<BasicBlock, IsPostDom> {
40
public:
41
  using IDFCalculatorBase =
42
      typename llvm::IDFCalculatorBase<BasicBlock, IsPostDom>;
43
  using ChildrenGetterTy = typename IDFCalculatorBase::ChildrenGetterTy;
44
45
  IDFCalculator(DominatorTreeBase<BasicBlock, IsPostDom> &DT)
46
1.16M
      : IDFCalculatorBase(DT) {}
llvm::IDFCalculator<false>::IDFCalculator(llvm::DominatorTreeBase<llvm::BasicBlock, false>&)
Line
Count
Source
46
1.00M
      : IDFCalculatorBase(DT) {}
llvm::IDFCalculator<true>::IDFCalculator(llvm::DominatorTreeBase<llvm::BasicBlock, true>&)
Line
Count
Source
46
161k
      : IDFCalculatorBase(DT) {}
47
48
  IDFCalculator(DominatorTreeBase<BasicBlock, IsPostDom> &DT,
49
                const GraphDiff<BasicBlock *, IsPostDom> *GD)
50
115
      : IDFCalculatorBase(DT, ChildrenGetterTy(GD)) {
51
115
    assert(GD);
52
115
  }
53
};
54
55
using ForwardIDFCalculator = IDFCalculator<false>;
56
using ReverseIDFCalculator = IDFCalculator<true>;
57
58
//===----------------------------------------------------------------------===//
59
// Implementation.
60
//===----------------------------------------------------------------------===//
61
62
namespace IDFCalculatorDetail {
63
64
template <bool IsPostDom>
65
typename ChildrenGetterTy<BasicBlock, IsPostDom>::ChildrenTy
66
8.97M
ChildrenGetterTy<BasicBlock, IsPostDom>::get(const NodeRef &N) {
67
8.97M
68
8.97M
  using OrderedNodeTy =
69
8.97M
      typename IDFCalculatorBase<BasicBlock, IsPostDom>::OrderedNodeTy;
70
8.97M
71
8.97M
  if (!GD) {
72
8.96M
    auto Children = children<OrderedNodeTy>(N);
73
8.96M
    return {Children.begin(), Children.end()};
74
8.96M
  }
75
495
76
495
  using SnapShotBBPairTy =
77
495
      std::pair<const GraphDiff<BasicBlock *, IsPostDom> *, OrderedNodeTy>;
78
495
79
495
  ChildrenTy Ret;
80
495
  for (const auto &SnapShotBBPair : children<SnapShotBBPairTy>({GD, N}))
81
520
    Ret.emplace_back(SnapShotBBPair.second);
82
495
  return Ret;
83
495
}
llvm::IDFCalculatorDetail::ChildrenGetterTy<llvm::BasicBlock, false>::get(llvm::BasicBlock* const&)
Line
Count
Source
66
6.62M
ChildrenGetterTy<BasicBlock, IsPostDom>::get(const NodeRef &N) {
67
6.62M
68
6.62M
  using OrderedNodeTy =
69
6.62M
      typename IDFCalculatorBase<BasicBlock, IsPostDom>::OrderedNodeTy;
70
6.62M
71
6.62M
  if (!GD) {
72
6.62M
    auto Children = children<OrderedNodeTy>(N);
73
6.62M
    return {Children.begin(), Children.end()};
74
6.62M
  }
75
495
76
495
  using SnapShotBBPairTy =
77
495
      std::pair<const GraphDiff<BasicBlock *, IsPostDom> *, OrderedNodeTy>;
78
495
79
495
  ChildrenTy Ret;
80
495
  for (const auto &SnapShotBBPair : children<SnapShotBBPairTy>({GD, N}))
81
520
    Ret.emplace_back(SnapShotBBPair.second);
82
495
  return Ret;
83
495
}
llvm::IDFCalculatorDetail::ChildrenGetterTy<llvm::BasicBlock, true>::get(llvm::BasicBlock* const&)
Line
Count
Source
66
2.34M
ChildrenGetterTy<BasicBlock, IsPostDom>::get(const NodeRef &N) {
67
2.34M
68
2.34M
  using OrderedNodeTy =
69
2.34M
      typename IDFCalculatorBase<BasicBlock, IsPostDom>::OrderedNodeTy;
70
2.34M
71
2.34M
  if (!GD) {
72
2.34M
    auto Children = children<OrderedNodeTy>(N);
73
2.34M
    return {Children.begin(), Children.end()};
74
2.34M
  }
75
0
76
0
  using SnapShotBBPairTy =
77
0
      std::pair<const GraphDiff<BasicBlock *, IsPostDom> *, OrderedNodeTy>;
78
0
79
0
  ChildrenTy Ret;
80
0
  for (const auto &SnapShotBBPair : children<SnapShotBBPairTy>({GD, N}))
81
0
    Ret.emplace_back(SnapShotBBPair.second);
82
0
  return Ret;
83
0
}
84
85
} // end of namespace IDFCalculatorDetail
86
87
} // end of namespace llvm
88
89
#endif