Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/Analysis/PostDominators.cpp
Line
Count
Source (jump to first uncovered line)
1
//===- PostDominators.cpp - Post-Dominator Calculation --------------------===//
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
// This file implements the post-dominator construction algorithms.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#include "llvm/Analysis/PostDominators.h"
14
#include "llvm/IR/Function.h"
15
#include "llvm/IR/PassManager.h"
16
#include "llvm/Pass.h"
17
#include "llvm/Support/raw_ostream.h"
18
19
using namespace llvm;
20
21
#define DEBUG_TYPE "postdomtree"
22
23
#ifdef EXPENSIVE_CHECKS
24
static constexpr bool ExpensiveChecksEnabled = true;
25
#else
26
static constexpr bool ExpensiveChecksEnabled = false;
27
#endif
28
29
//===----------------------------------------------------------------------===//
30
//  PostDominatorTree Implementation
31
//===----------------------------------------------------------------------===//
32
33
char PostDominatorTreeWrapperPass::ID = 0;
34
35
INITIALIZE_PASS(PostDominatorTreeWrapperPass, "postdomtree",
36
                "Post-Dominator Tree Construction", true, true)
37
38
bool PostDominatorTree::invalidate(Function &F, const PreservedAnalyses &PA,
39
952
                                   FunctionAnalysisManager::Invalidator &) {
40
952
  // Check whether the analysis, all analyses on functions, or the function's
41
952
  // CFG have been preserved.
42
952
  auto PAC = PA.getChecker<PostDominatorTreeAnalysis>();
43
952
  return !(PAC.preserved() || 
PAC.preservedSet<AllAnalysesOn<Function>>()947
||
44
952
           
PAC.preservedSet<CFGAnalyses>()947
);
45
952
}
46
47
603k
bool PostDominatorTreeWrapperPass::runOnFunction(Function &F) {
48
603k
  DT.recalculate(F);
49
603k
  return false;
50
603k
}
51
52
0
void PostDominatorTreeWrapperPass::verifyAnalysis() const {
53
0
  if (VerifyDomInfo)
54
0
    assert(DT.verify(PostDominatorTree::VerificationLevel::Full));
55
0
  else if (ExpensiveChecksEnabled)
56
0
    assert(DT.verify(PostDominatorTree::VerificationLevel::Basic));
57
0
}
58
59
9
void PostDominatorTreeWrapperPass::print(raw_ostream &OS, const Module *) const {
60
9
  DT.print(OS);
61
9
}
62
63
0
FunctionPass* llvm::createPostDomTree() {
64
0
  return new PostDominatorTreeWrapperPass();
65
0
}
66
67
AnalysisKey PostDominatorTreeAnalysis::Key;
68
69
PostDominatorTree PostDominatorTreeAnalysis::run(Function &F,
70
1.25k
                                                 FunctionAnalysisManager &) {
71
1.25k
  PostDominatorTree PDT(F);
72
1.25k
  return PDT;
73
1.25k
}
74
75
PostDominatorTreePrinterPass::PostDominatorTreePrinterPass(raw_ostream &OS)
76
5
  : OS(OS) {}
77
78
PreservedAnalyses
79
5
PostDominatorTreePrinterPass::run(Function &F, FunctionAnalysisManager &AM) {
80
5
  OS << "PostDominatorTree for function: " << F.getName() << "\n";
81
5
  AM.getResult<PostDominatorTreeAnalysis>(F).print(OS);
82
5
83
5
  return PreservedAnalyses::all();
84
5
}