LLVM 23.0.0git
DXILDataScalarization.cpp
Go to the documentation of this file.
1//===- DXILDataScalarization.cpp - Perform DXIL Data Legalization ---------===//
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
10#include "DirectX.h"
12#include "llvm/ADT/STLExtras.h"
15#include "llvm/IR/IRBuilder.h"
16#include "llvm/IR/InstVisitor.h"
18#include "llvm/IR/Module.h"
19#include "llvm/IR/Operator.h"
20#include "llvm/IR/PassManager.h"
22#include "llvm/IR/Type.h"
26
27#define DEBUG_TYPE "dxil-data-scalarization"
28static const int MaxVecSize = 4;
29
30using namespace llvm;
31
33
34public:
35 bool runOnModule(Module &M) override;
37
38 static char ID; // Pass identification.
39};
40
41static bool findAndReplaceVectors(Module &M);
42
43class DataScalarizerVisitor : public InstVisitor<DataScalarizerVisitor, bool> {
44public:
45 DataScalarizerVisitor() : GlobalMap() {}
46 bool visit(Function &F);
47 // InstVisitor methods. They return true if the instruction was scalarized,
48 // false if nothing changed.
50 bool visitInstruction(Instruction &I) { return false; }
51 bool visitSelectInst(SelectInst &SI) { return false; }
52 bool visitICmpInst(ICmpInst &ICI) { return false; }
53 bool visitFCmpInst(FCmpInst &FCI) { return false; }
54 bool visitUnaryOperator(UnaryOperator &UO) { return false; }
55 bool visitBinaryOperator(BinaryOperator &BO) { return false; }
57 bool visitCastInst(CastInst &CI) { return false; }
58 bool visitBitCastInst(BitCastInst &BCI) { return false; }
61 bool visitShuffleVectorInst(ShuffleVectorInst &SVI) { return false; }
62 bool visitPHINode(PHINode &PHI) { return false; }
63 bool visitLoadInst(LoadInst &LI);
65 bool visitCallInst(CallInst &ICI) { return false; }
66 bool visitFreezeInst(FreezeInst &FI) { return false; }
67 friend bool findAndReplaceVectors(llvm::Module &M);
68
69private:
70 typedef std::tuple<AllocaInst *, Type *, SmallVector<Value *, 4>>
71 AllocaAndGEPs;
73 VectorToArrayMap; // A map from a vector-typed Value to its corresponding
74 // AllocaInst and GEPs to each element of an array
75 VectorToArrayMap VectorAllocaMap;
76 AllocaAndGEPs createArrayFromVector(IRBuilder<> &Builder, Value *Vec,
77 const Twine &Name);
78 bool replaceDynamicInsertElementInst(InsertElementInst &IEI);
79 bool replaceDynamicExtractElementInst(ExtractElementInst &EEI);
80
81 GlobalVariable *lookupReplacementGlobal(Value *CurrOperand);
83};
84
86 bool MadeChange = false;
88 for (BasicBlock *BB : make_early_inc_range(RPOT)) {
90 MadeChange |= InstVisitor::visit(I);
91 }
92 VectorAllocaMap.clear();
93 return MadeChange;
94}
95
97DataScalarizerVisitor::lookupReplacementGlobal(Value *CurrOperand) {
98 if (GlobalVariable *OldGlobal = dyn_cast<GlobalVariable>(CurrOperand)) {
99 auto It = GlobalMap.find(OldGlobal);
100 if (It != GlobalMap.end()) {
101 return It->second; // Found, return the new global
102 }
103 }
104 return nullptr; // Not found
105}
106
107// Helper function to check if a type is a vector or an array of vectors
109 if (isa<VectorType>(T))
110 return true;
111 if (ArrayType *ArrayTy = dyn_cast<ArrayType>(T))
112 return isVectorOrArrayOfVectors(ArrayTy->getElementType());
113 return false;
114}
115
116// Recursively creates an array-like version of a given vector type.
118 if (auto *VecTy = dyn_cast<VectorType>(T))
119 return ArrayType::get(VecTy->getElementType(),
120 dyn_cast<FixedVectorType>(VecTy)->getNumElements());
121 if (auto *ArrayTy = dyn_cast<ArrayType>(T)) {
122 Type *NewElementType =
123 equivalentArrayTypeFromVector(ArrayTy->getElementType());
124 return ArrayType::get(NewElementType, ArrayTy->getNumElements());
125 }
126 // If it's not a vector or array, return the original type.
127 return T;
128}
129
131 Type *AllocatedType = AI.getAllocatedType();
132 if (!isVectorOrArrayOfVectors(AllocatedType))
133 return false;
134
135 IRBuilder<> Builder(&AI);
136 Type *NewType = equivalentArrayTypeFromVector(AllocatedType);
137 AllocaInst *ArrAlloca =
138 Builder.CreateAlloca(NewType, nullptr, AI.getName() + ".scalarized");
139 ArrAlloca->setAlignment(AI.getAlign());
140 AI.replaceAllUsesWith(ArrAlloca);
141 AI.eraseFromParent();
142 return true;
143}
144
146 Value *PtrOperand = LI.getPointerOperand();
147 ConstantExpr *CE = dyn_cast<ConstantExpr>(PtrOperand);
148 if (CE && CE->getOpcode() == Instruction::GetElementPtr) {
149 GetElementPtrInst *OldGEP = cast<GetElementPtrInst>(CE->getAsInstruction());
150 OldGEP->insertBefore(LI.getIterator());
151 IRBuilder<> Builder(&LI);
152 LoadInst *NewLoad = Builder.CreateLoad(LI.getType(), OldGEP, LI.getName());
153 NewLoad->setAlignment(LI.getAlign());
154 LI.replaceAllUsesWith(NewLoad);
155 LI.eraseFromParent();
156 visitGetElementPtrInst(*OldGEP);
157 return true;
158 }
159 if (GlobalVariable *NewGlobal = lookupReplacementGlobal(PtrOperand))
160 LI.setOperand(LI.getPointerOperandIndex(), NewGlobal);
161 return false;
162}
163
165
166 Value *PtrOperand = SI.getPointerOperand();
167 ConstantExpr *CE = dyn_cast<ConstantExpr>(PtrOperand);
168 if (CE && CE->getOpcode() == Instruction::GetElementPtr) {
169 GetElementPtrInst *OldGEP = cast<GetElementPtrInst>(CE->getAsInstruction());
170 OldGEP->insertBefore(SI.getIterator());
171 IRBuilder<> Builder(&SI);
172 StoreInst *NewStore = Builder.CreateStore(SI.getValueOperand(), OldGEP);
173 NewStore->setAlignment(SI.getAlign());
174 SI.replaceAllUsesWith(NewStore);
175 SI.eraseFromParent();
176 visitGetElementPtrInst(*OldGEP);
177 return true;
178 }
179 if (GlobalVariable *NewGlobal = lookupReplacementGlobal(PtrOperand))
180 SI.setOperand(SI.getPointerOperandIndex(), NewGlobal);
181
182 return false;
183}
184
185DataScalarizerVisitor::AllocaAndGEPs
186DataScalarizerVisitor::createArrayFromVector(IRBuilder<> &Builder, Value *Vec,
187 const Twine &Name = "") {
188 // If there is already an alloca for this vector, return it
189 if (VectorAllocaMap.contains(Vec))
190 return VectorAllocaMap[Vec];
191
192 auto InsertPoint = Builder.GetInsertPoint();
193
194 // Allocate the array to hold the vector elements
195 Builder.SetInsertPointPastAllocas(Builder.GetInsertBlock()->getParent());
197 AllocaInst *ArrAlloca =
198 Builder.CreateAlloca(ArrTy, nullptr, Name + ".alloca");
199 const uint64_t ArrNumElems = ArrTy->getArrayNumElements();
200
201 // Create loads and stores to populate the array immediately after the
202 // original vector's defining instruction if available, else immediately after
203 // the alloca
204 if (auto *Instr = dyn_cast<Instruction>(Vec))
205 Builder.SetInsertPoint(Instr->getNextNode());
206 SmallVector<Value *, 4> GEPs(ArrNumElems);
207 for (unsigned I = 0; I < ArrNumElems; ++I) {
208 Value *EE = Builder.CreateExtractElement(Vec, I, Name + ".extract");
209 GEPs[I] = Builder.CreateInBoundsGEP(
210 ArrTy, ArrAlloca, {Builder.getInt32(0), Builder.getInt32(I)},
211 Name + ".index");
212 Builder.CreateStore(EE, GEPs[I]);
213 }
214
215 VectorAllocaMap.insert({Vec, {ArrAlloca, ArrTy, GEPs}});
216 Builder.SetInsertPoint(InsertPoint);
217 return {ArrAlloca, ArrTy, GEPs};
218}
219
220/// Returns a pair of Value* with the first being a GEP into ArrAlloca using
221/// indices {0, Index}, and the second Value* being a Load of the GEP
222static std::pair<Value *, Value *>
223dynamicallyLoadArray(IRBuilder<> &Builder, AllocaInst *ArrAlloca, Type *ArrTy,
224 Value *Index, const Twine &Name = "") {
225 Value *GEP = Builder.CreateInBoundsGEP(
226 ArrTy, ArrAlloca, {Builder.getInt32(0), Index}, Name + ".index");
227 Value *Load =
228 Builder.CreateLoad(ArrTy->getArrayElementType(), GEP, Name + ".load");
229 return std::make_pair(GEP, Load);
230}
231
232bool DataScalarizerVisitor::replaceDynamicInsertElementInst(
233 InsertElementInst &IEI) {
234 IRBuilder<> Builder(&IEI);
235
236 Value *Vec = IEI.getOperand(0);
237 Value *Val = IEI.getOperand(1);
238 Value *Index = IEI.getOperand(2);
239
240 AllocaAndGEPs ArrAllocaAndGEPs =
241 createArrayFromVector(Builder, Vec, IEI.getName());
242 AllocaInst *ArrAlloca = std::get<0>(ArrAllocaAndGEPs);
243 Type *ArrTy = std::get<1>(ArrAllocaAndGEPs);
244 SmallVector<Value *, 4> &ArrGEPs = std::get<2>(ArrAllocaAndGEPs);
245
246 auto GEPAndLoad =
247 dynamicallyLoadArray(Builder, ArrAlloca, ArrTy, Index, IEI.getName());
248 Value *GEP = GEPAndLoad.first;
249 Value *Load = GEPAndLoad.second;
250
251 Builder.CreateStore(Val, GEP);
252 Value *NewIEI = PoisonValue::get(Vec->getType());
253 for (unsigned I = 0; I < ArrTy->getArrayNumElements(); ++I) {
254 Value *Load = Builder.CreateLoad(ArrTy->getArrayElementType(), ArrGEPs[I],
255 IEI.getName() + ".load");
256 NewIEI = Builder.CreateInsertElement(NewIEI, Load, Builder.getInt32(I),
257 IEI.getName() + ".insert");
258 }
259
260 // Store back the original value so the Alloca can be reused for subsequent
261 // insertelement instructions on the same vector
262 Builder.CreateStore(Load, GEP);
263
264 IEI.replaceAllUsesWith(NewIEI);
265 IEI.eraseFromParent();
266 return true;
267}
268
270 // If the index is a constant then we don't need to scalarize it
271 Value *Index = IEI.getOperand(2);
272 if (isa<ConstantInt>(Index))
273 return false;
274 return replaceDynamicInsertElementInst(IEI);
275}
276
277bool DataScalarizerVisitor::replaceDynamicExtractElementInst(
278 ExtractElementInst &EEI) {
279 IRBuilder<> Builder(&EEI);
280
281 AllocaAndGEPs ArrAllocaAndGEPs =
282 createArrayFromVector(Builder, EEI.getVectorOperand(), EEI.getName());
283 AllocaInst *ArrAlloca = std::get<0>(ArrAllocaAndGEPs);
284 Type *ArrTy = std::get<1>(ArrAllocaAndGEPs);
285
286 auto GEPAndLoad = dynamicallyLoadArray(Builder, ArrAlloca, ArrTy,
287 EEI.getIndexOperand(), EEI.getName());
288 Value *Load = GEPAndLoad.second;
289
290 EEI.replaceAllUsesWith(Load);
291 EEI.eraseFromParent();
292 return true;
293}
294
296 // If the index is a constant then we don't need to scalarize it
297 Value *Index = EEI.getIndexOperand();
298 if (isa<ConstantInt>(Index))
299 return false;
300 return replaceDynamicExtractElementInst(EEI);
301}
302
304 GEPOperator *GOp = cast<GEPOperator>(&GEPI);
305 Value *PtrOperand = GOp->getPointerOperand();
306 Type *GEPType = GOp->getSourceElementType();
307
308 // Replace a GEP ConstantExpr pointer operand with a GEP instruction so that
309 // it can be visited
310 if (auto *PtrOpGEPCE = dyn_cast<ConstantExpr>(PtrOperand);
311 PtrOpGEPCE && PtrOpGEPCE->getOpcode() == Instruction::GetElementPtr) {
312 GetElementPtrInst *OldGEPI =
313 cast<GetElementPtrInst>(PtrOpGEPCE->getAsInstruction());
314 OldGEPI->insertBefore(GEPI.getIterator());
315
316 IRBuilder<> Builder(&GEPI);
317 SmallVector<Value *> Indices(GEPI.indices());
318 Value *NewGEP =
319 Builder.CreateGEP(GEPI.getSourceElementType(), OldGEPI, Indices,
320 GEPI.getName(), GEPI.getNoWrapFlags());
322 "Expected newly-created GEP to be an instruction");
324
325 GEPI.replaceAllUsesWith(NewGEPI);
326 GEPI.eraseFromParent();
327 visitGetElementPtrInst(*OldGEPI);
328 visitGetElementPtrInst(*NewGEPI);
329 return true;
330 }
331
332 Type *NewGEPType = equivalentArrayTypeFromVector(GEPType);
333 Value *NewPtrOperand = PtrOperand;
334 if (GlobalVariable *NewGlobal = lookupReplacementGlobal(PtrOperand))
335 NewPtrOperand = NewGlobal;
336
337 bool NeedsTransform = NewPtrOperand != PtrOperand || NewGEPType != GEPType;
338 if (!NeedsTransform)
339 return false;
340
341 IRBuilder<> Builder(&GEPI);
342 SmallVector<Value *, MaxVecSize> Indices(GOp->idx_begin(), GOp->idx_end());
343 Value *NewGEP = Builder.CreateGEP(NewGEPType, NewPtrOperand, Indices,
344 GOp->getName(), GOp->getNoWrapFlags());
345
346 GOp->replaceAllUsesWith(NewGEP);
347
348 if (auto *OldGEPI = dyn_cast<GetElementPtrInst>(GOp))
349 OldGEPI->eraseFromParent();
350
351 return true;
352}
353
355 Type *NewType, LLVMContext &Ctx) {
356 // Handle ConstantAggregateZero (zero-initialized constants)
358 return ConstantAggregateZero::get(NewType);
359 }
360
361 // Handle UndefValue (undefined constants)
362 if (isa<UndefValue>(Init)) {
363 return UndefValue::get(NewType);
364 }
365
366 // Handle vector to array transformation
367 if (isa<VectorType>(OrigType) && isa<ArrayType>(NewType)) {
368 // Convert vector initializer to array initializer
370
371 unsigned E = cast<FixedVectorType>(OrigType)->getNumElements();
372 for (unsigned I = 0; I != E; ++I)
373 if (Constant *Elt = Init->getAggregateElement(I))
374 ArrayElements.push_back(Elt);
375
376 assert(ArrayElements.size() == E &&
377 "Expected fixed length constant aggregate for vector initializer!");
378 return ConstantArray::get(cast<ArrayType>(NewType), ArrayElements);
379 }
380
381 // Handle array of vectors transformation
382 if (auto *ArrayTy = dyn_cast<ArrayType>(OrigType)) {
383 auto *ArrayInit = dyn_cast<ConstantArray>(Init);
384 assert(ArrayInit && "Expected a ConstantArray for array initializer!");
385
387 for (unsigned I = 0; I < ArrayTy->getNumElements(); ++I) {
388 // Recursively transform array elements
389 Constant *NewElemInit = transformInitializer(
390 ArrayInit->getOperand(I), ArrayTy->getElementType(),
391 cast<ArrayType>(NewType)->getElementType(), Ctx);
392 NewArrayElements.push_back(NewElemInit);
393 }
394
395 return ConstantArray::get(cast<ArrayType>(NewType), NewArrayElements);
396 }
397
398 // If not a vector or array, return the original initializer
399 return Init;
400}
401
403 bool MadeChange = false;
404 LLVMContext &Ctx = M.getContext();
405 IRBuilder<> Builder(Ctx);
407 for (GlobalVariable &G : M.globals()) {
408 Type *OrigType = G.getValueType();
409
410 Type *NewType = equivalentArrayTypeFromVector(OrigType);
411 if (OrigType != NewType) {
412 // Create a new global variable with the updated type
413 // Note: Initializer is set via transformInitializer
414 GlobalVariable *NewGlobal = new GlobalVariable(
415 M, NewType, G.isConstant(), G.getLinkage(),
416 /*Initializer=*/nullptr, G.getName() + ".scalarized", &G,
417 G.getThreadLocalMode(), G.getAddressSpace(),
418 G.isExternallyInitialized());
419
420 // Copy relevant attributes
421 NewGlobal->setUnnamedAddr(G.getUnnamedAddr());
422 if (G.getAlignment() > 0) {
423 NewGlobal->setAlignment(G.getAlign());
424 }
425
426 if (G.hasInitializer()) {
427 Constant *Init = G.getInitializer();
428 Constant *NewInit = transformInitializer(Init, OrigType, NewType, Ctx);
429 NewGlobal->setInitializer(NewInit);
430 }
431
432 // Note: we want to do G.replaceAllUsesWith(NewGlobal);, but it assumes
433 // type equality. Instead we will use the visitor pattern.
434 Impl.GlobalMap[&G] = NewGlobal;
435 }
436 }
437
438 for (auto &F : make_early_inc_range(M.functions())) {
439 if (F.isDeclaration())
440 continue;
441 MadeChange |= Impl.visit(F);
442 }
443
444 // Remove the old globals after the iteration
445 for (auto &[Old, New] : Impl.GlobalMap) {
446 Old->eraseFromParent();
447 MadeChange = true;
448 }
449 return MadeChange;
450}
451
454 bool MadeChanges = findAndReplaceVectors(M);
455 if (!MadeChanges)
456 return PreservedAnalyses::all();
458 return PA;
459}
460
464
466
468 "DXIL Data Scalarization", false, false)
470 "DXIL Data Scalarization", false, false)
471
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Rewrite undef for PHI
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static bool findAndReplaceVectors(Module &M)
static std::pair< Value *, Value * > dynamicallyLoadArray(IRBuilder<> &Builder, AllocaInst *ArrAlloca, Type *ArrTy, Value *Index, const Twine &Name="")
Returns a pair of Value* with the first being a GEP into ArrAlloca using indices {0,...
static bool isVectorOrArrayOfVectors(Type *T)
static Type * equivalentArrayTypeFromVector(Type *T)
static const int MaxVecSize
static Constant * transformInitializer(Constant *Init, Type *OrigType, Type *NewType, LLVMContext &Ctx)
#define DEBUG_TYPE
Hexagon Common GEP
Module.h This file contains the declarations for the Module class.
This header defines various interfaces for pass management in LLVM.
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
#define G(x, y, z)
Definition MD5.cpp:55
#define T
#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 builds on the ADT/GraphTraits.h file to build a generic graph post order iterator.
This file contains some templates that are useful if you are working with the STL at all.
bool runOnModule(Module &M) override
runOnModule - Virtual method overriden by subclasses to process the module being operated on.
bool visitCallInst(CallInst &ICI)
bool visitInstruction(Instruction &I)
bool visitBinaryOperator(BinaryOperator &BO)
bool visitInsertElementInst(InsertElementInst &IEI)
bool visitGetElementPtrInst(GetElementPtrInst &GEPI)
bool visitStoreInst(StoreInst &SI)
bool visitFreezeInst(FreezeInst &FI)
bool visitBitCastInst(BitCastInst &BCI)
bool visitCastInst(CastInst &CI)
bool visitFCmpInst(FCmpInst &FCI)
bool visitSelectInst(SelectInst &SI)
bool visitUnaryOperator(UnaryOperator &UO)
bool visitICmpInst(ICmpInst &ICI)
bool visitShuffleVectorInst(ShuffleVectorInst &SVI)
bool visitAllocaInst(AllocaInst &AI)
bool visitPHINode(PHINode &PHI)
bool visitExtractElementInst(ExtractElementInst &EEI)
friend bool findAndReplaceVectors(llvm::Module &M)
an instruction to allocate memory on the stack
Align getAlign() const
Return the alignment of the memory that is being allocated by the instruction.
Type * getAllocatedType() const
Return the type that is being allocated by the instruction.
void setAlignment(Align Align)
static LLVM_ABI ArrayType * get(Type *ElementType, uint64_t NumElements)
This static method is the primary way to construct an ArrayType.
LLVM Basic Block Representation.
Definition BasicBlock.h:62
This class represents a no-op cast from one type to another.
This class represents a function call, abstracting a target machine's calling convention.
This is the base class for all instructions that perform data casts.
Definition InstrTypes.h:448
static LLVM_ABI ConstantAggregateZero * get(Type *Ty)
static LLVM_ABI Constant * get(ArrayType *T, ArrayRef< Constant * > V)
A constant value that is initialized with an expression using other constant values.
Definition Constants.h:1130
This is an important base class in LLVM.
Definition Constant.h:43
PreservedAnalyses run(Module &M, ModuleAnalysisManager &)
bool contains(const_arg_type_t< KeyT > Val) const
Return true if the specified key is in the map, false otherwise.
Definition DenseMap.h:169
This instruction extracts a single (scalar) element from a VectorType value.
This instruction compares its operands according to the predicate given to the constructor.
This class represents a freeze function that returns random concrete value if an operand is either a ...
op_iterator idx_end()
Definition Operator.h:446
LLVM_ABI Type * getSourceElementType() const
Definition Operator.cpp:82
op_iterator idx_begin()
Definition Operator.h:444
Value * getPointerOperand()
Definition Operator.h:457
GEPNoWrapFlags getNoWrapFlags() const
Definition Operator.h:425
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
iterator_range< op_iterator > indices()
Type * getSourceElementType() const
LLVM_ABI GEPNoWrapFlags getNoWrapFlags() const
Get the nowrap flags for the GEP instruction.
void setUnnamedAddr(UnnamedAddr Val)
LLVM_ABI void setInitializer(Constant *InitVal)
setInitializer - Sets the initializer for this global variable, removing any existing initializer if ...
Definition Globals.cpp:534
void setAlignment(Align Align)
Sets the alignment attribute of the GlobalVariable.
This instruction compares its operands according to the predicate given to the constructor.
Value * CreateInsertElement(Type *VecTy, Value *NewElt, Value *Idx, const Twine &Name="")
Definition IRBuilder.h:2561
BasicBlock::iterator GetInsertPoint() const
Definition IRBuilder.h:202
ConstantInt * getInt32(uint32_t C)
Get a constant 32-bit value.
Definition IRBuilder.h:522
LoadInst * CreateLoad(Type *Ty, Value *Ptr, const char *Name)
Provided to resolve 'CreateLoad(Ty, Ptr, "...")' correctly, instead of converting the string to 'bool...
Definition IRBuilder.h:1854
StoreInst * CreateStore(Value *Val, Value *Ptr, bool isVolatile=false)
Definition IRBuilder.h:1867
void SetInsertPoint(BasicBlock *TheBB)
This specifies that created instructions should be appended to the end of the specified block.
Definition IRBuilder.h:207
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Definition IRBuilder.h:2787
This instruction inserts a single (scalar) element into a VectorType value.
Base class for instruction visitors.
Definition InstVisitor.h:78
void visit(Iterator Start, Iterator End)
Definition InstVisitor.h:87
LLVM_ABI void insertBefore(InstListType::iterator InsertPos)
Insert an unlinked instruction into a basic block immediately before the specified position.
LLVM_ABI InstListType::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
An instruction for reading from memory.
void setAlignment(Align Align)
Value * getPointerOperand()
static unsigned getPointerOperandIndex()
Align getAlign() const
Return the alignment of the access that is being performed.
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
Definition Pass.h:255
ModulePass(char &pid)
Definition Pass.h:257
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition Analysis.h:118
This class represents the LLVM 'select' instruction.
This instruction constructs a fixed permutation of two input vectors.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
void setAlignment(Align Align)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition Twine.h:82
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:45
Type * getArrayElementType() const
Definition Type.h:408
LLVM_ABI uint64_t getArrayNumElements() const
static LLVM_ABI UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
void setOperand(unsigned i, Value *Val)
Definition User.h:212
Value * getOperand(unsigned i) const
Definition User.h:207
LLVM Value Representation.
Definition Value.h:75
Type * getType() const
All values are typed, get the type of this value.
Definition Value.h:256
LLVM_ABI void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
Definition Value.cpp:553
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
Definition Value.cpp:322
self_iterator getIterator()
Definition ilist_node.h:123
This is an optimization pass for GlobalISel generic memory operations.
Definition Types.h:26
FunctionAddr VTableAddr Value
Definition InstrProf.h:137
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
ModulePass * createDXILDataScalarizationLegacyPass()
Pass to scalarize llvm global data into a DXIL legal form.
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:634
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
IRBuilder(LLVMContext &, FolderTy, InserterTy, MDNode *, ArrayRef< OperandBundleDef >) -> IRBuilder< FolderTy, InserterTy >
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
Definition MIRParser.h:39