Coverage Report

Created: 2018-08-14 02:14

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/polly/lib/Transform/Canonicalization.cpp
Line
Count
Source (jump to first uncovered line)
1
//===---- Canonicalization.cpp - Run canonicalization passes --------------===//
2
//
3
//                     The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
//
10
// Run the set of default canonicalization passes.
11
//
12
// This pass is mainly used for debugging.
13
//
14
//===----------------------------------------------------------------------===//
15
16
#include "polly/Canonicalization.h"
17
#include "polly/LinkAllPasses.h"
18
#include "polly/Options.h"
19
#include "llvm/Transforms/IPO.h"
20
#include "llvm/Transforms/InstCombine/InstCombine.h"
21
#include "llvm/Transforms/Scalar.h"
22
#include "llvm/Transforms/Utils.h"
23
24
using namespace llvm;
25
using namespace polly;
26
27
static cl::opt<bool>
28
    PollyInliner("polly-run-inliner",
29
                 cl::desc("Run an early inliner pass before Polly"), cl::Hidden,
30
                 cl::init(false), cl::ZeroOrMore, cl::cat(PollyCategory));
31
32
1
void polly::registerCanonicalicationPasses(llvm::legacy::PassManagerBase &PM) {
33
1
  bool UseMemSSA = true;
34
1
  PM.add(polly::createRewriteByrefParamsPass());
35
1
  PM.add(llvm::createPromoteMemoryToRegisterPass());
36
1
  PM.add(llvm::createEarlyCSEPass(UseMemSSA));
37
1
  PM.add(llvm::createInstructionCombiningPass());
38
1
  PM.add(llvm::createCFGSimplificationPass());
39
1
  PM.add(llvm::createTailCallEliminationPass());
40
1
  PM.add(llvm::createCFGSimplificationPass());
41
1
  PM.add(llvm::createReassociatePass());
42
1
  PM.add(llvm::createLoopRotatePass());
43
1
  if (PollyInliner) {
44
0
    PM.add(llvm::createFunctionInliningPass(200));
45
0
    PM.add(llvm::createPromoteMemoryToRegisterPass());
46
0
    PM.add(llvm::createCFGSimplificationPass());
47
0
    PM.add(llvm::createInstructionCombiningPass());
48
0
    PM.add(createBarrierNoopPass());
49
0
  }
50
1
  PM.add(llvm::createInstructionCombiningPass());
51
1
  PM.add(llvm::createIndVarSimplifyPass());
52
1
  PM.add(polly::createCodePreparationPass());
53
1
}
54
55
namespace {
56
class PollyCanonicalize : public ModulePass {
57
  PollyCanonicalize(const PollyCanonicalize &) = delete;
58
  const PollyCanonicalize &operator=(const PollyCanonicalize &) = delete;
59
60
public:
61
  static char ID;
62
63
1
  explicit PollyCanonicalize() : ModulePass(ID) {}
64
  ~PollyCanonicalize();
65
66
  /// @name FunctionPass interface.
67
  //@{
68
  virtual void getAnalysisUsage(AnalysisUsage &AU) const;
69
  virtual void releaseMemory();
70
  virtual bool runOnModule(Module &M);
71
  virtual void print(raw_ostream &OS, const Module *) const;
72
  //@}
73
};
74
} // namespace
75
76
1
PollyCanonicalize::~PollyCanonicalize() {}
77
78
1
void PollyCanonicalize::getAnalysisUsage(AnalysisUsage &AU) const {}
79
80
1
void PollyCanonicalize::releaseMemory() {}
81
82
1
bool PollyCanonicalize::runOnModule(Module &M) {
83
1
  legacy::PassManager PM;
84
1
  registerCanonicalicationPasses(PM);
85
1
  PM.run(M);
86
1
87
1
  return true;
88
1
}
89
90
1
void PollyCanonicalize::print(raw_ostream &OS, const Module *) const {}
91
92
char PollyCanonicalize::ID = 0;
93
94
0
Pass *polly::createPollyCanonicalizePass() { return new PollyCanonicalize(); }
95
96
44.2k
INITIALIZE_PASS_BEGIN(PollyCanonicalize, "polly-canonicalize",
97
44.2k
                      "Polly - Run canonicalization passes", false, false)
98
44.2k
INITIALIZE_PASS_END(PollyCanonicalize, "polly-canonicalize",
99
                    "Polly - Run canonicalization passes", false, false)