LLVM: include/llvm/Analysis/StackLifetime.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9#ifndef LLVM_ANALYSIS_STACKLIFETIME_H
10#define LLVM_ANALYSIS_STACKLIFETIME_H
11
19#include
20
21namespace llvm {
22
28
29
30
31
32
33
34
35
36
38
39
40
41 struct BlockLifetimeInfo {
42 explicit BlockLifetimeInfo(unsigned Size)
44
45
47
48
50
51
53
54
56 };
57
58public:
60
61
62
67
68 public:
70 void addRange(unsigned Start, unsigned End) { Bits.set(Start, End); }
71
73 return Bits.anyCommon(Other.Bits);
74 }
75
77
78 bool test(unsigned Idx) const { return Bits.test(Idx); }
79 };
80
81
82
87
88private:
90 LivenessType Type;
91
92
94 LivenessMap BlockLiveness;
95
96
97
99
100
101
103
105 unsigned NumAllocas;
107
108
110
111
112
114
115 struct Marker {
116 unsigned AllocaNo;
117 bool IsStart;
118 };
119
120
121 DenseMap<const BasicBlock *, SmallVector<std::pair<unsigned, Marker>, 4>>
122 BBMarkers;
123
125 void dumpBlockLiveness() const;
126 void dumpLiveRanges() const;
127
128 void collectMarkers();
129 void calculateLocalLiveness();
130 void calculateLiveIntervals();
131
132public:
134 LivenessType Type);
135
136 void run();
137
139 filter_iterator<ArrayRef<const IntrinsicInst *>::const_iterator,
140 std::function<bool(const IntrinsicInst *)>>>
146
147
148
149
151
152
154
155
157
158
159
161 return LiveRange(Instructions.size(), true);
162 }
163
165};
166
168 OS << "{";
170 for (int Idx = V.find_first(); Idx >= 0; Idx = V.find_next(Idx))
171 OS << LS << Idx;
172 OS << "}";
173 return OS;
174}
175
178 return OS << R.Bits;
179}
180
181
183 : public PassInfoMixin {
186
187public:
189 : Type(Type), OS(OS) {}
194};
195
196}
197
198#endif
This file implements the BitVector class.
static void dumpAllocas(const SmallVectorImpl< coro::AllocaInfo > &Allocas)
This file defines the DenseMap class.
This header defines various interfaces for pass management in LLVM.
SI Optimize VGPR LiveRange
This file defines the SmallVector class.
an instruction to allocate memory on the stack
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
LLVM Basic Block Representation.
A wrapper class for inspecting calls to intrinsic functions.
A helper class to return the specified delimiter string after the first invocation of operator String...
This class represents the liveness of a register, stack slot, etc.
A set of analyses that are preserved following a run of a transformation pass.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
void printPipeline(raw_ostream &OS, function_ref< StringRef(StringRef)> MapClassName2PassName)
static bool isRequired()
Definition StackLifetime.h:191
StackLifetimePrinterPass(raw_ostream &OS, StackLifetime::LivenessType Type)
Definition StackLifetime.h:188
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
This class represents a set of interesting instructions where an alloca is live.
Definition StackLifetime.h:63
bool overlaps(const LiveRange &Other) const
Definition StackLifetime.h:72
void addRange(unsigned Start, unsigned End)
Definition StackLifetime.h:70
void join(const LiveRange &Other)
Definition StackLifetime.h:76
bool test(unsigned Idx) const
Definition StackLifetime.h:78
friend raw_ostream & operator<<(raw_ostream &OS, const StackLifetime::LiveRange &R)
Definition StackLifetime.h:176
LiveRange(unsigned Size, bool Set=false)
Definition StackLifetime.h:69
void print(raw_ostream &O)
StackLifetime(const Function &F, ArrayRef< const AllocaInst * > Allocas, LivenessType Type)
iterator_range< filter_iterator< ArrayRef< const IntrinsicInst * >::const_iterator, std::function< bool(const IntrinsicInst *)> > > getMarkers() const
Definition StackLifetime.h:141
bool isReachable(const Instruction *I) const
Returns true if instruction is reachable from entry.
LiveRange getFullLiveRange() const
Returns a live range that represents an alloca that is live throughout the entire function.
Definition StackLifetime.h:160
const LiveRange & getLiveRange(const AllocaInst *AI) const
Returns a set of "interesting" instructions where the given alloca is live.
LivenessType
Definition StackLifetime.h:83
@ May
Definition StackLifetime.h:84
@ Must
Definition StackLifetime.h:85
bool isAliveAfter(const AllocaInst *AI, const Instruction *I) const
Returns true if the alloca is alive after the instruction.
StringRef - Represent a constant reference to a string, i.e.
The instances of the Type class are immutable: once they are created, they are never changed.
An efficient, type-erasing, non-owning reference to a callable.
This class implements an extremely fast bulk output stream that can only output to a stream.
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< filter_iterator< detail::IterOfRange< RangeT >, PredicateT > > make_filter_range(RangeT &&Range, PredicateT Pred)
Convenience function that takes a range of elements and a predicate, and return a new filter_iterator...
iterator_range(Container &&) -> iterator_range< llvm::detail::IterOfRange< Container > >
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
ArrayRef(const T &OneElt) -> ArrayRef< T >
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
A CRTP mix-in to automatically provide informational APIs needed for passes.