42 NVPTXLowerAlloca() : FunctionPass(ID) {}
43 StringRef getPassName()
const override {
44 return "convert address space of alloca'ed memory to local";
49char NVPTXLowerAlloca::ID = 1;
69 unsigned AllocAddrSpace = AllocInstPtrTy->getAddressSpace();
72 "AllocaInst can only be in Generic or Local address space for "
76 auto ETy = allocaInst->getAllocatedType();
91 ASCastToLocalAS->insertAfter(allocaInst->getIterator());
92 AllocaInLocalAS = ASCastToLocalAS;
98 AllocaInGenericAS->insertAfter(AllocaInLocalAS->
getIterator());
107 if (LI && LI->getPointerOperand() == allocaInst &&
109 LI->setOperand(LI->getPointerOperandIndex(), AllocaInGenericAS);
113 if (
SI &&
SI->getPointerOperand() == allocaInst &&
115 SI->setOperand(
SI->getPointerOperandIndex(), AllocaInGenericAS);
119 if (GI && GI->getPointerOperand() == allocaInst) {
120 GI->setOperand(GI->getPointerOperandIndex(), AllocaInGenericAS);
124 if (BI && BI->getOperand(0) == allocaInst) {
125 BI->setOperand(0, AllocaInGenericAS);
135 return new NVPTXLowerAlloca();
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static bool runOnFunction(Function &F, bool PostInlining)
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
This class represents a conversion between pointers from one address space to another.
FunctionPass class - This class is used to implement most global optimizations.
static LLVM_ABI PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space.
A Use represents the edge between a Value definition and its users.
self_iterator getIterator()
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
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...
FunctionPass * createNVPTXLowerAllocaPass()
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.