48 return "convert address space of alloca'ed memory to local";
53char NVPTXLowerAlloca::ID = 1;
68 if (
auto allocaInst = dyn_cast<AllocaInst>(&
I)) {
72 cast<PointerType>(allocaInst->getType()->getScalarType());
73 unsigned AllocAddrSpace = AllocInstPtrTy->getAddressSpace();
76 "AllocaInst can only be in Generic or Local address space for "
80 auto ETy = allocaInst->getAllocatedType();
94 ASCastToLocalAS->insertAfter(allocaInst);
95 AllocaInLocalAS = ASCastToLocalAS;
100 AllocaInGenericAS->insertAfter(AllocaInLocalAS);
108 auto LI = dyn_cast<LoadInst>(AllocaUse.getUser());
109 if (LI && LI->getPointerOperand() == allocaInst &&
111 LI->setOperand(LI->getPointerOperandIndex(), AllocaInGenericAS);
114 auto SI = dyn_cast<StoreInst>(AllocaUse.getUser());
115 if (SI && SI->getPointerOperand() == allocaInst &&
117 SI->setOperand(SI->getPointerOperandIndex(), AllocaInGenericAS);
120 auto GI = dyn_cast<GetElementPtrInst>(AllocaUse.getUser());
121 if (GI && GI->getPointerOperand() == allocaInst) {
122 GI->setOperand(GI->getPointerOperandIndex(), AllocaInGenericAS);
125 auto BI = dyn_cast<BitCastInst>(AllocaUse.getUser());
126 if (BI && BI->getOperand(0) == allocaInst) {
127 BI->setOperand(0, AllocaInGenericAS);
137 return new NVPTXLowerAlloca();
static bool runOnFunction(Function &F, bool PostInlining)
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This class represents a conversion between pointers from one address space to another.
FunctionPass class - This class is used to implement most global optimizations.
virtual bool runOnFunction(Function &F)=0
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
StringRef - Represent a constant reference to a string, i.e.
A Use represents the edge between a Value definition and its users.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
void initializeNVPTXLowerAllocaPass(PassRegistry &)
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()