57 auto *LocalAlloca =
new AllocaInst(AI->getAllocatedType(),
59 AI->getAlign(),
"", AI->getIterator());
60 LocalAlloca->setDebugLoc(AI->getDebugLoc());
61 LocalAlloca->copyMetadata(*AI);
62 LocalAlloca->setUsedWithInAlloca(AI->isUsedWithInAlloca());
63 LocalAlloca->setSwiftError(AI->isSwiftError());
74 DVR->replaceVariableLocationOp(AI, LocalAlloca);
82 II->getModule(),
II->getIntrinsicID(), {LocalAlloca->getType()});
83 II->setCalledFunction(Decl);
92 GenericPtr->setDebugLoc(AI->getDebugLoc());
93 AI->replaceAllUsesWith(GenericPtr);
94 LocalAlloca->takeName(AI);
95 AI->eraseFromParent();
98 return !GenericAllocas.
empty();
107 NVPTXLowerAllocaLegacyPass() : FunctionPass(ID) {}
108 StringRef getPassName()
const override {
109 return "convert address space of alloca'ed memory to local";
114char NVPTXLowerAllocaLegacyPass::ID = 0;
117 "Lower Alloca",
false,
false)
120 return new NVPTXLowerAllocaLegacyPass();
static bool runOnFunction(Function &F, bool PostInlining)
static bool lowerAllocas(Function &F)
uint64_t IntrinsicInst * II
FunctionAnalysisManager FAM
#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
Represents analyses that only rely on functions' control flow.
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.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM)
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PreservedAnalyses & preserveSet()
Mark an analysis set as preserved.
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 * createNVPTXLowerAllocaLegacyPass()
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
LLVM_ABI void findDbgUsers(Value *V, SmallVectorImpl< DbgVariableRecord * > &DbgVariableRecords)
Finds the debug info records describing a value.