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 if (AArch64Options::Global.stress_promote_const)
348 return true;
349
350 // FIXME: see function \todo
351 if (Cst->getType()->isVectorTy())
352 return false;
353 return isConstantUsingVectorTy(Cst->getType());
354}
355
356static bool
358 AArch64PromoteConstant::PromotionCacheTy &PromotionCache) {
359 auto Converted = PromotionCache.insert(
360 std::make_pair(&C, AArch64PromoteConstant::PromotedConstant()));
361 if (Converted.second)
362 Converted.first->second.ShouldConvert = shouldConvertImpl(&C);
363 return Converted.first->second.ShouldConvert;
364}
365
366Instruction *AArch64PromoteConstant::findInsertionPoint(Instruction &User,
367 unsigned OpNo) {
368 // If this user is a phi, the insertion point is in the related
369 // incoming basic block.
370 if (PHINode *PhiInst = dyn_cast<PHINode>(&User))
371 return PhiInst->getIncomingBlock(OpNo)->getTerminator();
372
373 return &User;
374}
375
376bool AArch64PromoteConstant::isDominated(Instruction *NewPt, Instruction *User,
377 unsigned OpNo,
378 InsertionPoints &InsertPts) {
379 DominatorTree &DT = getAnalysis<DominatorTreeWrapperPass>(
380 *NewPt->getParent()->getParent()).getDomTree();
381
382 // Traverse all the existing insertion points and check if one is dominating
383 // NewPt. If it is, remember that.
384 for (auto &IPI : InsertPts) {
385 if (NewPt == IPI.first || DT.dominates(IPI.first, NewPt) ||
386 // When IPI.first is a terminator instruction, DT may think that
387 // the result is defined on the edge.
388 // Here we are testing the insertion point, not the definition.
389 (IPI.first->getParent() != NewPt->getParent() &&
390 DT.dominates(IPI.first->getParent(), NewPt->getParent()))) {
391 // No need to insert this point. Just record the dominated use.
392 LLVM_DEBUG(dbgs() << "Insertion point dominated by:\n");
393 LLVM_DEBUG(IPI.first->print(dbgs()));
394 LLVM_DEBUG(dbgs() << '\n');
395 IPI.second.emplace_back(User, OpNo);
396 return true;
397 }
398 }
399 return false;
400}
401
402bool AArch64PromoteConstant::tryAndMerge(Instruction *NewPt, Instruction *User,
403 unsigned OpNo,
404 InsertionPoints &InsertPts) {
405 DominatorTree &DT = getAnalysis<DominatorTreeWrapperPass>(
406 *NewPt->getParent()->getParent()).getDomTree();
407 BasicBlock *NewBB = NewPt->getParent();
408
409 // Traverse all the existing insertion point and check if one is dominated by
410 // NewPt and thus useless or can be combined with NewPt into a common
411 // dominator.
412 for (InsertionPoints::iterator IPI = InsertPts.begin(),
413 EndIPI = InsertPts.end();
414 IPI != EndIPI; ++IPI) {
415 BasicBlock *CurBB = IPI->first->getParent();
416 if (NewBB == CurBB) {
417 // Instructions are in the same block.
418 // By construction, NewPt is dominating the other.
419 // Indeed, isDominated returned false with the exact same arguments.
420 LLVM_DEBUG(dbgs() << "Merge insertion point with:\n");
421 LLVM_DEBUG(IPI->first->print(dbgs()));
422 LLVM_DEBUG(dbgs() << "\nat considered insertion point.\n");
423 appendAndTransferDominatedUses(NewPt, User, OpNo, IPI, InsertPts);
424 return true;
425 }
426
427 // Look for a common dominator
428 BasicBlock *CommonDominator = DT.findNearestCommonDominator(NewBB, CurBB);
429 // If none exists, we cannot merge these two points.
430 if (!CommonDominator)
431 continue;
432
433 if (CommonDominator != NewBB) {
434 // By construction, the CommonDominator cannot be CurBB.
435 assert(CommonDominator != CurBB &&
436 "Instruction has not been rejected during isDominated check!");
437 // Take the last instruction of the CommonDominator as insertion point
438 NewPt = CommonDominator->getTerminator();
439 }
440 // else, CommonDominator is the block of NewBB, hence NewBB is the last
441 // possible insertion point in that block.
442 LLVM_DEBUG(dbgs() << "Merge insertion point with:\n");
443 LLVM_DEBUG(IPI->first->print(dbgs()));
444 LLVM_DEBUG(dbgs() << '\n');
445 LLVM_DEBUG(NewPt->print(dbgs()));
446 LLVM_DEBUG(dbgs() << '\n');
447 appendAndTransferDominatedUses(NewPt, User, OpNo, IPI, InsertPts);
448 return true;
449 }
450 return false;
451}
452
453void AArch64PromoteConstant::computeInsertionPoint(
454 Instruction *User, unsigned OpNo, InsertionPoints &InsertPts) {
455 LLVM_DEBUG(dbgs() << "Considered use, opidx " << OpNo << ":\n");
456 LLVM_DEBUG(User->print(dbgs()));
457 LLVM_DEBUG(dbgs() << '\n');
458
459 Instruction *InsertionPoint = findInsertionPoint(*User, OpNo);
460
461 LLVM_DEBUG(dbgs() << "Considered insertion point:\n");
462 LLVM_DEBUG(InsertionPoint->print(dbgs()));
463 LLVM_DEBUG(dbgs() << '\n');
464
465 if (isDominated(InsertionPoint, User, OpNo, InsertPts))
466 return;
467 // This insertion point is useful, check if we can merge some insertion
468 // point in a common dominator or if NewPt dominates an existing one.
469 if (tryAndMerge(InsertionPoint, User, OpNo, InsertPts))
470 return;
471
472 LLVM_DEBUG(dbgs() << "Keep considered insertion point\n");
473
474 // It is definitely useful by its own
475 InsertPts[InsertionPoint].emplace_back(User, OpNo);
476}
477
479 AArch64PromoteConstant::PromotedConstant &PC) {
480 assert(PC.ShouldConvert &&
481 "Expected that we should convert this to a global");
482 if (PC.GV)
483 return;
484 PC.GV = new GlobalVariable(
485 *F.getParent(), C.getType(), true, GlobalValue::InternalLinkage, nullptr,
486 "_PromotedConst", nullptr, GlobalVariable::NotThreadLocal);
487 PC.GV->setInitializer(&C);
488 LLVM_DEBUG(dbgs() << "Global replacement: ");
489 LLVM_DEBUG(PC.GV->print(dbgs()));
490 LLVM_DEBUG(dbgs() << '\n');
491 ++NumPromoted;
492}
493
494void AArch64PromoteConstant::insertDefinitions(Function &F,
495 GlobalVariable &PromotedGV,
496 InsertionPoints &InsertPts) {
497#ifndef NDEBUG
498 // Do more checking for debug purposes.
499 DominatorTree &DT = getAnalysis<DominatorTreeWrapperPass>(F).getDomTree();
500#endif
501 assert(!InsertPts.empty() && "Empty uses does not need a definition");
502
503 for (const auto &IPI : InsertPts) {
504 // Create the load of the global variable.
505 IRBuilder<> Builder(IPI.first);
506 LoadInst *LoadedCst =
507 Builder.CreateLoad(PromotedGV.getValueType(), &PromotedGV);
508 LLVM_DEBUG(dbgs() << "**********\n");
509 LLVM_DEBUG(dbgs() << "New def: ");
510 LLVM_DEBUG(LoadedCst->print(dbgs()));
511 LLVM_DEBUG(dbgs() << '\n');
512
513 // Update the dominated uses.
514 for (auto Use : IPI.second) {
515#ifndef NDEBUG
516 assert(DT.dominates(LoadedCst,
517 findInsertionPoint(*Use.first, Use.second)) &&
518 "Inserted definition does not dominate all its uses!");
519#endif
520 LLVM_DEBUG({
521 dbgs() << "Use to update " << Use.second << ":";
522 Use.first->print(dbgs());
523 dbgs() << '\n';
524 });
525 Use.first->setOperand(Use.second, LoadedCst);
526 ++NumPromotedUses;
527 }
528 }
529}
530
531void AArch64PromoteConstant::promoteConstants(
532 Function &F, SmallVectorImpl<UpdateRecord> &Updates,
533 PromotionCacheTy &PromotionCache) {
534 // Promote the constants.
535 for (auto U = Updates.begin(), E = Updates.end(); U != E;) {
536 LLVM_DEBUG(dbgs() << "** Compute insertion points **\n");
537 auto First = U;
538 Constant *C = First->C;
539 InsertionPoints InsertPts;
540 do {
541 computeInsertionPoint(U->User, U->Op, InsertPts);
542 } while (++U != E && U->C == C);
543
544 auto &Promotion = PromotionCache[C];
545 ensurePromotedGV(F, *C, Promotion);
546 insertDefinitions(F, *Promotion.GV, InsertPts);
547 }
548}
549
550bool AArch64PromoteConstant::runOnFunction(Function &F,
551 PromotionCacheTy &PromotionCache) {
552 // Look for instructions using constant vector. Promote that constant to a
553 // global variable. Create as few loads of this variable as possible and
554 // update the uses accordingly.
556 for (Instruction &I : instructions(&F)) {
557 // Traverse the operand, looking for constant vectors. Replace them by a
558 // load of a global variable of constant vector type.
559 for (Use &U : I.operands()) {
561 // There is no point in promoting global values as they are already
562 // global. Do not promote constants containing constant expression, global
563 // values or blockaddresses either, as they may require some code
564 // expansion.
565 if (!Cst || isa<GlobalValue>(Cst) || !containsOnlyConstantData(Cst))
566 continue;
567
568 // Check if this constant is worth promoting.
569 if (!shouldConvert(*Cst, PromotionCache))
570 continue;
571
572 // Check if this use should be promoted.
573 unsigned OpNo = &U - I.op_begin();
574 if (!shouldConvertUse(Cst, &I, OpNo))
575 continue;
576
577 Updates.emplace_back(Cst, &I, OpNo);
578 }
579 }
580
581 if (Updates.empty())
582 return false;
583
584 promoteConstants(F, Updates, PromotionCache);
585 return true;
586}
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:278
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:43
bool isNullValue() const
Return true if this is the value that would be returned by getNullValue.
Definition Constant.h:64
DenseMapIterator< KeyT, ValueT, KeyInfoT, BucketT > iterator
Definition DenseMap.h:679
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Definition DenseMap.h:828
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
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
Definition Pass.h:255
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.
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()