LLVM 20.0.0git
AMDGPULateCodeGenPrepare.cpp
Go to the documentation of this file.
1//===-- AMDGPUCodeGenPrepare.cpp ------------------------------------------===//
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/// \file
10/// This pass does misc. AMDGPU optimizations on IR *just* before instruction
11/// selection.
12//
13//===----------------------------------------------------------------------===//
14
15#include "AMDGPU.h"
16#include "AMDGPUTargetMachine.h"
21#include "llvm/IR/IRBuilder.h"
22#include "llvm/IR/InstVisitor.h"
26
27#define DEBUG_TYPE "amdgpu-late-codegenprepare"
28
29using namespace llvm;
30
31// Scalar load widening needs running after load-store-vectorizer as that pass
32// doesn't handle overlapping cases. In addition, this pass enhances the
33// widening to handle cases where scalar sub-dword loads are naturally aligned
34// only but not dword aligned.
35static cl::opt<bool>
36 WidenLoads("amdgpu-late-codegenprepare-widen-constant-loads",
37 cl::desc("Widen sub-dword constant address space loads in "
38 "AMDGPULateCodeGenPrepare"),
40
41namespace {
42
43class AMDGPULateCodeGenPrepare
44 : public InstVisitor<AMDGPULateCodeGenPrepare, bool> {
45 Function &F;
46 const DataLayout &DL;
47 const GCNSubtarget &ST;
48
49 AssumptionCache *const AC;
51
53
54public:
55 AMDGPULateCodeGenPrepare(Function &F, const GCNSubtarget &ST,
57 : F(F), DL(F.getDataLayout()), ST(ST), AC(AC), UA(UA) {}
58 bool run();
59 bool visitInstruction(Instruction &) { return false; }
60
61 // Check if the specified value is at least DWORD aligned.
62 bool isDWORDAligned(const Value *V) const {
63 KnownBits Known = computeKnownBits(V, DL, 0, AC);
64 return Known.countMinTrailingZeros() >= 2;
65 }
66
67 bool canWidenScalarExtLoad(LoadInst &LI) const;
68 bool visitLoadInst(LoadInst &LI);
69};
70
72
73class LiveRegOptimizer {
74private:
75 Module &Mod;
76 const DataLayout &DL;
77 const GCNSubtarget &ST;
78 /// The scalar type to convert to
79 Type *const ConvertToScalar;
80 /// The set of visited Instructions
82 /// Map of Value -> Converted Value
83 ValueToValueMap ValMap;
84 /// Map of containing conversions from Optimal Type -> Original Type per BB.
86
87public:
88 /// Calculate the and \p return the type to convert to given a problematic \p
89 /// OriginalType. In some instances, we may widen the type (e.g. v2i8 -> i32).
90 Type *calculateConvertType(Type *OriginalType);
91 /// Convert the virtual register defined by \p V to the compatible vector of
92 /// legal type
93 Value *convertToOptType(Instruction *V, BasicBlock::iterator &InstPt);
94 /// Convert the virtual register defined by \p V back to the original type \p
95 /// ConvertType, stripping away the MSBs in cases where there was an imperfect
96 /// fit (e.g. v2i32 -> v7i8)
97 Value *convertFromOptType(Type *ConvertType, Instruction *V,
99 BasicBlock *InsertBlock);
100 /// Check for problematic PHI nodes or cross-bb values based on the value
101 /// defined by \p I, and coerce to legal types if necessary. For problematic
102 /// PHI node, we coerce all incoming values in a single invocation.
103 bool optimizeLiveType(Instruction *I,
105
106 // Whether or not the type should be replaced to avoid inefficient
107 // legalization code
108 bool shouldReplace(Type *ITy) {
109 FixedVectorType *VTy = dyn_cast<FixedVectorType>(ITy);
110 if (!VTy)
111 return false;
112
113 const auto *TLI = ST.getTargetLowering();
114
115 Type *EltTy = VTy->getElementType();
116 // If the element size is not less than the convert to scalar size, then we
117 // can't do any bit packing
118 if (!EltTy->isIntegerTy() ||
119 EltTy->getScalarSizeInBits() > ConvertToScalar->getScalarSizeInBits())
120 return false;
121
122 // Only coerce illegal types
124 TLI->getTypeConversion(EltTy->getContext(), EVT::getEVT(EltTy, false));
125 return LK.first != TargetLoweringBase::TypeLegal;
126 }
127
128 LiveRegOptimizer(Module &Mod, const GCNSubtarget &ST)
129 : Mod(Mod), DL(Mod.getDataLayout()), ST(ST),
130 ConvertToScalar(Type::getInt32Ty(Mod.getContext())) {}
131};
132
133} // end anonymous namespace
134
135bool AMDGPULateCodeGenPrepare::run() {
136 // "Optimize" the virtual regs that cross basic block boundaries. When
137 // building the SelectionDAG, vectors of illegal types that cross basic blocks
138 // will be scalarized and widened, with each scalar living in its
139 // own register. To work around this, this optimization converts the
140 // vectors to equivalent vectors of legal type (which are converted back
141 // before uses in subsequent blocks), to pack the bits into fewer physical
142 // registers (used in CopyToReg/CopyFromReg pairs).
143 LiveRegOptimizer LRO(*F.getParent(), ST);
144
145 bool Changed = false;
146
147 bool HasScalarSubwordLoads = ST.hasScalarSubwordLoads();
148
149 for (auto &BB : reverse(F))
151 Changed |= !HasScalarSubwordLoads && visit(I);
152 Changed |= LRO.optimizeLiveType(&I, DeadInsts);
153 }
154
156 return Changed;
157}
158
159Type *LiveRegOptimizer::calculateConvertType(Type *OriginalType) {
160 assert(OriginalType->getScalarSizeInBits() <=
161 ConvertToScalar->getScalarSizeInBits());
162
163 FixedVectorType *VTy = cast<FixedVectorType>(OriginalType);
164
165 TypeSize OriginalSize = DL.getTypeSizeInBits(VTy);
166 TypeSize ConvertScalarSize = DL.getTypeSizeInBits(ConvertToScalar);
167 unsigned ConvertEltCount =
168 (OriginalSize + ConvertScalarSize - 1) / ConvertScalarSize;
169
170 if (OriginalSize <= ConvertScalarSize)
171 return IntegerType::get(Mod.getContext(), ConvertScalarSize);
172
173 return VectorType::get(Type::getIntNTy(Mod.getContext(), ConvertScalarSize),
174 ConvertEltCount, false);
175}
176
177Value *LiveRegOptimizer::convertToOptType(Instruction *V,
178 BasicBlock::iterator &InsertPt) {
179 FixedVectorType *VTy = cast<FixedVectorType>(V->getType());
180 Type *NewTy = calculateConvertType(V->getType());
181
182 TypeSize OriginalSize = DL.getTypeSizeInBits(VTy);
183 TypeSize NewSize = DL.getTypeSizeInBits(NewTy);
184
185 IRBuilder<> Builder(V->getParent(), InsertPt);
186 // If there is a bitsize match, we can fit the old vector into a new vector of
187 // desired type.
188 if (OriginalSize == NewSize)
189 return Builder.CreateBitCast(V, NewTy, V->getName() + ".bc");
190
191 // If there is a bitsize mismatch, we must use a wider vector.
192 assert(NewSize > OriginalSize);
193 uint64_t ExpandedVecElementCount = NewSize / VTy->getScalarSizeInBits();
194
195 SmallVector<int, 8> ShuffleMask;
196 uint64_t OriginalElementCount = VTy->getElementCount().getFixedValue();
197 for (unsigned I = 0; I < OriginalElementCount; I++)
198 ShuffleMask.push_back(I);
199
200 for (uint64_t I = OriginalElementCount; I < ExpandedVecElementCount; I++)
201 ShuffleMask.push_back(OriginalElementCount);
202
203 Value *ExpandedVec = Builder.CreateShuffleVector(V, ShuffleMask);
204 return Builder.CreateBitCast(ExpandedVec, NewTy, V->getName() + ".bc");
205}
206
207Value *LiveRegOptimizer::convertFromOptType(Type *ConvertType, Instruction *V,
208 BasicBlock::iterator &InsertPt,
209 BasicBlock *InsertBB) {
210 FixedVectorType *NewVTy = cast<FixedVectorType>(ConvertType);
211
212 TypeSize OriginalSize = DL.getTypeSizeInBits(V->getType());
213 TypeSize NewSize = DL.getTypeSizeInBits(NewVTy);
214
215 IRBuilder<> Builder(InsertBB, InsertPt);
216 // If there is a bitsize match, we simply convert back to the original type.
217 if (OriginalSize == NewSize)
218 return Builder.CreateBitCast(V, NewVTy, V->getName() + ".bc");
219
220 // If there is a bitsize mismatch, then we must have used a wider value to
221 // hold the bits.
222 assert(OriginalSize > NewSize);
223 // For wide scalars, we can just truncate the value.
224 if (!V->getType()->isVectorTy()) {
225 Instruction *Trunc = cast<Instruction>(
226 Builder.CreateTrunc(V, IntegerType::get(Mod.getContext(), NewSize)));
227 return cast<Instruction>(Builder.CreateBitCast(Trunc, NewVTy));
228 }
229
230 // For wider vectors, we must strip the MSBs to convert back to the original
231 // type.
232 VectorType *ExpandedVT = VectorType::get(
233 Type::getIntNTy(Mod.getContext(), NewVTy->getScalarSizeInBits()),
234 (OriginalSize / NewVTy->getScalarSizeInBits()), false);
235 Instruction *Converted =
236 cast<Instruction>(Builder.CreateBitCast(V, ExpandedVT));
237
238 unsigned NarrowElementCount = NewVTy->getElementCount().getFixedValue();
239 SmallVector<int, 8> ShuffleMask(NarrowElementCount);
240 std::iota(ShuffleMask.begin(), ShuffleMask.end(), 0);
241
242 return Builder.CreateShuffleVector(Converted, ShuffleMask);
243}
244
245bool LiveRegOptimizer::optimizeLiveType(
251
252 Worklist.push_back(cast<Instruction>(I));
253 while (!Worklist.empty()) {
254 Instruction *II = Worklist.pop_back_val();
255
256 if (!Visited.insert(II).second)
257 continue;
258
259 if (!shouldReplace(II->getType()))
260 continue;
261
262 if (PHINode *Phi = dyn_cast<PHINode>(II)) {
263 PhiNodes.insert(Phi);
264 // Collect all the incoming values of problematic PHI nodes.
265 for (Value *V : Phi->incoming_values()) {
266 // Repeat the collection process for newly found PHI nodes.
267 if (PHINode *OpPhi = dyn_cast<PHINode>(V)) {
268 if (!PhiNodes.count(OpPhi) && !Visited.count(OpPhi))
269 Worklist.push_back(OpPhi);
270 continue;
271 }
272
273 Instruction *IncInst = dyn_cast<Instruction>(V);
274 // Other incoming value types (e.g. vector literals) are unhandled
275 if (!IncInst && !isa<ConstantAggregateZero>(V))
276 return false;
277
278 // Collect all other incoming values for coercion.
279 if (IncInst)
280 Defs.insert(IncInst);
281 }
282 }
283
284 // Collect all relevant uses.
285 for (User *V : II->users()) {
286 // Repeat the collection process for problematic PHI nodes.
287 if (PHINode *OpPhi = dyn_cast<PHINode>(V)) {
288 if (!PhiNodes.count(OpPhi) && !Visited.count(OpPhi))
289 Worklist.push_back(OpPhi);
290 continue;
291 }
292
293 Instruction *UseInst = cast<Instruction>(V);
294 // Collect all uses of PHINodes and any use the crosses BB boundaries.
295 if (UseInst->getParent() != II->getParent() || isa<PHINode>(II)) {
296 Uses.insert(UseInst);
297 if (!isa<PHINode>(II))
298 Defs.insert(II);
299 }
300 }
301 }
302
303 // Coerce and track the defs.
304 for (Instruction *D : Defs) {
305 if (!ValMap.contains(D)) {
306 BasicBlock::iterator InsertPt = std::next(D->getIterator());
307 Value *ConvertVal = convertToOptType(D, InsertPt);
308 assert(ConvertVal);
309 ValMap[D] = ConvertVal;
310 }
311 }
312
313 // Construct new-typed PHI nodes.
314 for (PHINode *Phi : PhiNodes) {
315 ValMap[Phi] = PHINode::Create(calculateConvertType(Phi->getType()),
316 Phi->getNumIncomingValues(),
317 Phi->getName() + ".tc", Phi->getIterator());
318 }
319
320 // Connect all the PHI nodes with their new incoming values.
321 for (PHINode *Phi : PhiNodes) {
322 PHINode *NewPhi = cast<PHINode>(ValMap[Phi]);
323 bool MissingIncVal = false;
324 for (int I = 0, E = Phi->getNumIncomingValues(); I < E; I++) {
325 Value *IncVal = Phi->getIncomingValue(I);
326 if (isa<ConstantAggregateZero>(IncVal)) {
327 Type *NewType = calculateConvertType(Phi->getType());
328 NewPhi->addIncoming(ConstantInt::get(NewType, 0, false),
329 Phi->getIncomingBlock(I));
330 } else if (Value *Val = ValMap.lookup(IncVal))
331 NewPhi->addIncoming(Val, Phi->getIncomingBlock(I));
332 else
333 MissingIncVal = true;
334 }
335 if (MissingIncVal) {
336 Value *DeadVal = ValMap[Phi];
337 // The coercion chain of the PHI is broken. Delete the Phi
338 // from the ValMap and any connected / user Phis.
339 SmallVector<Value *, 4> PHIWorklist;
340 SmallPtrSet<Value *, 4> VisitedPhis;
341 PHIWorklist.push_back(DeadVal);
342 while (!PHIWorklist.empty()) {
343 Value *NextDeadValue = PHIWorklist.pop_back_val();
344 VisitedPhis.insert(NextDeadValue);
345 auto OriginalPhi =
346 std::find_if(PhiNodes.begin(), PhiNodes.end(),
347 [this, &NextDeadValue](PHINode *CandPhi) {
348 return ValMap[CandPhi] == NextDeadValue;
349 });
350 // This PHI may have already been removed from maps when
351 // unwinding a previous Phi
352 if (OriginalPhi != PhiNodes.end())
353 ValMap.erase(*OriginalPhi);
354
355 DeadInsts.emplace_back(cast<Instruction>(NextDeadValue));
356
357 for (User *U : NextDeadValue->users()) {
358 if (!VisitedPhis.contains(cast<PHINode>(U)))
359 PHIWorklist.push_back(U);
360 }
361 }
362 } else {
363 DeadInsts.emplace_back(cast<Instruction>(Phi));
364 }
365 }
366 // Coerce back to the original type and replace the uses.
367 for (Instruction *U : Uses) {
368 // Replace all converted operands for a use.
369 for (auto [OpIdx, Op] : enumerate(U->operands())) {
370 if (ValMap.contains(Op) && ValMap[Op]) {
371 Value *NewVal = nullptr;
372 if (BBUseValMap.contains(U->getParent()) &&
373 BBUseValMap[U->getParent()].contains(ValMap[Op]))
374 NewVal = BBUseValMap[U->getParent()][ValMap[Op]];
375 else {
376 BasicBlock::iterator InsertPt = U->getParent()->getFirstNonPHIIt();
377 // We may pick up ops that were previously converted for users in
378 // other blocks. If there is an originally typed definition of the Op
379 // already in this block, simply reuse it.
380 if (isa<Instruction>(Op) && !isa<PHINode>(Op) &&
381 U->getParent() == cast<Instruction>(Op)->getParent()) {
382 NewVal = Op;
383 } else {
384 NewVal =
385 convertFromOptType(Op->getType(), cast<Instruction>(ValMap[Op]),
386 InsertPt, U->getParent());
387 BBUseValMap[U->getParent()][ValMap[Op]] = NewVal;
388 }
389 }
390 assert(NewVal);
391 U->setOperand(OpIdx, NewVal);
392 }
393 }
394 }
395
396 return true;
397}
398
399bool AMDGPULateCodeGenPrepare::canWidenScalarExtLoad(LoadInst &LI) const {
400 unsigned AS = LI.getPointerAddressSpace();
401 // Skip non-constant address space.
402 if (AS != AMDGPUAS::CONSTANT_ADDRESS &&
404 return false;
405 // Skip non-simple loads.
406 if (!LI.isSimple())
407 return false;
408 Type *Ty = LI.getType();
409 // Skip aggregate types.
410 if (Ty->isAggregateType())
411 return false;
412 unsigned TySize = DL.getTypeStoreSize(Ty);
413 // Only handle sub-DWORD loads.
414 if (TySize >= 4)
415 return false;
416 // That load must be at least naturally aligned.
417 if (LI.getAlign() < DL.getABITypeAlign(Ty))
418 return false;
419 // It should be uniform, i.e. a scalar load.
420 return UA.isUniform(&LI);
421}
422
423bool AMDGPULateCodeGenPrepare::visitLoadInst(LoadInst &LI) {
424 if (!WidenLoads)
425 return false;
426
427 // Skip if that load is already aligned on DWORD at least as it's handled in
428 // SDAG.
429 if (LI.getAlign() >= 4)
430 return false;
431
432 if (!canWidenScalarExtLoad(LI))
433 return false;
434
435 int64_t Offset = 0;
436 auto *Base =
438 // If that base is not DWORD aligned, it's not safe to perform the following
439 // transforms.
440 if (!isDWORDAligned(Base))
441 return false;
442
443 int64_t Adjust = Offset & 0x3;
444 if (Adjust == 0) {
445 // With a zero adjust, the original alignment could be promoted with a
446 // better one.
447 LI.setAlignment(Align(4));
448 return true;
449 }
450
451 IRBuilder<> IRB(&LI);
452 IRB.SetCurrentDebugLocation(LI.getDebugLoc());
453
454 unsigned LdBits = DL.getTypeStoreSizeInBits(LI.getType());
455 auto *IntNTy = Type::getIntNTy(LI.getContext(), LdBits);
456
457 auto *NewPtr = IRB.CreateConstGEP1_64(
458 IRB.getInt8Ty(),
459 IRB.CreateAddrSpaceCast(Base, LI.getPointerOperand()->getType()),
460 Offset - Adjust);
461
462 LoadInst *NewLd = IRB.CreateAlignedLoad(IRB.getInt32Ty(), NewPtr, Align(4));
463 NewLd->copyMetadata(LI);
464 NewLd->setMetadata(LLVMContext::MD_range, nullptr);
465
466 unsigned ShAmt = Adjust * 8;
467 auto *NewVal = IRB.CreateBitCast(
468 IRB.CreateTrunc(IRB.CreateLShr(NewLd, ShAmt), IntNTy), LI.getType());
469 LI.replaceAllUsesWith(NewVal);
470 DeadInsts.emplace_back(&LI);
471
472 return true;
473}
474
477 const GCNSubtarget &ST = TM.getSubtarget<GCNSubtarget>(F);
478
481
482 bool Changed = AMDGPULateCodeGenPrepare(F, ST, &AC, UI).run();
483
484 if (!Changed)
485 return PreservedAnalyses::all();
488 return PA;
489}
490
492public:
493 static char ID;
494
496
497 StringRef getPassName() const override {
498 return "AMDGPU IR late optimizations";
499 }
500
501 void getAnalysisUsage(AnalysisUsage &AU) const override {
505 AU.setPreservesAll();
506 }
507
508 bool runOnFunction(Function &F) override;
509};
510
512 if (skipFunction(F))
513 return false;
514
515 const TargetPassConfig &TPC = getAnalysis<TargetPassConfig>();
516 const TargetMachine &TM = TPC.getTM<TargetMachine>();
517 const GCNSubtarget &ST = TM.getSubtarget<GCNSubtarget>(F);
518
519 AssumptionCache &AC =
520 getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
521 UniformityInfo &UI =
522 getAnalysis<UniformityInfoWrapperPass>().getUniformityInfo();
523
524 return AMDGPULateCodeGenPrepare(F, ST, &AC, UI).run();
525}
526
528 "AMDGPU IR late optimizations", false, false)
534
536
539}
aarch64 falkor hwpf fix late
static cl::opt< bool > WidenLoads("amdgpu-late-codegenprepare-widen-constant-loads", cl::desc("Widen sub-dword constant address space loads in " "AMDGPULateCodeGenPrepare"), cl::ReallyHidden, cl::init(true))
The AMDGPU TargetMachine interface definition for hw codegen targets.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static bool runOnFunction(Function &F, bool PostInlining)
#define DEBUG_TYPE
Legalize the Machine IR a function s Machine IR
Definition: Legalizer.cpp:80
Generic memory optimizations
#define F(x, y, z)
Definition: MD5.cpp:55
#define I(x, y, z)
Definition: MD5.cpp:58
uint64_t IntrinsicInst * II
if(auto Err=PB.parsePassPipeline(MPM, Passes)) return wrap(std MPM run * Mod
FunctionAnalysisManager FAM
#define INITIALIZE_PASS_DEPENDENCY(depName)
Definition: PassSupport.h:55
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition: PassSupport.h:57
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
Definition: PassSupport.h:52
Remove Loads Into Fake Uses
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void visit(MachineFunction &MF, MachineBasicBlock &Start, std::function< void(MachineBasicBlock *)> op)
Target-Independent Code Generator Pass Configuration Options pass.
LLVM IR instance of the generic uniformity analysis.
bool runOnFunction(Function &F) override
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
StringRef getPassName() const override
getPassName - Return a nice clean name for a pass.
PreservedAnalyses run(Function &, FunctionAnalysisManager &)
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:253
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Definition: PassManager.h:410
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
void setPreservesAll()
Set by analyses that do not transform their input at all.
A function analysis which provides an AssumptionCache.
An immutable pass that tracks lazily created AssumptionCache objects.
A cache of @llvm.assume calls within a function.
LLVM Basic Block Representation.
Definition: BasicBlock.h:61
InstListType::iterator iterator
Instruction iterators...
Definition: BasicBlock.h:177
Represents analyses that only rely on functions' control flow.
Definition: Analysis.h:72
This class represents an Operation in the Expression.
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:63
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
Definition: DenseMap.h:194
bool erase(const KeyT &Val)
Definition: DenseMap.h:321
bool contains(const_arg_type_t< KeyT > Val) const
Return true if the specified key is in the map, false otherwise.
Definition: DenseMap.h:147
Class to represent fixed width SIMD vectors.
Definition: DerivedTypes.h:563
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:310
bool isUniform(ConstValueRefT V) const
Whether V is uniform/non-divergent.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Definition: IRBuilder.h:2697
Base class for instruction visitors.
Definition: InstVisitor.h:78
void visitInstruction(Instruction &I)
Definition: InstVisitor.h:283
RetTy visitLoadInst(LoadInst &I)
Definition: InstVisitor.h:169
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
Definition: Instruction.h:471
void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
Definition: Metadata.cpp:1679
void copyMetadata(const Instruction &SrcInst, ArrayRef< unsigned > WL=ArrayRef< unsigned >())
Copy metadata from SrcInst to this instruction.
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
Definition: Type.cpp:311
An instruction for reading from memory.
Definition: Instructions.h:176
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
Definition: Instructions.h:261
void setAlignment(Align Align)
Definition: Instructions.h:215
Value * getPointerOperand()
Definition: Instructions.h:255
bool isSimple() const
Definition: Instructions.h:247
Align getAlign() const
Return the alignment of the access that is being performed.
Definition: Instructions.h:211
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
void addIncoming(Value *V, BasicBlock *BB)
Add an incoming value to the end of the PHI list.
static PHINode * Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructors - NumReservedValues is a hint for the number of incoming edges that this phi node will h...
A set of analyses that are preserved following a run of a transformation pass.
Definition: Analysis.h:111
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
Definition: Analysis.h:114
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition: Analysis.h:117
void preserveSet()
Mark an analysis set as preserved.
Definition: Analysis.h:146
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
Definition: SmallPtrSet.h:452
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
Definition: SmallPtrSet.h:384
bool contains(ConstPtrType Ptr) const
Definition: SmallPtrSet.h:458
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition: SmallPtrSet.h:519
bool empty() const
Definition: SmallVector.h:81
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:573
reference emplace_back(ArgTypes &&... Args)
Definition: SmallVector.h:937
void push_back(const T &Elt)
Definition: SmallVector.h:413
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1196
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
std::pair< LegalizeTypeAction, EVT > LegalizeKind
LegalizeKind holds the legalization kind that needs to happen to EVT in order to type-legalize it.
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:77
const STC & getSubtarget(const Function &F) const
This method returns a pointer to the specified type of TargetSubtargetInfo.
Target-Independent Code Generator Pass Configuration Options.
TMC & getTM() const
Get the right type of TargetMachine for this target.
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
static IntegerType * getIntNTy(LLVMContext &C, unsigned N)
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
bool isAggregateType() const
Return true if the type is an aggregate type.
Definition: Type.h:303
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
Definition: Type.h:128
bool isIntegerTy() const
True if this is an instance of IntegerType.
Definition: Type.h:237
Analysis pass which computes UniformityInfo.
Legacy analysis pass which computes a CycleInfo.
LLVM Value Representation.
Definition: Value.h:74
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:255
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
Definition: Value.cpp:534
iterator_range< user_iterator > users()
Definition: Value.h:421
LLVMContext & getContext() const
All values hold a context through their type.
Definition: Value.cpp:1075
ElementCount getElementCount() const
Return an ElementCount instance to represent the (possibly scalable) number of elements in the vector...
Definition: DerivedTypes.h:665
Type * getElementType() const
Definition: DerivedTypes.h:460
constexpr ScalarTy getFixedValue() const
Definition: TypeSize.h:202
const ParentTy * getParent() const
Definition: ilist_node.h:32
@ CONSTANT_ADDRESS_32BIT
Address space for 32-bit constant memory.
@ CONSTANT_ADDRESS
Address space for constant memory (VTX2).
@ ReallyHidden
Definition: CommandLine.h:138
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:443
PointerTypeMap run(const Module &M)
Compute the PointerTypeMap for the module M.
NodeAddr< PhiNode * > Phi
Definition: RDFGraph.h:390
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Offset
Definition: DWP.cpp:480
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
Definition: STLExtras.h:2448
Value * GetPointerBaseWithConstantOffset(Value *Ptr, int64_t &Offset, const DataLayout &DL, bool AllowNonInbounds=true)
Analyze the specified pointer to see if it can be expressed as a base pointer plus a constant offset.
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:657
auto reverse(ContainerTy &&C)
Definition: STLExtras.h:420
void computeKnownBits(const Value *V, KnownBits &Known, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, bool UseInstrInfo=true)
Determine which bits of V are known to be either zero or one and return them in the KnownZero/KnownOn...
DWARFExpression::Operation Op
bool RecursivelyDeleteTriviallyDeadInstructionsPermissive(SmallVectorImpl< WeakTrackingVH > &DeadInsts, const TargetLibraryInfo *TLI=nullptr, MemorySSAUpdater *MSSAU=nullptr, std::function< void(Value *)> AboutToDeleteCallback=std::function< void(Value *)>())
Same functionality as RecursivelyDeleteTriviallyDeadInstructions, but allow instructions that are not...
Definition: Local.cpp:561
FunctionPass * createAMDGPULateCodeGenPrepareLegacyPass()
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
static EVT getEVT(Type *Ty, bool HandleUnknown=false)
Return the value type corresponding to the specified type.
Definition: ValueTypes.cpp:289
unsigned countMinTrailingZeros() const
Returns the minimum number of trailing zero bits.
Definition: KnownBits.h:234