Coverage Report

Created: 2017-08-21 19:50

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/tools/polly/lib/CodeGen/CodegenCleanup.cpp
Line
Count
Source (jump to first uncovered line)
1
//===- CodegenCleanup.cpp -------------------------------------------------===//
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
#include "polly/CodeGen/CodegenCleanup.h"
11
12
#include "llvm/Analysis/ScopedNoAliasAA.h"
13
#include "llvm/Analysis/TypeBasedAliasAnalysis.h"
14
#include "llvm/IR/Function.h"
15
#include "llvm/IR/LegacyPassManager.h"
16
#include "llvm/PassInfo.h"
17
#include "llvm/PassRegistry.h"
18
#include "llvm/PassSupport.h"
19
#include "llvm/Support/Debug.h"
20
#include "llvm/Transforms/Scalar.h"
21
#define DEBUG_TYPE "polly-cleanup"
22
23
using namespace llvm;
24
using namespace polly;
25
26
namespace {
27
28
class CodegenCleanup : public FunctionPass {
29
private:
30
  CodegenCleanup(const CodegenCleanup &) = delete;
31
  const CodegenCleanup &operator=(const CodegenCleanup &) = delete;
32
33
  llvm::legacy::FunctionPassManager *FPM;
34
35
public:
36
  static char ID;
37
0
  explicit CodegenCleanup() : FunctionPass(ID), FPM(nullptr) {}
38
39
  /// @name FunctionPass interface
40
  //@{
41
0
  virtual void getAnalysisUsage(llvm::AnalysisUsage &AU) const override {}
42
43
0
  virtual bool doInitialization(Module &M) override {
44
0
    assert(!FPM);
45
0
46
0
    FPM = new llvm::legacy::FunctionPassManager(&M);
47
0
48
0
    // TODO: How to make parent passes discoverable?
49
0
    // TODO: Should be sensitive to compiler options in PassManagerBuilder, to
50
0
    // which we do not have access here.
51
0
    FPM->add(createScopedNoAliasAAWrapperPass());
52
0
    FPM->add(createTypeBasedAAWrapperPass());
53
0
    FPM->add(createAAResultsWrapperPass());
54
0
55
0
    // TODO: These are non-conditional passes that run between
56
0
    // EP_ModuleOptimizerEarly and EP_VectorizerStart just to ensure we do not
57
0
    // miss any optimization that would have run after Polly with
58
0
    // -polly-position=early. This can probably be reduced to a more compact set
59
0
    // of passes.
60
0
    FPM->add(createCFGSimplificationPass());
61
0
    FPM->add(createSROAPass());
62
0
    FPM->add(createEarlyCSEPass());
63
0
    FPM->add(createInstructionCombiningPass());
64
0
    FPM->add(createJumpThreadingPass());
65
0
    FPM->add(createCorrelatedValuePropagationPass());
66
0
    FPM->add(createCFGSimplificationPass());
67
0
    FPM->add(createInstructionCombiningPass());
68
0
    FPM->add(createCFGSimplificationPass());
69
0
    FPM->add(createReassociatePass());
70
0
    FPM->add(createLoopRotatePass());
71
0
    FPM->add(createLICMPass());
72
0
    FPM->add(createLoopUnswitchPass());
73
0
    FPM->add(createCFGSimplificationPass());
74
0
    FPM->add(createInstructionCombiningPass());
75
0
    FPM->add(createIndVarSimplifyPass());
76
0
    FPM->add(createLoopIdiomPass());
77
0
    FPM->add(createLoopDeletionPass());
78
0
    FPM->add(createCFGSimplificationPass());
79
0
    FPM->add(createSimpleLoopUnrollPass());
80
0
    FPM->add(createMergedLoadStoreMotionPass());
81
0
    FPM->add(createMemCpyOptPass());
82
0
    FPM->add(createBitTrackingDCEPass());
83
0
    FPM->add(createInstructionCombiningPass());
84
0
    FPM->add(createJumpThreadingPass());
85
0
    FPM->add(createCorrelatedValuePropagationPass());
86
0
    FPM->add(createDeadStoreEliminationPass());
87
0
    FPM->add(createLICMPass());
88
0
    FPM->add(createLoopRerollPass());
89
0
    FPM->add(createAggressiveDCEPass());
90
0
    FPM->add(createCFGSimplificationPass());
91
0
    FPM->add(createInstructionCombiningPass());
92
0
93
0
    return FPM->doInitialization();
94
0
  }
95
96
0
  virtual bool doFinalization(Module &M) override {
97
0
    bool Result = FPM->doFinalization();
98
0
99
0
    delete FPM;
100
0
    FPM = nullptr;
101
0
102
0
    return Result;
103
0
  }
104
105
0
  virtual bool runOnFunction(llvm::Function &F) override {
106
0
    if (
!F.hasFnAttribute("polly-optimized")0
)
{0
107
0
      DEBUG(dbgs() << F.getName()
108
0
                   << ": Skipping cleanup because Polly did not optimize it.");
109
0
      return false;
110
0
    }
111
0
112
0
    
DEBUG0
(dbgs() << F.getName() << ": Running codegen cleanup...");0
113
0
    return FPM->run(F);
114
0
  }
115
  //@}
116
};
117
118
char CodegenCleanup::ID;
119
} // namespace
120
121
0
FunctionPass *polly::createCodegenCleanupPass() { return new CodegenCleanup(); }
122
123
41.9k
INITIALIZE_PASS_BEGIN41.9k
(CodegenCleanup, "polly-cleanup",41.9k
124
41.9k
                      "Polly - Cleanup after code generation", false, false)
125
41.9k
INITIALIZE_PASS_END(CodegenCleanup, "polly-cleanup",
126
                    "Polly - Cleanup after code generation", false, false)