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