LLVM 24.0.0git
ADCE.cpp
Go to the documentation of this file.
1//===- ADCE.cpp - Code to perform dead code elimination -------------------===//
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// This file implements the Aggressive Dead Code Elimination pass. This pass
10// optimistically assumes that all instructions are dead until proven otherwise,
11// allowing it to eliminate dead computations that other DCE passes do not
12// catch, particularly involving loop computations.
13//
14//===----------------------------------------------------------------------===//
15
17#include "ScalarOptions.h"
21#include "llvm/ADT/SetVector.h"
24#include "llvm/ADT/Statistic.h"
25#include "llvm/Analysis/CFG.h"
31#include "llvm/IR/BasicBlock.h"
32#include "llvm/IR/CFG.h"
33#include "llvm/IR/DebugInfo.h"
35#include "llvm/IR/DebugLoc.h"
36#include "llvm/IR/Dominators.h"
37#include "llvm/IR/Function.h"
38#include "llvm/IR/IRBuilder.h"
40#include "llvm/IR/Instruction.h"
42#include "llvm/IR/PassManager.h"
43#include "llvm/IR/Use.h"
44#include "llvm/IR/Value.h"
47#include "llvm/Support/Debug.h"
50#include <cassert>
51#include <cstddef>
52#include <utility>
53
54using namespace llvm;
55
56#define DEBUG_TYPE "adce"
57
58STATISTIC(NumRemoved, "Number of instructions removed");
59STATISTIC(NumBranchesRemoved, "Number of branch instructions removed");
60
61namespace {
62
63/// Information about basic blocks relevant to dead code elimination.
64struct BlockInfoType {
65 /// True when this block contains a live instructions.
66 bool Live = false;
67
68 /// True when this block is known to have live PHI nodes.
69 bool HasLivePhiNodes = false;
70
71 /// Control dependence sources need to be live for this block.
72 bool CFLive = false;
73
74 /// Post-order numbering of reverse control flow graph.
75 unsigned PostOrder = 0;
76};
77
78struct ADCEChanged {
79 bool ChangedAnything = false;
80 bool ChangedNonDebugInstr = false;
81 bool ChangedControlFlow = false;
82};
83
84class AggressiveDeadCodeElimination {
85 const ScalarOptions &Opts;
86 Function &F;
87
88 // ADCE does not use DominatorTree per se, but it updates it to preserve the
89 // analysis.
90 DominatorTree *DT;
91 PostDominatorTree &PDT;
92
93 /// Mapping of blocks to associated information, indexed by block number.
95
96 /// Set of live instructions.
97 SmallPtrSet<Instruction *, 32> LiveInst;
98 bool isLive(Instruction *I) { return LiveInst.contains(I); }
99
100 /// Instructions known to be live where we need to mark
101 /// reaching definitions as live.
103
104 /// Debug info scopes around a live instruction.
105 SmallPtrSet<const Metadata *, 32> AliveScopes;
106
107 /// Set of blocks with not known to have live terminators.
108 SmallSetVector<BasicBlock *, 16> BlocksWithDeadTerminators;
109
110 /// The set of blocks which we have determined whose control
111 /// dependence sources must be live and which have not had
112 /// those dependences analyzed.
113 SmallPtrSet<BasicBlock *, 16> NewLiveBlocks;
114
115 /// Set up auxiliary data structures for Instructions and BasicBlocks and
116 /// initialize the Worklist to the set of must-be-live Instruscions.
117 void initialize();
118
119 BlockInfoType &getBlockInfo(BasicBlock *BB) {
120 return BlockInfo[BB->getNumber()];
121 }
122
123 /// Return true for operations which are always treated as live.
124 bool isAlwaysLive(Instruction &I);
125
126 /// Return true for instrumentation instructions for value profiling.
127 bool isInstrumentsConstant(Instruction &I);
128
129 /// Propagate liveness to reaching definitions.
130 void markLiveInstructions();
131
132 /// Mark an instruction as live.
133 void markLive(Instruction *I);
134
135 /// Mark a block as live.
136 void markLive(BasicBlock *BB);
137
138 /// Mark terminators of control predecessors of a PHI node live.
139 void markPhiLive(PHINode *PN);
140
141 /// Record the Debug Scopes which surround live debug information.
142 void collectLiveScopes(const DILocalScope &LS);
143 void collectLiveScopes(const DILocation &DL);
144
145 /// Analyze dead branches to find those whose branches are the sources
146 /// of control dependences impacting a live block. Those branches are
147 /// marked live.
148 void markLiveBranchesFromControlDependences();
149
150 /// Remove instructions not marked live, return if any instruction was
151 /// removed.
152 ADCEChanged removeDeadInstructions();
153
154 /// Identify connected sections of the control flow graph which have
155 /// dead terminators and rewrite the control flow graph to remove them.
156 bool updateDeadRegions();
157
158 /// Set the BlockInfo::PostOrder field based on a post-order
159 /// numbering of the reverse control flow graph.
160 void computeReversePostOrder();
161
162 /// Make the terminator of this block an unconditional branch to \p Target.
163 void makeUnconditional(BasicBlock *BB, BasicBlock *Target);
164
165public:
166 AggressiveDeadCodeElimination(Function &F, DominatorTree *DT,
167 PostDominatorTree &PDT)
168 : Opts(ScalarOptions::Global), F(F), DT(DT), PDT(PDT) {}
169
170 ADCEChanged performDeadCodeElimination();
171};
172
173} // end anonymous namespace
174
175ADCEChanged AggressiveDeadCodeElimination::performDeadCodeElimination() {
176 initialize();
177 markLiveInstructions();
178 return removeDeadInstructions();
179}
180
181void AggressiveDeadCodeElimination::initialize() {
182 BlockInfo.resize(F.getMaxBlockNumber());
183 size_t NumInsts = 0;
184 for (auto &BB : F)
185 NumInsts += BB.size();
186 LiveInst.reserve(NumInsts);
187
188 // Collect the set of "root" instructions that are known live.
189 for (Instruction &I : instructions(F))
190 if (isAlwaysLive(I))
191 markLive(&I);
192
193 if (!Opts.adce_remove_control_flow)
194 return;
195
196 if (!Opts.adce_remove_loops) {
197 // Mark all terminators that have backedges as live.
199 FindFunctionBackedges(F, Backedges);
200 for (const auto &[Src, Dst] : Backedges)
201 markLive(const_cast<Instruction *>(Src->getTerminator()));
202 }
203
204 // Mark blocks live if there is no path from the block to a
205 // return of the function.
206 // We do this by seeing which of the postdomtree root children exit the
207 // program, and for all others, mark the subtree live.
208 for (const auto &PDTChild : children<DomTreeNode *>(PDT.getRootNode())) {
209 auto *BB = PDTChild->getBlock();
210 // Real function return
211 if (isa<ReturnInst>(BB->back())) {
212 LLVM_DEBUG(dbgs() << "post-dom root child is a return: " << BB->getName()
213 << '\n';);
214 continue;
215 }
216
217 // This child is something else, like an infinite loop.
218 for (auto *DFNode : depth_first(PDTChild))
219 markLive(&DFNode->getBlock()->back());
220 }
221
222 // Treat the entry block as always live
223 auto *BB = &F.getEntryBlock();
224 auto &EntryInfo = getBlockInfo(BB);
225 EntryInfo.Live = true;
226 if (isa<UncondBrInst>(BB->back()))
227 markLive(&BB->back());
228
229 // Build initial collection of blocks with dead terminators
230 for (auto &BB : F)
231 if (!isLive(&BB.back()))
232 BlocksWithDeadTerminators.insert(&BB);
233}
234
235bool AggressiveDeadCodeElimination::isAlwaysLive(Instruction &I) {
236 // TODO -- use llvm::isInstructionTriviallyDead
237 if (I.isEHPad() || I.mayHaveSideEffects()) {
238 // Skip any value profile instrumentation calls if they are
239 // instrumenting constants.
240 if (isInstrumentsConstant(I))
241 return false;
242 return true;
243 }
244 if (!I.isTerminator())
245 return false;
246 if (Opts.adce_remove_control_flow &&
248 return false;
249 return true;
250}
251
252// Check if this instruction is a runtime call for value profiling and
253// if it's instrumenting a constant.
254bool AggressiveDeadCodeElimination::isInstrumentsConstant(Instruction &I) {
255 // TODO -- move this test into llvm::isInstructionTriviallyDead
256 if (CallInst *CI = dyn_cast<CallInst>(&I))
257 if (Function *Callee = CI->getCalledFunction())
258 if (Callee->getName() == getInstrProfValueProfFuncName())
259 if (isa<Constant>(CI->getArgOperand(0)))
260 return true;
261 return false;
262}
263
264void AggressiveDeadCodeElimination::markLiveInstructions() {
265 // Propagate liveness backwards to operands.
266 do {
267 // Worklist holds newly discovered live instructions
268 // where we need to mark the inputs as live.
269 while (!Worklist.empty()) {
270 Instruction *LiveInst = Worklist.pop_back_val();
271 LLVM_DEBUG(dbgs() << "work live: "; LiveInst->dump(););
272
273 for (Use &OI : LiveInst->operands())
274 if (Instruction *Inst = dyn_cast<Instruction>(OI))
275 markLive(Inst);
276
277 if (auto *PN = dyn_cast<PHINode>(LiveInst))
278 markPhiLive(PN);
279 }
280
281 // After data flow liveness has been identified, examine which branch
282 // decisions are required to determine live instructions are executed.
283 markLiveBranchesFromControlDependences();
284
285 } while (!Worklist.empty());
286}
287
288void AggressiveDeadCodeElimination::markLive(Instruction *I) {
289 auto [It, Inserted] = LiveInst.insert(I);
290 if (!Inserted)
291 return;
292
293 LLVM_DEBUG(dbgs() << "mark live: "; I->dump());
294 Worklist.push_back(I);
295
296 // Collect the live debug info scopes attached to this instruction.
297 if (const DILocation *DL = I->getDebugLoc())
298 collectLiveScopes(*DL);
299
300 // Mark the containing block live
301 BasicBlock *BB = I->getParent();
302 if (I == &BB->back()) {
303 BlocksWithDeadTerminators.remove(BB);
304 // For live terminators, mark destination blocks
305 // live to preserve this control flow edges.
306 if (!isa<UncondBrInst>(I))
307 for (auto *Succ : I->successors())
308 markLive(Succ);
309 }
310 markLive(BB);
311}
312
313void AggressiveDeadCodeElimination::markLive(BasicBlock *BB) {
314 auto &BBInfo = BlockInfo[BB->getNumber()];
315 if (BBInfo.Live)
316 return;
317 LLVM_DEBUG(dbgs() << "mark block live: " << BB->getName() << '\n');
318 BBInfo.Live = true;
319 if (!BBInfo.CFLive) {
320 BBInfo.CFLive = true;
321 NewLiveBlocks.insert(BB);
322 }
323
324 // Mark unconditional branches at the end of live
325 // blocks as live since there is no work to do for them later
326 if (isa<UncondBrInst>(BB->back()))
327 markLive(&BB->back());
328}
329
330void AggressiveDeadCodeElimination::collectLiveScopes(const DILocalScope &LS) {
331 if (!AliveScopes.insert(&LS).second)
332 return;
333
334 if (isa<DISubprogram>(LS))
335 return;
336
337 // Tail-recurse through the scope chain.
338 collectLiveScopes(cast<DILocalScope>(*LS.getScope()));
339}
340
341void AggressiveDeadCodeElimination::collectLiveScopes(const DILocation &DL) {
342 // Even though DILocations are not scopes, shove them into AliveScopes so we
343 // don't revisit them.
344 if (!AliveScopes.insert(&DL).second)
345 return;
346
347 // Collect live scopes from the scope chain.
348 collectLiveScopes(*DL.getScope());
349
350 // Tail-recurse through the inlined-at chain.
351 if (const DILocation *IA = DL.getInlinedAt())
352 collectLiveScopes(*IA);
353}
354
355void AggressiveDeadCodeElimination::markPhiLive(PHINode *PN) {
356 auto &Info = getBlockInfo(PN->getParent());
357 // Only need to check this once per block.
358 if (Info.HasLivePhiNodes)
359 return;
360 Info.HasLivePhiNodes = true;
361
362 // If a predecessor block is not live, mark it as control-flow live
363 // which will trigger marking live branches upon which
364 // that block is control dependent.
365 for (auto *PredBB : predecessors(PN->getParent())) {
366 auto &Info = getBlockInfo(PredBB);
367 if (!Info.CFLive) {
368 Info.CFLive = true;
369 NewLiveBlocks.insert(PredBB);
370 }
371 }
372}
373
374void AggressiveDeadCodeElimination::markLiveBranchesFromControlDependences() {
375 if (BlocksWithDeadTerminators.empty())
376 return;
377
378 LLVM_DEBUG({
379 dbgs() << "new live blocks:\n";
380 for (auto *BB : NewLiveBlocks)
381 dbgs() << "\t" << BB->getName() << '\n';
382 dbgs() << "dead terminator blocks:\n";
383 for (auto *BB : BlocksWithDeadTerminators)
384 dbgs() << "\t" << BB->getName() << '\n';
385 });
386
387 // The dominance frontier of a live block X in the reverse
388 // control graph is the set of blocks upon which X is control
389 // dependent. The following sequence computes the set of blocks
390 // which currently have dead terminators that are control
391 // dependence sources of a block which is in NewLiveBlocks.
392
393 const SmallPtrSet<BasicBlock *, 16> BWDT(llvm::from_range,
394 BlocksWithDeadTerminators);
396 ReverseIDFCalculator IDFs(PDT);
397 IDFs.setDefiningBlocks(NewLiveBlocks);
398 IDFs.setLiveInBlocks(BWDT);
399 IDFs.calculate(IDFBlocks);
400 NewLiveBlocks.clear();
401
402 // Dead terminators which control live blocks are now marked live.
403 for (auto *BB : IDFBlocks) {
404 LLVM_DEBUG(dbgs() << "live control in: " << BB->getName() << '\n');
405 markLive(BB->getTerminator());
406 }
407}
408
409//===----------------------------------------------------------------------===//
410//
411// Routines to update the CFG and SSA information before removing dead code.
412//
413//===----------------------------------------------------------------------===//
414ADCEChanged AggressiveDeadCodeElimination::removeDeadInstructions() {
415 ADCEChanged Changed;
416 // Updates control and dataflow around dead blocks
417 Changed.ChangedControlFlow = updateDeadRegions();
418
419 // The inverse of the live set is the dead set. These are those instructions
420 // that have no side effects and do not influence the control flow or return
421 // value of the function, and may therefore be deleted safely.
422 // NOTE: We reuse the Worklist vector here for memory efficiency.
423 for (Instruction &I : llvm::reverse(instructions(F))) {
424 // With "RemoveDIs" debug-info stored in DbgVariableRecord objects,
425 // debug-info attached to this instruction, and drop any for scopes that
426 // aren't alive, like the rest of this loop does. Extending support to
427 // assignment tracking is future work.
428 for (DbgRecord &DR : make_early_inc_range(I.getDbgRecordRange())) {
429 // Avoid removing a DVR that is linked to instructions because it holds
430 // information about an existing store.
431 if (DbgVariableRecord *DVR = dyn_cast<DbgVariableRecord>(&DR);
432 DVR && DVR->isDbgAssign())
433 if (!at::getAssignmentInsts(DVR).empty())
434 continue;
435 if (AliveScopes.count(DR.getDebugLoc()->getScope()))
436 continue;
437 I.dropOneDbgRecord(&DR);
438 }
439
440 // Check if the instruction is alive.
441 if (isLive(&I))
442 continue;
443
444 Changed.ChangedNonDebugInstr = true;
445
446 // Prepare to delete.
447 Worklist.push_back(&I);
449 }
450
451 for (Instruction *&I : Worklist)
452 I->dropAllReferences();
453
454 for (Instruction *&I : Worklist) {
455 ++NumRemoved;
456 I->eraseFromParent();
457 }
458
459 Changed.ChangedAnything = Changed.ChangedControlFlow || !Worklist.empty();
460
461 return Changed;
462}
463
464// A dead region is the set of dead blocks with a common live post-dominator.
465bool AggressiveDeadCodeElimination::updateDeadRegions() {
466 LLVM_DEBUG({
467 dbgs() << "final dead terminator blocks: " << '\n';
468 for (auto *BB : BlocksWithDeadTerminators)
469 dbgs() << '\t' << BB->getName()
470 << (getBlockInfo(BB).Live ? " LIVE\n" : "\n");
471 });
472
473 // Don't compute the post ordering unless we needed it.
474 bool HavePostOrder = false;
475 bool Changed = false;
477
478 for (auto *BB : BlocksWithDeadTerminators) {
479 if (isa<UncondBrInst>(BB->back())) {
480 LiveInst.insert(&BB->back());
481 continue;
482 }
483
484 if (!HavePostOrder) {
485 computeReversePostOrder();
486 HavePostOrder = true;
487 }
488
489 // Add an unconditional branch to the successor closest to the
490 // end of the function which insures a path to the exit for each
491 // live edge.
492 BasicBlock *PreferredSucc = nullptr;
493 unsigned PreferredSuccPostOrder = 0;
494 for (auto *Succ : successors(BB)) {
495 unsigned SuccPostOrder = BlockInfo[Succ->getNumber()].PostOrder;
496 if (PreferredSuccPostOrder < SuccPostOrder) {
497 PreferredSucc = Succ;
498 PreferredSuccPostOrder = SuccPostOrder;
499 }
500 }
501 assert((PreferredSucc && PreferredSuccPostOrder > 0) &&
502 "Failed to find safe successor for dead branch");
503
504 // Collect removed successors to update the (Post)DominatorTrees.
505 SmallPtrSet<BasicBlock *, 4> RemovedSuccessors;
506 bool First = true;
507 for (auto *Succ : successors(BB)) {
508 if (!First || Succ != PreferredSucc) {
509 Succ->removePredecessor(BB);
510 RemovedSuccessors.insert(Succ);
511 } else
512 First = false;
513 }
514 makeUnconditional(BB, PreferredSucc);
515
516 // Inform the dominators about the deleted CFG edges.
517 for (auto *Succ : RemovedSuccessors) {
518 // It might have happened that the same successor appeared multiple times
519 // and the CFG edge wasn't really removed.
520 if (Succ != PreferredSucc) {
521 LLVM_DEBUG(dbgs() << "ADCE: (Post)DomTree edge enqueued for deletion"
522 << BB->getName() << " -> " << Succ->getName()
523 << "\n");
524 DeletedEdges.push_back({DominatorTree::Delete, BB, Succ});
525 }
526 }
527
528 NumBranchesRemoved += 1;
529 Changed = true;
530 }
531
532 if (!DeletedEdges.empty())
533 DomTreeUpdater(DT, &PDT, DomTreeUpdater::UpdateStrategy::Eager)
534 .applyUpdates(DeletedEdges);
535
536 return Changed;
537}
538
539// reverse top-sort order
540void AggressiveDeadCodeElimination::computeReversePostOrder() {
541 // This provides a post-order numbering of the reverse control flow graph
542 // Note that it is incomplete in the presence of infinite loops but we don't
543 // need numbers blocks which don't reach the end of the functions since
544 // all branches in those blocks are forced live.
545
546 // For each block without successors, extend the DFS from the block
547 // backward through the graph
548 SmallPtrSet<BasicBlock*, 16> Visited;
549 unsigned PostOrder = 0;
550 for (auto &BB : F) {
551 if (!succ_empty(&BB))
552 continue;
553 for (BasicBlock *Block : inverse_post_order_ext(&BB,Visited))
554 getBlockInfo(Block).PostOrder = PostOrder++;
555 }
556}
557
558void AggressiveDeadCodeElimination::makeUnconditional(BasicBlock *BB,
559 BasicBlock *Target) {
560 Instruction *PredTerm = BB->getTerminator();
561 // Collect the live debug info scopes attached to this instruction.
562 if (const DILocation *DL = PredTerm->getDebugLoc())
563 collectLiveScopes(*DL);
564
565 // Just mark live an existing unconditional branch
566 if (auto *BI = dyn_cast<UncondBrInst>(PredTerm)) {
567 BI->setSuccessor(Target);
568 LiveInst.insert(PredTerm);
569 return;
570 }
571 LLVM_DEBUG(dbgs() << "making unconditional " << BB->getName() << '\n');
572 NumBranchesRemoved += 1;
573 IRBuilder<> Builder(PredTerm);
574 auto *NewTerm = Builder.CreateBr(Target);
575 LiveInst.insert(NewTerm);
576 if (const DILocation *DL = PredTerm->getDebugLoc())
577 NewTerm->setDebugLoc(DL);
578 PredTerm->eraseFromParent();
579}
580
581//===----------------------------------------------------------------------===//
582//
583// Pass Manager integration code
584//
585//===----------------------------------------------------------------------===//
587 // ADCE does not need DominatorTree, but require DominatorTree here
588 // to update analysis if it is already available.
589 auto *DT = FAM.getCachedResult<DominatorTreeAnalysis>(F);
590 auto &PDT = FAM.getResult<PostDominatorTreeAnalysis>(F);
591 ADCEChanged Changed =
592 AggressiveDeadCodeElimination(F, DT, PDT).performDeadCodeElimination();
593 if (!Changed.ChangedAnything)
594 return PreservedAnalyses::all();
595
597 if (!Changed.ChangedControlFlow) {
599 if (!Changed.ChangedNonDebugInstr) {
600 // Only removing debug instructions does not affect MemorySSA.
601 //
602 // Therefore we preserve MemorySSA when only removing debug instructions
603 // since otherwise later passes may behave differently which then makes
604 // the presence of debug info affect code generation.
606 }
607 }
610
611 return PA;
612}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Expand Atomic instructions
static bool isAlwaysLive(Instruction *I)
This file builds on the ADT/GraphTraits.h file to build generic depth first graph iterator.
This is the interface for a simple mod/ref and alias analysis over globals.
This file defines the little GraphTraits<X> template class that should be specialized by classes that...
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
This header defines various interfaces for pass management in LLVM.
This defines the Use class.
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
This file exposes an interface to building/using memory SSA to walk memory instructions using a use/d...
FunctionAnalysisManager FAM
This file builds on the ADT/GraphTraits.h file to build a generic graph post order iterator.
This file implements a set that has insertion order iteration characteristics.
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
Definition Statistic.h:171
#define LLVM_DEBUG(...)
Definition Debug.h:119
static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, const llvm::StringTable &StandardNames, VectorLibrary VecLib)
Initialize the set of available library functions based on the specified target triple.
unsigned getNumber() const
Definition BasicBlock.h:95
const Instruction & back() const
Definition BasicBlock.h:471
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction; assumes that the block is well-formed.
Definition BasicBlock.h:237
Represents analyses that only rely on functions' control flow.
Definition Analysis.h:73
Analysis pass which computes a DominatorTree.
Definition Dominators.h:241
DomTreeNodeBase< NodeT > * getRootNode()
getRootNode - This returns the entry node for the CFG of the function.
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
LLVM_ABI InstListType::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
An analysis that produces MemorySSA for a function.
Definition MemorySSA.h:922
Analysis pass which computes a PostDominatorTree.
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition Analysis.h:118
PreservedAnalyses & preserveSet()
Mark an analysis set as preserved.
Definition Analysis.h:151
PreservedAnalyses & preserve()
Mark an analysis as preserved.
Definition Analysis.h:132
void reserve(size_type NewNumEntries)
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
void resize(size_type N)
void push_back(const T &Elt)
op_range operands()
Definition User.h:267
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
Definition Value.cpp:319
LLVM_ABI void dump() const
Support for debugging, callable in GDB: V->dump()
const ParentTy * getParent() const
Definition ilist_node.h:34
Changed
@ BasicBlock
Various leaf nodes.
Definition ISDOpcodes.h:83
AssignmentInstRange getAssignmentInsts(DIAssignID *ID)
Return a range of instructions (typically just one) that have ID as an attachment.
Definition DebugInfo.h:190
bool empty() const
Definition BasicBlock.h:101
friend class Instruction
Iterator for Instructions in a `BasicBlock.
Definition BasicBlock.h:73
This is an optimization pass for GlobalISel generic memory operations.
bool succ_empty(const Instruction *I)
Definition CFG.h:141
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
LLVM_ABI void salvageDebugInfo(const MachineRegisterInfo &MRI, MachineInstr &MI)
Assuming the instruction MI is going to be deleted, attempt to salvage debug users of MI by writing t...
Definition Utils.cpp:1677
auto successors(const MachineBasicBlock *BB)
constexpr from_range_t from_range
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
Definition STLExtras.h:649
auto inverse_post_order_ext(const T &G, SetType &S)
auto reverse(ContainerTy &&C)
Definition STLExtras.h:408
IDFCalculator< true > ReverseIDFCalculator
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:209
IRBuilder(LLVMContext &, FolderTy, InserterTy) -> IRBuilder< FolderTy, InserterTy >
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Definition Casting.h:547
@ Global
Append to llvm.global_dtors.
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
Definition ModRef.h:74
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
auto predecessors(const MachineBasicBlock *BB)
StringRef getInstrProfValueProfFuncName()
Return the name profile runtime entry point to do value profiling for a given site.
Definition InstrProf.h:112
iterator_range< typename GraphTraits< GraphType >::ChildIteratorType > children(const typename GraphTraits< GraphType >::NodeRef &G)
iterator_range< df_iterator< T > > depth_first(const T &G)
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
LLVM_ABI void FindFunctionBackedges(const Function &F, SmallVectorImpl< std::pair< const BasicBlock *, const BasicBlock * > > &Result)
Analyze the specified function to find all of the loop backedges in the function and return them.
Definition CFG.cpp:36
LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &)
Definition ADCE.cpp:586