LLVM  16.0.0git
StackLifetime.cpp
Go to the documentation of this file.
1 //===- StackLifetime.cpp - Alloca Lifetime Analysis -----------------------===//
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 
11 #include "llvm/ADT/STLExtras.h"
12 #include "llvm/ADT/SmallVector.h"
13 #include "llvm/ADT/StringExtras.h"
15 #include "llvm/Config/llvm-config.h"
17 #include "llvm/IR/BasicBlock.h"
18 #include "llvm/IR/CFG.h"
19 #include "llvm/IR/InstIterator.h"
20 #include "llvm/IR/Instructions.h"
21 #include "llvm/IR/IntrinsicInst.h"
22 #include "llvm/IR/Value.h"
23 #include "llvm/Support/Casting.h"
24 #include "llvm/Support/Compiler.h"
25 #include "llvm/Support/Debug.h"
27 #include <algorithm>
28 #include <tuple>
29 
30 using namespace llvm;
31 
32 #define DEBUG_TYPE "stack-lifetime"
33 
36  const auto IT = AllocaNumbering.find(AI);
37  assert(IT != AllocaNumbering.end());
38  return LiveRanges[IT->second];
39 }
40 
42  return BlockInstRange.find(I->getParent()) != BlockInstRange.end();
43 }
44 
46  const Instruction *I) const {
47  const BasicBlock *BB = I->getParent();
48  auto ItBB = BlockInstRange.find(BB);
49  assert(ItBB != BlockInstRange.end() && "Unreachable is not expected");
50 
51  // Search the block for the first instruction following 'I'.
52  auto It = std::upper_bound(Instructions.begin() + ItBB->getSecond().first + 1,
53  Instructions.begin() + ItBB->getSecond().second, I,
54  [](const Instruction *L, const Instruction *R) {
55  return L->comesBefore(R);
56  });
57  --It;
58  unsigned InstNum = It - Instructions.begin();
59  return getLiveRange(AI).test(InstNum);
60 }
61 
62 // Returns unique alloca annotated by lifetime marker only if
63 // markers has the same size and points to the alloca start.
65  const DataLayout &DL) {
66  const AllocaInst *AI = findAllocaForValue(II.getArgOperand(1), true);
67  if (!AI)
68  return nullptr;
69 
70  auto AllocaSizeInBits = AI->getAllocationSizeInBits(DL);
71  if (!AllocaSizeInBits)
72  return nullptr;
73  int64_t AllocaSize = *AllocaSizeInBits / 8;
74 
75  auto *Size = dyn_cast<ConstantInt>(II.getArgOperand(0));
76  if (!Size)
77  return nullptr;
78  int64_t LifetimeSize = Size->getSExtValue();
79 
80  if (LifetimeSize != -1 && LifetimeSize != AllocaSize)
81  return nullptr;
82 
83  return AI;
84 }
85 
86 void StackLifetime::collectMarkers() {
87  InterestingAllocas.resize(NumAllocas);
89  BBMarkerSet;
90 
91  const DataLayout &DL = F.getParent()->getDataLayout();
92 
93  // Compute the set of start/end markers per basic block.
94  for (const BasicBlock *BB : depth_first(&F)) {
95  for (const Instruction &I : *BB) {
96  const IntrinsicInst *II = dyn_cast<IntrinsicInst>(&I);
97  if (!II || !II->isLifetimeStartOrEnd())
98  continue;
99  const AllocaInst *AI = findMatchingAlloca(*II, DL);
100  if (!AI) {
101  HasUnknownLifetimeStartOrEnd = true;
102  continue;
103  }
104  auto It = AllocaNumbering.find(AI);
105  if (It == AllocaNumbering.end())
106  continue;
107  auto AllocaNo = It->second;
108  bool IsStart = II->getIntrinsicID() == Intrinsic::lifetime_start;
109  if (IsStart)
110  InterestingAllocas.set(AllocaNo);
111  BBMarkerSet[BB][II] = {AllocaNo, IsStart};
112  }
113  }
114 
115  // Compute instruction numbering. Only the following instructions are
116  // considered:
117  // * Basic block entries
118  // * Lifetime markers
119  // For each basic block, compute
120  // * the list of markers in the instruction order
121  // * the sets of allocas whose lifetime starts or ends in this BB
122  LLVM_DEBUG(dbgs() << "Instructions:\n");
123  for (const BasicBlock *BB : depth_first(&F)) {
124  LLVM_DEBUG(dbgs() << " " << Instructions.size() << ": BB " << BB->getName()
125  << "\n");
126  auto BBStart = Instructions.size();
127  Instructions.push_back(nullptr);
128 
129  BlockLifetimeInfo &BlockInfo =
130  BlockLiveness.try_emplace(BB, NumAllocas).first->getSecond();
131 
132  auto &BlockMarkerSet = BBMarkerSet[BB];
133  if (BlockMarkerSet.empty()) {
134  BlockInstRange[BB] = std::make_pair(BBStart, Instructions.size());
135  continue;
136  }
137 
138  auto ProcessMarker = [&](const IntrinsicInst *I, const Marker &M) {
139  LLVM_DEBUG(dbgs() << " " << Instructions.size() << ": "
140  << (M.IsStart ? "start " : "end ") << M.AllocaNo
141  << ", " << *I << "\n");
142 
143  BBMarkers[BB].push_back({Instructions.size(), M});
144  Instructions.push_back(I);
145 
146  if (M.IsStart) {
147  BlockInfo.End.reset(M.AllocaNo);
148  BlockInfo.Begin.set(M.AllocaNo);
149  } else {
150  BlockInfo.Begin.reset(M.AllocaNo);
151  BlockInfo.End.set(M.AllocaNo);
152  }
153  };
154 
155  if (BlockMarkerSet.size() == 1) {
156  ProcessMarker(BlockMarkerSet.begin()->getFirst(),
157  BlockMarkerSet.begin()->getSecond());
158  } else {
159  // Scan the BB to determine the marker order.
160  for (const Instruction &I : *BB) {
161  const IntrinsicInst *II = dyn_cast<IntrinsicInst>(&I);
162  if (!II)
163  continue;
164  auto It = BlockMarkerSet.find(II);
165  if (It == BlockMarkerSet.end())
166  continue;
167  ProcessMarker(II, It->getSecond());
168  }
169  }
170 
171  BlockInstRange[BB] = std::make_pair(BBStart, Instructions.size());
172  }
173 }
174 
175 void StackLifetime::calculateLocalLiveness() {
176  bool Changed = true;
177 
178  // LiveIn, LiveOut and BitsIn have a different meaning deppends on type.
179  // ::Maybe true bits represent "may be alive" allocas, ::Must true bits
180  // represent "may be dead". After the loop we will convert ::Must bits from
181  // "may be dead" to "must be alive".
182  while (Changed) {
183  // TODO: Consider switching to worklist instead of traversing entire graph.
184  Changed = false;
185 
186  for (const BasicBlock *BB : depth_first(&F)) {
187  BlockLifetimeInfo &BlockInfo = BlockLiveness.find(BB)->getSecond();
188 
189  // Compute BitsIn by unioning together the LiveOut sets of all preds.
190  BitVector BitsIn;
191  for (const auto *PredBB : predecessors(BB)) {
192  LivenessMap::const_iterator I = BlockLiveness.find(PredBB);
193  // If a predecessor is unreachable, ignore it.
194  if (I == BlockLiveness.end())
195  continue;
196  BitsIn |= I->second.LiveOut;
197  }
198 
199  // Everything is "may be dead" for entry without predecessors.
200  if (Type == LivenessType::Must && BitsIn.empty())
201  BitsIn.resize(NumAllocas, true);
202 
203  // Update block LiveIn set, noting whether it has changed.
204  if (BitsIn.test(BlockInfo.LiveIn)) {
205  BlockInfo.LiveIn |= BitsIn;
206  }
207 
208  // Compute LiveOut by subtracting out lifetimes that end in this
209  // block, then adding in lifetimes that begin in this block. If
210  // we have both BEGIN and END markers in the same basic block
211  // then we know that the BEGIN marker comes after the END,
212  // because we already handle the case where the BEGIN comes
213  // before the END when collecting the markers (and building the
214  // BEGIN/END vectors).
215  switch (Type) {
216  case LivenessType::May:
217  BitsIn.reset(BlockInfo.End);
218  // "may be alive" is set by lifetime start.
219  BitsIn |= BlockInfo.Begin;
220  break;
221  case LivenessType::Must:
222  BitsIn.reset(BlockInfo.Begin);
223  // "may be dead" is set by lifetime end.
224  BitsIn |= BlockInfo.End;
225  break;
226  }
227 
228  // Update block LiveOut set, noting whether it has changed.
229  if (BitsIn.test(BlockInfo.LiveOut)) {
230  Changed = true;
231  BlockInfo.LiveOut |= BitsIn;
232  }
233  }
234  } // while changed.
235 
236  if (Type == LivenessType::Must) {
237  // Convert from "may be dead" to "must be alive".
238  for (auto &[BB, BlockInfo] : BlockLiveness) {
239  BlockInfo.LiveIn.flip();
240  BlockInfo.LiveOut.flip();
241  }
242  }
243 }
244 
245 void StackLifetime::calculateLiveIntervals() {
246  for (auto IT : BlockLiveness) {
247  const BasicBlock *BB = IT.getFirst();
248  BlockLifetimeInfo &BlockInfo = IT.getSecond();
249  unsigned BBStart, BBEnd;
250  std::tie(BBStart, BBEnd) = BlockInstRange[BB];
251 
252  BitVector Started, Ended;
253  Started.resize(NumAllocas);
254  Ended.resize(NumAllocas);
256  Start.resize(NumAllocas);
257 
258  // LiveIn ranges start at the first instruction.
259  for (unsigned AllocaNo = 0; AllocaNo < NumAllocas; ++AllocaNo) {
260  if (BlockInfo.LiveIn.test(AllocaNo)) {
261  Started.set(AllocaNo);
262  Start[AllocaNo] = BBStart;
263  }
264  }
265 
266  for (auto &It : BBMarkers[BB]) {
267  unsigned InstNo = It.first;
268  bool IsStart = It.second.IsStart;
269  unsigned AllocaNo = It.second.AllocaNo;
270 
271  if (IsStart) {
272  if (!Started.test(AllocaNo)) {
273  Started.set(AllocaNo);
274  Ended.reset(AllocaNo);
275  Start[AllocaNo] = InstNo;
276  }
277  } else {
278  if (Started.test(AllocaNo)) {
279  LiveRanges[AllocaNo].addRange(Start[AllocaNo], InstNo);
280  Started.reset(AllocaNo);
281  }
282  Ended.set(AllocaNo);
283  }
284  }
285 
286  for (unsigned AllocaNo = 0; AllocaNo < NumAllocas; ++AllocaNo)
287  if (Started.test(AllocaNo))
288  LiveRanges[AllocaNo].addRange(Start[AllocaNo], BBEnd);
289  }
290 }
291 
292 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
293 LLVM_DUMP_METHOD void StackLifetime::dumpAllocas() const {
294  dbgs() << "Allocas:\n";
295  for (unsigned AllocaNo = 0; AllocaNo < NumAllocas; ++AllocaNo)
296  dbgs() << " " << AllocaNo << ": " << *Allocas[AllocaNo] << "\n";
297 }
298 
299 LLVM_DUMP_METHOD void StackLifetime::dumpBlockLiveness() const {
300  dbgs() << "Block liveness:\n";
301  for (auto IT : BlockLiveness) {
302  const BasicBlock *BB = IT.getFirst();
303  const BlockLifetimeInfo &BlockInfo = BlockLiveness.find(BB)->getSecond();
304  auto BlockRange = BlockInstRange.find(BB)->getSecond();
305  dbgs() << " BB (" << BB->getName() << ") [" << BlockRange.first << ", " << BlockRange.second
306  << "): begin " << BlockInfo.Begin << ", end " << BlockInfo.End
307  << ", livein " << BlockInfo.LiveIn << ", liveout "
308  << BlockInfo.LiveOut << "\n";
309  }
310 }
311 
312 LLVM_DUMP_METHOD void StackLifetime::dumpLiveRanges() const {
313  dbgs() << "Alloca liveness:\n";
314  for (unsigned AllocaNo = 0; AllocaNo < NumAllocas; ++AllocaNo)
315  dbgs() << " " << AllocaNo << ": " << LiveRanges[AllocaNo] << "\n";
316 }
317 #endif
318 
322  : F(F), Type(Type), Allocas(Allocas), NumAllocas(Allocas.size()) {
323  LLVM_DEBUG(dumpAllocas());
324 
325  for (unsigned I = 0; I < NumAllocas; ++I)
326  AllocaNumbering[Allocas[I]] = I;
327 
328  collectMarkers();
329 }
330 
332  if (HasUnknownLifetimeStartOrEnd) {
333  // There is marker which we can't assign to a specific alloca, so we
334  // fallback to the most conservative results for the type.
335  switch (Type) {
336  case LivenessType::May:
337  LiveRanges.resize(NumAllocas, getFullLiveRange());
338  break;
339  case LivenessType::Must:
340  LiveRanges.resize(NumAllocas, LiveRange(Instructions.size()));
341  break;
342  }
343  return;
344  }
345 
346  LiveRanges.resize(NumAllocas, LiveRange(Instructions.size()));
347  for (unsigned I = 0; I < NumAllocas; ++I)
348  if (!InterestingAllocas.test(I))
349  LiveRanges[I] = getFullLiveRange();
350 
351  calculateLocalLiveness();
352  LLVM_DEBUG(dumpBlockLiveness());
353  calculateLiveIntervals();
354  LLVM_DEBUG(dumpLiveRanges());
355 }
356 
358  : public AssemblyAnnotationWriter {
359  const StackLifetime &SL;
360 
361  void printInstrAlive(unsigned InstrNo, formatted_raw_ostream &OS) {
363  for (const auto &KV : SL.AllocaNumbering) {
364  if (SL.LiveRanges[KV.getSecond()].test(InstrNo))
365  Names.push_back(KV.getFirst()->getName());
366  }
367  llvm::sort(Names);
368  OS << " ; Alive: <" << llvm::join(Names, " ") << ">\n";
369  }
370 
371  void emitBasicBlockStartAnnot(const BasicBlock *BB,
372  formatted_raw_ostream &OS) override {
373  auto ItBB = SL.BlockInstRange.find(BB);
374  if (ItBB == SL.BlockInstRange.end())
375  return; // Unreachable.
376  printInstrAlive(ItBB->getSecond().first, OS);
377  }
378 
379  void printInfoComment(const Value &V, formatted_raw_ostream &OS) override {
380  const Instruction *Instr = dyn_cast<Instruction>(&V);
381  if (!Instr || !SL.isReachable(Instr))
382  return;
383 
385  for (const auto &KV : SL.AllocaNumbering) {
386  if (SL.isAliveAfter(KV.getFirst(), Instr))
387  Names.push_back(KV.getFirst()->getName());
388  }
389  llvm::sort(Names);
390  OS << "\n ; Alive: <" << llvm::join(Names, " ") << ">\n";
391  }
392 
393 public:
395 };
396 
398  LifetimeAnnotationWriter AAW(*this);
399  F.print(OS, &AAW);
400 }
401 
405  for (auto &I : instructions(F))
406  if (const AllocaInst *AI = dyn_cast<AllocaInst>(&I))
407  Allocas.push_back(AI);
408  StackLifetime SL(F, Allocas, Type);
409  SL.run();
410  SL.print(OS);
411  return PreservedAnalyses::all();
412 }
413 
415  raw_ostream &OS, function_ref<StringRef(StringRef)> MapClassName2PassName) {
417  OS, MapClassName2PassName);
418  OS << "<";
419  switch (Type) {
421  OS << "may";
422  break;
424  OS << "must";
425  break;
426  }
427  OS << ">";
428 }
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:152
LLVM_DUMP_METHOD
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Definition: Compiler.h:492
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::StackLifetime::isAliveAfter
bool isAliveAfter(const AllocaInst *AI, const Instruction *I) const
Returns true if the alloca is alive after the instruction.
Definition: StackLifetime.cpp:45
llvm::upper_bound
auto upper_bound(R &&Range, T &&Value)
Provide wrappers to std::upper_bound which take ranges instead of having to pass begin/end explicitly...
Definition: STLExtras.h:1935
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:113
IntrinsicInst.h
llvm::PassInfoMixin< StackLifetimePrinterPass >
InstIterator.h
llvm::Function
Definition: Function.h:60
llvm::Function::print
void print(raw_ostream &OS, AssemblyAnnotationWriter *AAW=nullptr, bool ShouldPreserveUseListOrder=false, bool IsForDebug=false) const
Print the function to an output stream with an optional AssemblyAnnotationWriter.
Definition: AsmWriter.cpp:4572
llvm::BitVector::set
BitVector & set()
Definition: BitVector.h:344
llvm::IntrinsicInst::getIntrinsicID
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of this intrinsic.
Definition: IntrinsicInst.h:53
llvm::SmallVector< unsigned, 8 >
ValueTracking.h
IT
static cl::opt< ITMode > IT(cl::desc("IT block support"), cl::Hidden, cl::init(DefaultIT), cl::values(clEnumValN(DefaultIT, "arm-default-it", "Generate any type of IT block"), clEnumValN(RestrictedIT, "arm-restrict-it", "Disallow complex IT blocks")))
llvm::StackLifetime::StackLifetime
StackLifetime(const Function &F, ArrayRef< const AllocaInst * > Allocas, LivenessType Type)
Definition: StackLifetime.cpp:319
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::BitVector::resize
void resize(unsigned N, bool t=false)
resize - Grow or shrink the bitvector.
Definition: BitVector.h:334
llvm::StackLifetime::LivenessType::Must
@ Must
STLExtras.h
LLVM_DEBUG
#define LLVM_DEBUG(X)
Definition: Debug.h:101
DepthFirstIterator.h
F
#define F(x, y, z)
Definition: MD5.cpp:55
llvm::StackLifetime::print
void print(raw_ostream &O)
Definition: StackLifetime.cpp:397
llvm::BasicBlock
LLVM Basic Block Representation.
Definition: BasicBlock.h:55
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
llvm::DenseMapBase< DenseMap< const BasicBlock *, BlockLifetimeInfo, DenseMapInfo< const BasicBlock * >, llvm::detail::DenseMapPair< const BasicBlock *, BlockLifetimeInfo > >, const BasicBlock *, BlockLifetimeInfo, DenseMapInfo< const BasicBlock * >, llvm::detail::DenseMapPair< const BasicBlock *, BlockLifetimeInfo > >::const_iterator
DenseMapIterator< const BasicBlock *, BlockLifetimeInfo, DenseMapInfo< const BasicBlock * >, llvm::detail::DenseMapPair< const BasicBlock *, BlockLifetimeInfo >, true > const_iterator
Definition: DenseMap.h:73
FormattedStream.h
llvm::Instruction::isLifetimeStartOrEnd
bool isLifetimeStartOrEnd() const LLVM_READONLY
Return true if the instruction is a llvm.lifetime.start or llvm.lifetime.end marker.
Definition: Instruction.cpp:755
StackLifetime.h
llvm::StackLifetime::isReachable
bool isReachable(const Instruction *I) const
Returns true if instruction is reachable from entry.
Definition: StackLifetime.cpp:41
llvm::Instruction
Definition: Instruction.h:42
llvm::predecessors
auto predecessors(MachineBasicBlock *BB)
Definition: MachineSSAContext.h:30
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
llvm::BitVector
Definition: BitVector.h:75
llvm::AllocaInst::getAllocationSizeInBits
Optional< TypeSize > getAllocationSizeInBits(const DataLayout &DL) const
Get allocation size in bits.
Definition: Instructions.cpp:59
llvm::BitVector::empty
bool empty() const
empty - Tests whether there are no bits in this bitvector.
Definition: BitVector.h:149
CFG.h
AssemblyAnnotationWriter.h
llvm::sort
void sort(IteratorTy Start, IteratorTy End)
Definition: STLExtras.h:1682
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLFunctionalExtras.h:36
llvm::StackLifetime::LivenessType::May
@ May
BasicBlock.h
llvm::instructions
inst_range instructions(Function *F)
Definition: InstIterator.h:133
llvm::GlobalValue::getParent
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:652
llvm::StackLifetime::getLiveRange
const LiveRange & getLiveRange(const AllocaInst *AI) const
Returns a set of "interesting" instructions where the given alloca is live.
Definition: StackLifetime.cpp:35
llvm::DenseMap
Definition: DenseMap.h:714
I
#define I(x, y, z)
Definition: MD5.cpp:58
StringExtras.h
llvm::StackLifetime
Compute live ranges of allocas.
Definition: StackLifetime.h:37
llvm::BitVector::flip
BitVector & flip()
Definition: BitVector.h:424
llvm::DenseMapBase::find
iterator find(const_arg_type_t< KeyT > Val)
Definition: DenseMap.h:150
llvm::formatted_raw_ostream
formatted_raw_ostream - A raw_ostream that wraps another one and keeps track of line and column posit...
Definition: FormattedStream.h:30
llvm::StackLifetime::LivenessType
LivenessType
Definition: StackLifetime.h:83
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LiveRange
SI Optimize VGPR LiveRange
Definition: SIOptimizeVGPRLiveRange.cpp:616
llvm::size
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
Definition: STLExtras.h:1715
llvm::StackLifetimePrinterPass::printPipeline
void printPipeline(raw_ostream &OS, function_ref< StringRef(StringRef)> MapClassName2PassName)
Definition: StackLifetime.cpp:414
llvm::StackLifetimePrinterPass::run
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Definition: StackLifetime.cpp:402
llvm::StackLifetime::run
void run()
Definition: StackLifetime.cpp:331
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
llvm::StackLifetime::LiveRange
This class represents a set of interesting instructions where an alloca is live.
Definition: StackLifetime.h:63
Compiler.h
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
llvm::StackLifetime::getFullLiveRange
LiveRange getFullLiveRange() const
Returns a live range that represents an alloca that is live throughout the entire function.
Definition: StackLifetime.h:162
llvm::depth_first
iterator_range< df_iterator< T > > depth_first(const T &G)
Definition: DepthFirstIterator.h:230
llvm::StackLifetime::LifetimeAnnotationWriter
Definition: StackLifetime.cpp:357
llvm::BitVector::test
bool test(unsigned Idx) const
Definition: BitVector.h:454
llvm::DenseMapBase::end
iterator end()
Definition: DenseMap.h:84
llvm::PreservedAnalyses::all
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition: PassManager.h:158
llvm::AssemblyAnnotationWriter
Definition: AssemblyAnnotationWriter.h:27
Casting.h
llvm::BitVector::reset
BitVector & reset()
Definition: BitVector.h:385
llvm::IntrinsicInst
A wrapper class for inspecting calls to intrinsic functions.
Definition: IntrinsicInst.h:46
llvm::StackLifetime::LifetimeAnnotationWriter::LifetimeAnnotationWriter
LifetimeAnnotationWriter(const StackLifetime &SL)
Definition: StackLifetime.cpp:394
Instructions.h
SmallVector.h
llvm::CallBase::getArgOperand
Value * getArgOperand(unsigned i) const
Definition: InstrTypes.h:1342
llvm::DenseMapBase::try_emplace
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&... Args)
Definition: DenseMap.h:222
findMatchingAlloca
static const AllocaInst * findMatchingAlloca(const IntrinsicInst &II, const DataLayout &DL)
Definition: StackLifetime.cpp:64
llvm::Module::getDataLayout
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
Definition: Module.cpp:399
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:42
BB
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
Definition: README.txt:39
llvm::StackLifetime::LiveRange::test
bool test(unsigned Idx) const
Definition: StackLifetime.h:78
llvm::AllocaInst
an instruction to allocate memory on the stack
Definition: Instructions.h:59
Value.h
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
Debug.h
llvm::findAllocaForValue
AllocaInst * findAllocaForValue(Value *V, bool OffsetZero=false)
Returns unique alloca where the value comes from, or nullptr.
Definition: ValueTracking.cpp:4648