48 NVPTXLowerAlloca() : FunctionPass(ID) {}
49 StringRef getPassName()
const override {
50 return "convert address space of alloca'ed memory to local";
55char NVPTXLowerAlloca::ID = 0;
75 auto *LocalAlloca =
new AllocaInst(AI->getAllocatedType(),
77 AI->getAlign(),
"", AI->getIterator());
78 LocalAlloca->setDebugLoc(AI->getDebugLoc());
79 LocalAlloca->copyMetadata(*AI);
80 LocalAlloca->setUsedWithInAlloca(AI->isUsedWithInAlloca());
81 LocalAlloca->setSwiftError(AI->isSwiftError());
92 DVR->replaceVariableLocationOp(AI, LocalAlloca);
100 II->getModule(),
II->getIntrinsicID(), {LocalAlloca->getType()});
101 II->setCalledFunction(Decl);
110 GenericPtr->setDebugLoc(AI->getDebugLoc());
111 AI->replaceAllUsesWith(GenericPtr);
112 LocalAlloca->takeName(AI);
113 AI->eraseFromParent();
116 return !GenericAllocas.
empty();
120 return new NVPTXLowerAlloca();
for(const MachineOperand &MO :llvm::drop_begin(OldMI.operands(), Desc.getNumOperands()))
static bool runOnFunction(Function &F, bool PostInlining)
uint64_t IntrinsicInst * II
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
This file defines the SmallVector class.
This class represents a conversion between pointers from one address space to another.
an instruction to allocate memory on the stack
Record of a variable value-assignment, aka a non instruction representation of the dbg....
FunctionPass class - This class is used to implement most global optimizations.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
A Use represents the edge between a Value definition and its users.
LLVM_ABI Function * getOrInsertDeclaration(Module *M, ID id, ArrayRef< Type * > OverloadTys={})
Look up the Function declaration of the intrinsic id in the Module M.
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...
static bool isLifetimeIntrinsic(Intrinsic::ID ID)
Check if ID corresponds to a lifetime intrinsic.
FunctionPass * createNVPTXLowerAllocaPass()
LLVM_ABI void findDbgUsers(Value *V, SmallVectorImpl< DbgVariableRecord * > &DbgVariableRecords)
Finds the debug info records describing a value.