LLVM 24.0.0git
AArch64PromoteConstant.cpp
Go to the documentation of this file.
1//==- AArch64PromoteConstant.cpp - Promote constant to global for AArch64 --==//
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 AArch64PromoteConstant pass which promotes constants
10// to global variables when this is likely to be more efficient. Currently only
11// types related to constant vector (i.e., constant vector, array of constant
12// vectors, constant structure with a constant vector field, etc.) are promoted
13// to global variables. Constant vectors are likely to be lowered in target
14// constant pool during instruction selection already; therefore, the access
15// will remain the same (memory load), but the structure types are not split
16// into different constant pool accesses for each field. A bonus side effect is
17// that created globals may be merged by the global merge pass.
18//
19// FIXME: This pass may be useful for other targets too.
20//===----------------------------------------------------------------------===//
21
22#include "AArch64.h"
23#include "AArch64Subtarget.h"
24#include "llvm/ADT/DenseMap.h"
26#include "llvm/ADT/Statistic.h"
27#include "llvm/IR/BasicBlock.h"
28#include "llvm/IR/Constant.h"
29#include "llvm/IR/Constants.h"
30#include "llvm/IR/Dominators.h"
31#include "llvm/IR/Function.h"
32#include "llvm/IR/GlobalValue.h"
34#include "llvm/IR/IRBuilder.h"
36#include "llvm/IR/Instruction.h"
39#include "llvm/IR/Module.h"
40#include "llvm/IR/Type.h"
42#include "llvm/Pass.h"
44#include "llvm/Support/Debug.h"
46#include <cassert>
47#include <utility>
48
49using namespace llvm;
50
51#define DEBUG_TYPE "aarch64-promote-const"
52
53STATISTIC(NumPromoted, "Number of promoted constants");
54STATISTIC(NumPromotedUses, "Number of promoted constants uses");
55
56//===----------------------------------------------------------------------===//
57// AArch64PromoteConstant
58//===----------------------------------------------------------------------===//
59
60namespace {
61
62/// Promotes interesting constant into global variables.
63/// The motivating example is:
64/// static const uint16_t TableA[32] = {
65/// 41944, 40330, 38837, 37450, 36158, 34953, 33826, 32768,
66/// 31776, 30841, 29960, 29128, 28340, 27595, 26887, 26215,
67/// 25576, 24967, 24386, 23832, 23302, 22796, 22311, 21846,
68/// 21400, 20972, 20561, 20165, 19785, 19419, 19066, 18725,
69/// };
70///
71/// uint8x16x4_t LoadStatic(void) {
72/// uint8x16x4_t ret;
73/// ret.val[0] = vld1q_u16(TableA + 0);
74/// ret.val[1] = vld1q_u16(TableA + 8);
75/// ret.val[2] = vld1q_u16(TableA + 16);
76/// ret.val[3] = vld1q_u16(TableA + 24);
77/// return ret;
78/// }
79///
80/// The constants in this example are folded into the uses. Thus, 4 different
81/// constants are created.
82///
83/// As their type is vector the cheapest way to create them is to load them
84/// for the memory.
85///
86/// Therefore the final assembly final has 4 different loads. With this pass
87/// enabled, only one load is issued for the constants.
88class AArch64PromoteConstant : public ModulePass {
89public:
90 struct PromotedConstant {
91 bool ShouldConvert = false;
92 GlobalVariable *GV = nullptr;
93 };
94 using PromotionCacheTy = SmallDenseMap<Constant *, PromotedConstant, 16>;
95
96 struct UpdateRecord {
97 Constant *C;
98 Instruction *User;
99 unsigned Op;
100
101 UpdateRecord(Constant *C, Instruction *User, unsigned Op)
102 : C(C), User(User), Op(Op) {}
103 };
104
105 static char ID;
106
107 AArch64PromoteConstant() : ModulePass(ID) {}
108
109 StringRef getPassName() const override { return "AArch64 Promote Constant"; }
110
111 /// Iterate over the functions and promote the interesting constants into
112 /// global variables with module scope.
113 bool runOnModule(Module &M) override {
114 LLVM_DEBUG(dbgs() << getPassName() << '\n');
115 if (skipModule(M))
116 return false;
117 bool Changed = false;
118 PromotionCacheTy PromotionCache;
119 for (auto &MF : M) {
120 Changed |= runOnFunction(MF, PromotionCache);
121 }
122 return Changed;
123 }
124
125private:
126 /// Look for interesting constants used within the given function.
127 /// Promote them into global variables, load these global variables within
128 /// the related function, so that the number of inserted load is minimal.
129 bool runOnFunction(Function &F, PromotionCacheTy &PromotionCache);
130
131 // This transformation requires dominator info
132 void getAnalysisUsage(AnalysisUsage &AU) const override {
133 AU.setPreservesCFG();
134 AU.addRequired<DominatorTreeWrapperPass>();
135 }
136
137 /// Type to store a list of Uses.
139 /// Map an insertion point to all the uses it dominates.
140 using InsertionPoints = DenseMap<Instruction *, Uses>;
141
142 /// Find the closest point that dominates the given Use.
143 Instruction *findInsertionPoint(Instruction &User, unsigned OpNo);
144
145 /// Check if the given insertion point is dominated by an existing
146 /// insertion point.
147 /// If true, the given use is added to the list of dominated uses for
148 /// the related existing point.
149 /// \param NewPt the insertion point to be checked
150 /// \param User the user of the constant
151 /// \param OpNo the operand number of the use
152 /// \param InsertPts existing insertion points
153 /// \pre NewPt and all instruction in InsertPts belong to the same function
154 /// \return true if one of the insertion point in InsertPts dominates NewPt,
155 /// false otherwise
156 bool isDominated(Instruction *NewPt, Instruction *User, unsigned OpNo,
157 InsertionPoints &InsertPts);
158
159 /// Check if the given insertion point can be merged with an existing
160 /// insertion point in a common dominator.
161 /// If true, the given use is added to the list of the created insertion
162 /// point.
163 /// \param NewPt the insertion point to be checked
164 /// \param User the user of the constant
165 /// \param OpNo the operand number of the use
166 /// \param InsertPts existing insertion points
167 /// \pre NewPt and all instruction in InsertPts belong to the same function
168 /// \pre isDominated returns false for the exact same parameters.
169 /// \return true if it exists an insertion point in InsertPts that could
170 /// have been merged with NewPt in a common dominator,
171 /// false otherwise
172 bool tryAndMerge(Instruction *NewPt, Instruction *User, unsigned OpNo,
173 InsertionPoints &InsertPts);
174
175 /// Compute the minimal insertion points to dominates all the interesting
176 /// uses of value.
177 /// Insertion points are group per function and each insertion point
178 /// contains a list of all the uses it dominates within the related function
179 /// \param User the user of the constant
180 /// \param OpNo the operand number of the constant
181 /// \param[out] InsertPts output storage of the analysis
182 void computeInsertionPoint(Instruction *User, unsigned OpNo,
183 InsertionPoints &InsertPts);
184
185 /// Insert a definition of a new global variable at each point contained in
186 /// InsPtsPerFunc and update the related uses (also contained in
187 /// InsPtsPerFunc).
188 void insertDefinitions(Function &F, GlobalVariable &GV,
189 InsertionPoints &InsertPts);
190
191 /// Do the constant promotion indicated by the Updates records, keeping track
192 /// of globals in PromotionCache.
193 void promoteConstants(Function &F, SmallVectorImpl<UpdateRecord> &Updates,
194 PromotionCacheTy &PromotionCache);
195
196 /// Transfer the list of dominated uses of IPI to NewPt in InsertPts.
197 /// Append Use to this list and delete the entry of IPI in InsertPts.
198 static void appendAndTransferDominatedUses(Instruction *NewPt,
199 Instruction *User, unsigned OpNo,
201 InsertionPoints &InsertPts) {
202 // Record the dominated use.
203 IPI->second.emplace_back(User, OpNo);
204 // Transfer the dominated uses of IPI to NewPt
205 // Inserting into the DenseMap may invalidate existing iterator.
206 // Keep a copy of the key to find the iterator to erase. Keep a copy of the
207 // value so that we don't have to dereference IPI->second.
208 Instruction *OldInstr = IPI->first;
209 Uses OldUses = std::move(IPI->second);
210 InsertPts[NewPt] = std::move(OldUses);
211 // Erase IPI.
212 InsertPts.erase(OldInstr);
213 }
214};
215
216} // end anonymous namespace
217
218char AArch64PromoteConstant::ID = 0;
219
220INITIALIZE_PASS_BEGIN(AArch64PromoteConstant, "aarch64-promote-const",
221 "AArch64 Promote Constant Pass", false, false)
223INITIALIZE_PASS_END(AArch64PromoteConstant, "aarch64-promote-const",
224 "AArch64 Promote Constant Pass", false, false)
225
227 return new AArch64PromoteConstant();
228}
229
230/// Check if the given type uses a vector type.
231static bool isConstantUsingVectorTy(const Type *CstTy) {
232 if (CstTy->isVectorTy())
233 return true;
234 if (CstTy->isStructTy()) {
235 for (unsigned EltIdx = 0, EndEltIdx = CstTy->getStructNumElements();
236 EltIdx < EndEltIdx; ++EltIdx)
238 return true;
239 } else if (CstTy->isArrayTy())
241 return false;
242}
243
244// Returns true if \p C contains only ConstantData leaves and no global values,
245// block addresses or constant expressions. Traverses ConstantAggregates.
247 if (isa<ConstantData>(C))
248 return true;
249
251 return false;
252
253 return all_of(C->operands(), [](const Use &U) {
254 return containsOnlyConstantData(cast<Constant>(&U));
255 });
256}
257
258/// Check if the given use (Instruction + OpIdx) of Cst should be converted into
259/// a load of a global variable initialized with Cst.
260/// A use should be converted if it is legal to do so.
261/// For instance, it is not legal to turn the mask operand of a shuffle vector
262/// into a load of a global variable.
263static bool shouldConvertUse(const Constant *Cst, const Instruction *Instr,
264 unsigned OpIdx) {
265 // shufflevector instruction expects a const for the mask argument, i.e., the
266 // third argument. Do not promote this use in that case.
267 if (isa<const ShuffleVectorInst>(Instr) && OpIdx == 2)
268 return false;
269
270 // extractvalue instruction expects a const idx.
271 if (isa<const ExtractValueInst>(Instr) && OpIdx > 0)
272 return false;
273
274 // extractvalue instruction expects a const idx.
275 if (isa<const InsertValueInst>(Instr) && OpIdx > 1)
276 return false;
277
278 if (isa<const AllocaInst>(Instr) && OpIdx > 0)
279 return false;
280
281 // Alignment argument must be constant.
282 if (isa<const LoadInst>(Instr) && OpIdx > 0)
283 return false;
284
285 // Alignment argument must be constant.
286 if (isa<const StoreInst>(Instr) && OpIdx > 1)
287 return false;
288
289 // Index must be constant.
290 if (isa<const GetElementPtrInst>(Instr) && OpIdx > 0)
291 return false;
292
293 // Personality function and filters must be constant.
294 // Give up on that instruction.
295 if (isa<const LandingPadInst>(Instr))
296 return false;
297
298 // Switch instruction expects constants to compare to.
299 if (isa<const SwitchInst>(Instr))
300 return false;
301
302 // Expected address must be a constant.
303 if (isa<const IndirectBrInst>(Instr))
304 return false;
305
306 // Do not mess with intrinsics.
307 if (isa<const IntrinsicInst>(Instr))
308 return false;
309
310 // Do not mess with inline asm.
311 const CallInst *CI = dyn_cast<const CallInst>(Instr);
312 return !(CI && CI->isInlineAsm());
313}
314
315/// Check if the given Cst should be converted into
316/// a load of a global variable initialized with Cst.
317/// A constant should be converted if it is likely that the materialization of
318/// the constant will be tricky. Thus, we give up on zero or undef values.
319///
320/// \todo Currently, accept only vector related types.
321/// Also we give up on all simple vector type to keep the existing
322/// behavior. Otherwise, we should push here all the check of the lowering of
323/// BUILD_VECTOR. By giving up, we lose the potential benefit of merging
324/// constant via global merge and the fact that the same constant is stored
325/// only once with this method (versus, as many function that uses the constant
326/// for the regular approach, even for float).
327/// Again, the simplest solution would be to promote every
328/// constant and rematerialize them when they are actually cheap to create.
329static bool shouldConvertImpl(const Constant *Cst) {
330 if (isa<const UndefValue>(Cst))
331 return false;
332
333 // FIXME: In some cases, it may be interesting to promote in memory
334 // a zero initialized constant.
335 // E.g., when the type of Cst require more instructions than the
336 // adrp/add/load sequence or when this sequence can be shared by several
337 // instances of Cst.
338 // Ideally, we could promote this into a global and rematerialize the constant
339 // when it was a bad idea.
340 if (Cst->isNullValue())
341 return false;
342
343 // Globals cannot be or contain scalable vectors.
344 if (Cst->getType()->isScalableTy())
345 return false;
346
347 const AArch64Options &CLOpts =
348 Cst->getContext().getLibraryOptions().get<AArch64Options>();
349 if (CLOpts.stress_promote_const)
350 return true;
351
352 // FIXME: see function \todo
353 if (Cst->getType()->isVectorTy())
354 return false;
355 return isConstantUsingVectorTy(Cst->getType());
356}
357
358static bool
360 AArch64PromoteConstant::PromotionCacheTy &PromotionCache) {
361 auto Converted = PromotionCache.insert(
362 std::make_pair(&C, AArch64PromoteConstant::PromotedConstant()));
363 if (Converted.second)
364 Converted.first->second.ShouldConvert = shouldConvertImpl(&C);
365 return Converted.first->second.ShouldConvert;
366}
367
368Instruction *AArch64PromoteConstant::findInsertionPoint(Instruction &User,
369 unsigned OpNo) {
370 // If this user is a phi, the insertion point is in the related
371 // incoming basic block.
372 if (PHINode *PhiInst = dyn_cast<PHINode>(&User))
373 return PhiInst->getIncomingBlock(OpNo)->getTerminator();
374
375 return &User;
376}
377
378bool AArch64PromoteConstant::isDominated(Instruction *NewPt, Instruction *User,
379 unsigned OpNo,
380 InsertionPoints &InsertPts) {
381 DominatorTree &DT = getAnalysis<DominatorTreeWrapperPass>(
382 *NewPt->getParent()->getParent()).getDomTree();
383
384 // Traverse all the existing insertion points and check if one is dominating
385 // NewPt. If it is, remember that.
386 for (auto &IPI : InsertPts) {
387 if (NewPt == IPI.first || DT.dominates(IPI.first, NewPt) ||
388 // When IPI.first is a terminator instruction, DT may think that
389 // the result is defined on the edge.
390 // Here we are testing the insertion point, not the definition.
391 (IPI.first->getParent() != NewPt->getParent() &&
392 DT.dominates(IPI.first->getParent(), NewPt->getParent()))) {
393 // No need to insert this point. Just record the dominated use.
394 LLVM_DEBUG(dbgs() << "Insertion point dominated by:\n");
395 LLVM_DEBUG(IPI.first->print(dbgs()));
396 LLVM_DEBUG(dbgs() << '\n');
397 IPI.second.emplace_back(User, OpNo);
398 return true;
399 }
400 }
401 return false;
402}
403
404bool AArch64PromoteConstant::tryAndMerge(Instruction *NewPt, Instruction *User,
405 unsigned OpNo,
406 InsertionPoints &InsertPts) {
407 DominatorTree &DT = getAnalysis<DominatorTreeWrapperPass>(
408 *NewPt->getParent()->getParent()).getDomTree();
409 BasicBlock *NewBB = NewPt->getParent();
410
411 // Traverse all the existing insertion point and check if one is dominated by
412 // NewPt and thus useless or can be combined with NewPt into a common
413 // dominator.
414 for (InsertionPoints::iterator IPI = InsertPts.begin(),
415 EndIPI = InsertPts.end();
416 IPI != EndIPI; ++IPI) {
417 BasicBlock *CurBB = IPI->first->getParent();
418 if (NewBB == CurBB) {
419 // Instructions are in the same block.
420 // By construction, NewPt is dominating the other.
421 // Indeed, isDominated returned false with the exact same arguments.
422 LLVM_DEBUG(dbgs() << "Merge insertion point with:\n");
423 LLVM_DEBUG(IPI->first->print(dbgs()));
424 LLVM_DEBUG(dbgs() << "\nat considered insertion point.\n");
425 appendAndTransferDominatedUses(NewPt, User, OpNo, IPI, InsertPts);
426 return true;
427 }
428
429 // Look for a common dominator
430 BasicBlock *CommonDominator = DT.findNearestCommonDominator(NewBB, CurBB);
431 // If none exists, we cannot merge these two points.
432 if (!CommonDominator)
433 continue;
434
435 if (CommonDominator != NewBB) {
436 // By construction, the CommonDominator cannot be CurBB.
437 assert(CommonDominator != CurBB &&
438 "Instruction has not been rejected during isDominated check!");
439 // Take the last instruction of the CommonDominator as insertion point
440 NewPt = CommonDominator->getTerminator();
441 }
442 // else, CommonDominator is the block of NewBB, hence NewBB is the last
443 // possible insertion point in that block.
444 LLVM_DEBUG(dbgs() << "Merge insertion point with:\n");
445 LLVM_DEBUG(IPI->first->print(dbgs()));
446 LLVM_DEBUG(dbgs() << '\n');
447 LLVM_DEBUG(NewPt->print(dbgs()));
448 LLVM_DEBUG(dbgs() << '\n');
449 appendAndTransferDominatedUses(NewPt, User, OpNo, IPI, InsertPts);
450 return true;
451 }
452 return false;
453}
454
455void AArch64PromoteConstant::computeInsertionPoint(
456 Instruction *User, unsigned OpNo, InsertionPoints &InsertPts) {
457 LLVM_DEBUG(dbgs() << "Considered use, opidx " << OpNo << ":\n");
458 LLVM_DEBUG(User->print(dbgs()));
459 LLVM_DEBUG(dbgs() << '\n');
460
461 Instruction *InsertionPoint = findInsertionPoint(*User, OpNo);
462
463 LLVM_DEBUG(dbgs() << "Considered insertion point:\n");
464 LLVM_DEBUG(InsertionPoint->print(dbgs()));
465 LLVM_DEBUG(dbgs() << '\n');
466
467 if (isDominated(InsertionPoint, User, OpNo, InsertPts))
468 return;
469 // This insertion point is useful, check if we can merge some insertion
470 // point in a common dominator or if NewPt dominates an existing one.
471 if (tryAndMerge(InsertionPoint, User, OpNo, InsertPts))
472 return;
473
474 LLVM_DEBUG(dbgs() << "Keep considered insertion point\n");
475
476 // It is definitely useful by its own
477 InsertPts[InsertionPoint].emplace_back(User, OpNo);
478}
479
481 AArch64PromoteConstant::PromotedConstant &PC) {
482 assert(PC.ShouldConvert &&
483 "Expected that we should convert this to a global");
484 if (PC.GV)
485 return;
486 PC.GV = new GlobalVariable(
487 *F.getParent(), C.getType(), true, GlobalValue::InternalLinkage, nullptr,
488 "_PromotedConst", nullptr, GlobalVariable::NotThreadLocal);
489 PC.GV->setInitializer(&C);
490 LLVM_DEBUG(dbgs() << "Global replacement: ");
491 LLVM_DEBUG(PC.GV->print(dbgs()));
492 LLVM_DEBUG(dbgs() << '\n');
493 ++NumPromoted;
494}
495
496void AArch64PromoteConstant::insertDefinitions(Function &F,
497 GlobalVariable &PromotedGV,
498 InsertionPoints &InsertPts) {
499#ifndef NDEBUG
500 // Do more checking for debug purposes.
501 DominatorTree &DT = getAnalysis<DominatorTreeWrapperPass>(F).getDomTree();
502#endif
503 assert(!InsertPts.empty() && "Empty uses does not need a definition");
504
505 for (const auto &IPI : InsertPts) {
506 // Create the load of the global variable.
507 IRBuilder<> Builder(IPI.first);
508 LoadInst *LoadedCst =
509 Builder.CreateLoad(PromotedGV.getValueType(), &PromotedGV);
510 LLVM_DEBUG(dbgs() << "**********\n");
511 LLVM_DEBUG(dbgs() << "New def: ");
512 LLVM_DEBUG(LoadedCst->print(dbgs()));
513 LLVM_DEBUG(dbgs() << '\n');
514
515 // Update the dominated uses.
516 for (auto Use : IPI.second) {
517#ifndef NDEBUG
518 assert(DT.dominates(LoadedCst,
519 findInsertionPoint(*Use.first, Use.second)) &&
520 "Inserted definition does not dominate all its uses!");
521#endif
522 LLVM_DEBUG({
523 dbgs() << "Use to update " << Use.second << ":";
524 Use.first->print(dbgs());
525 dbgs() << '\n';
526 });
527 Use.first->setOperand(Use.second, LoadedCst);
528 ++NumPromotedUses;
529 }
530 }
531}
532
533void AArch64PromoteConstant::promoteConstants(
534 Function &F, SmallVectorImpl<UpdateRecord> &Updates,
535 PromotionCacheTy &PromotionCache) {
536 // Promote the constants.
537 for (auto U = Updates.begin(), E = Updates.end(); U != E;) {
538 LLVM_DEBUG(dbgs() << "** Compute insertion points **\n");
539 auto First = U;
540 Constant *C = First->C;
541 InsertionPoints InsertPts;
542 do {
543 computeInsertionPoint(U->User, U->Op, InsertPts);
544 } while (++U != E && U->C == C);
545
546 auto &Promotion = PromotionCache[C];
547 ensurePromotedGV(F, *C, Promotion);
548 insertDefinitions(F, *Promotion.GV, InsertPts);
549 }
550}
551
552bool AArch64PromoteConstant::runOnFunction(Function &F,
553 PromotionCacheTy &PromotionCache) {
554 // Look for instructions using constant vector. Promote that constant to a
555 // global variable. Create as few loads of this variable as possible and
556 // update the uses accordingly.
558 for (Instruction &I : instructions(&F)) {
559 // Traverse the operand, looking for constant vectors. Replace them by a
560 // load of a global variable of constant vector type.
561 for (Use &U : I.operands()) {
563 // There is no point in promoting global values as they are already
564 // global. Do not promote constants containing constant expression, global
565 // values or blockaddresses either, as they may require some code
566 // expansion.
567 if (!Cst || isa<GlobalValue>(Cst) || !containsOnlyConstantData(Cst))
568 continue;
569
570 // Check if this constant is worth promoting.
571 if (!shouldConvert(*Cst, PromotionCache))
572 continue;
573
574 // Check if this use should be promoted.
575 unsigned OpNo = &U - I.op_begin();
576 if (!shouldConvertUse(Cst, &I, OpNo))
577 continue;
578
579 Updates.emplace_back(Cst, &I, OpNo);
580 }
581 }
582
583 if (Updates.empty())
584 return false;
585
586 promoteConstants(F, Updates, PromotionCache);
587 return true;
588}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static bool isConstantUsingVectorTy(const Type *CstTy)
Check if the given type uses a vector type.
static bool containsOnlyConstantData(const Constant *C)
static void ensurePromotedGV(Function &F, Constant &C, AArch64PromoteConstant::PromotedConstant &PC)
static bool shouldConvert(Constant &C, AArch64PromoteConstant::PromotionCacheTy &PromotionCache)
static bool shouldConvertImpl(const Constant *Cst)
Check if the given Cst should be converted into a load of a global variable initialized with Cst.
static bool shouldConvertUse(const Constant *Cst, const Instruction *Instr, unsigned OpIdx)
Check if the given use (Instruction + OpIdx) of Cst should be converted into a load of a global varia...
Expand Atomic instructions
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
This file defines the DenseMap class.
static bool runOnFunction(Function &F, bool PostInlining)
Module.h This file contains the declarations for the Module class.
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
#define INITIALIZE_PASS_DEPENDENCY(depName)
Definition PassSupport.h:42
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition PassSupport.h:44
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
Definition PassSupport.h:39
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
AnalysisUsage & addRequired()
LLVM_ABI void setPreservesCFG()
This function should be called by the pass, iff they do not:
Definition Pass.cpp:280
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction; assumes that the block is well-formed.
Definition BasicBlock.h:237
bool isInlineAsm() const
Check if this call is an inline asm statement.
This class represents a function call, abstracting a target machine's calling convention.
This is an important base class in LLVM.
Definition Constant.h:44
bool isNullValue() const
Return true if this is the value that would be returned by getNullValue.
Definition Constant.h:65
DenseMapIterator< KeyT, ValueT, KeyInfoT, BucketT > iterator
Definition DenseMap.h:678
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Definition DenseMap.h:827
Legacy analysis pass which computes a DominatorTree.
Definition Dominators.h:277
LLVM_ABI Instruction * findNearestCommonDominator(Instruction *I1, Instruction *I2) const
Find the nearest instruction I that dominates both I1 and I2, in the sense that a result produced bef...
LLVM_ABI bool dominates(const BasicBlock *BB, const Use &U) const
Return true if the (end of the) basic block BB dominates the use U.
@ InternalLinkage
Rename collisions when linking (static functions).
Definition GlobalValue.h:60
Type * getValueType() const
LLVM_ABI void setInitializer(Constant *InitVal)
setInitializer - Sets the initializer for this global variable, removing any existing initializer if ...
Definition Globals.cpp:613
LLVM_ABI cl::LibraryOptionsContext & getLibraryOptions() const
The library options this context reads in place of their process-wide values.
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
Definition Pass.h:253
reference emplace_back(ArgTypes &&... Args)
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
LLVM_ABI Type * getStructElementType(unsigned N) const
bool isVectorTy() const
True if this is an instance of VectorType.
Definition Type.h:283
bool isArrayTy() const
True if this is an instance of ArrayType.
Definition Type.h:274
Type * getArrayElementType() const
Definition Type.h:420
LLVM_ABI unsigned getStructNumElements() const
bool isStructTy() const
True if this is an instance of StructType.
Definition Type.h:271
LLVM_ABI bool isScalableTy() const
Return true if this is a type whose size is a known multiple of vscale.
Definition Type.cpp:61
A Use represents the edge between a Value definition and its users.
Definition Use.h:35
Type * getType() const
All values are typed, get the type of this value.
Definition Value.h:257
LLVM_ABI void print(raw_ostream &O, bool IsForDebug=false) const
Implement operator<< on Value.
LLVMContext & getContext() const
All values hold a context through their type.
Definition Value.h:260
const ParentTy * getParent() const
Definition ilist_node.h:34
Changed
@ BasicBlock
Various leaf nodes.
Definition ISDOpcodes.h:83
@ User
could "use" a pointer
NodeAddr< UseNode * > Use
Definition RDFGraph.h:385
friend class Instruction
Iterator for Instructions in a `BasicBlock.
Definition BasicBlock.h:73
This is an optimization pass for GlobalISel generic memory operations.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1755
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 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
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
Definition ModRef.h:74
ModulePass * createAArch64PromoteConstantPass()