Coverage Report

Created: 2019-02-23 12:57

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