Coverage Report

Created: 2017-10-03 07:32

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/include/llvm/CodeGen/LiveStackAnalysis.h
Line
Count
Source (jump to first uncovered line)
1
//===- LiveStackAnalysis.h - Live Stack Slot Analysis -----------*- C++ -*-===//
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
// This file implements the live stack slot analysis pass. It is analogous to
11
// live interval analysis except it's analyzing liveness of stack slots rather
12
// than registers.
13
//
14
//===----------------------------------------------------------------------===//
15
16
#ifndef LLVM_CODEGEN_LIVESTACKANALYSIS_H
17
#define LLVM_CODEGEN_LIVESTACKANALYSIS_H
18
19
#include "llvm/CodeGen/LiveInterval.h"
20
#include "llvm/CodeGen/MachineFunctionPass.h"
21
#include "llvm/Pass.h"
22
#include <cassert>
23
#include <map>
24
#include <unordered_map>
25
26
namespace llvm {
27
28
class TargetRegisterClass;
29
class TargetRegisterInfo;
30
31
class LiveStacks : public MachineFunctionPass {
32
  const TargetRegisterInfo *TRI;
33
34
  /// Special pool allocator for VNInfo's (LiveInterval val#).
35
  ///
36
  VNInfo::Allocator VNInfoAllocator;
37
38
  /// S2IMap - Stack slot indices to live interval mapping.
39
  using SS2IntervalMap = std::unordered_map<int, LiveInterval>;
40
  SS2IntervalMap S2IMap;
41
42
  /// S2RCMap - Stack slot indices to register class mapping.
43
  std::map<int, const TargetRegisterClass *> S2RCMap;
44
45
public:
46
  static char ID; // Pass identification, replacement for typeid
47
48
32.0k
  LiveStacks() : MachineFunctionPass(ID) {
49
32.0k
    initializeLiveStacksPass(*PassRegistry::getPassRegistry());
50
32.0k
  }
51
52
  using iterator = SS2IntervalMap::iterator;
53
  using const_iterator = SS2IntervalMap::const_iterator;
54
55
0
  const_iterator begin() const { return S2IMap.begin(); }
56
0
  const_iterator end() const { return S2IMap.end(); }
57
26.7k
  iterator begin() { return S2IMap.begin(); }
58
26.7k
  iterator end() { return S2IMap.end(); }
59
60
615k
  unsigned getNumIntervals() const { return (unsigned)S2IMap.size(); }
61
62
  LiveInterval &getOrCreateInterval(int Slot, const TargetRegisterClass *RC);
63
64
525k
  LiveInterval &getInterval(int Slot) {
65
525k
    assert(Slot >= 0 && "Spill slot indice must be >= 0");
66
525k
    SS2IntervalMap::iterator I = S2IMap.find(Slot);
67
525k
    assert(I != S2IMap.end() && "Interval does not exist for stack slot");
68
525k
    return I->second;
69
525k
  }
70
71
0
  const LiveInterval &getInterval(int Slot) const {
72
0
    assert(Slot >= 0 && "Spill slot indice must be >= 0");
73
0
    SS2IntervalMap::const_iterator I = S2IMap.find(Slot);
74
0
    assert(I != S2IMap.end() && "Interval does not exist for stack slot");
75
0
    return I->second;
76
0
  }
77
78
764k
  bool hasInterval(int Slot) const { return S2IMap.count(Slot); }
79
80
0
  const TargetRegisterClass *getIntervalRegClass(int Slot) const {
81
0
    assert(Slot >= 0 && "Spill slot indice must be >= 0");
82
0
    std::map<int, const TargetRegisterClass *>::const_iterator I =
83
0
        S2RCMap.find(Slot);
84
0
    assert(I != S2RCMap.end() &&
85
0
           "Register class info does not exist for stack slot");
86
0
    return I->second;
87
0
  }
88
89
125k
  VNInfo::Allocator &getVNInfoAllocator() { return VNInfoAllocator; }
90
91
  void getAnalysisUsage(AnalysisUsage &AU) const override;
92
  void releaseMemory() override;
93
94
  /// runOnMachineFunction - pass entry point
95
  bool runOnMachineFunction(MachineFunction &) override;
96
97
  /// print - Implement the dump method.
98
  void print(raw_ostream &O, const Module * = nullptr) const override;
99
};
100
101
} // end namespace llvm
102
103
#endif // LLVM_CODEGEN_LIVESTACK_ANALYSIS_H