Lines Matching refs:llvm

45 class RSAddDebugInfoPass : public llvm::ModulePass {
56 virtual bool runOnModule(llvm::Module &Module) { in runOnModule()
70 llvm::SmallSetVector<llvm::Function *, 16> expandFuncs{}; in runOnModule()
75 if (llvm::Function *const func = Module.getFunction(expandName)) in runOnModule()
88 llvm::DIBuilder DebugInfo(Module); in runOnModule()
113 void initializeDebugInfo(llvm::DIBuilder &DebugInfo, in initializeDebugInfo()
114 const llvm::Module &Module) { in initializeDebugInfo()
115 llvm::LLVMContext &ctx = Module.getContext(); in initializeDebugInfo()
118 DebugInfo.createCompileUnit(llvm::dwarf::DW_LANG_GOOGLE_RenderScript, in initializeDebugInfo()
127 llvm::NamedMDNode *mdCompileUnitList = in initializeDebugInfo()
132 llvm::DIGlobalVariable *kernelPrototypeVarMD = nullptr; in initializeDebugInfo()
133 for (llvm::MDNode* CUNode : mdCompileUnitList->operands()) { in initializeDebugInfo()
134 if (auto *CU = llvm::dyn_cast<llvm::DICompileUnit>(CUNode)) { in initializeDebugInfo()
135 for (llvm::DIGlobalVariable* GV : CU->getGlobalVariables()) { in initializeDebugInfo()
148 llvm::MDTuple *kernelPrototypeMD = nullptr; in initializeDebugInfo()
151 llvm::DIDerivedType *DT = nullptr; in initializeDebugInfo()
152 DT = llvm::cast<llvm::DIDerivedType>(kernelPrototypeVarMD->getType()); in initializeDebugInfo()
153 DT = llvm::cast<llvm::DIDerivedType>(DT->getBaseType()); in initializeDebugInfo()
154 llvm::DISubroutineType *ST = llvm::cast<llvm::DISubroutineType>(DT->getBaseType()); in initializeDebugInfo()
155 kernelPrototypeMD = llvm::cast<llvm::MDTuple>(ST->getRawTypeArray()); in initializeDebugInfo()
157 indexVarType = llvm::dyn_cast_or_null<llvm::DIType>( in initializeDebugInfo()
162 kernelPrototypeMD = llvm::MDTuple::get(ctx, {nullptr}); in initializeDebugInfo()
166 llvm::dwarf::DW_ATE_unsigned); in initializeDebugInfo()
180 void attachDebugInfo(llvm::DIBuilder &DebugInfo, llvm::Function &Func) { in attachDebugInfo()
182 llvm::AllocaInst* indexVar = nullptr; in attachDebugInfo()
183 for (llvm::Instruction &inst : llvm::instructions(Func)) { in attachDebugInfo()
184 if (auto *allocaInst = llvm::dyn_cast<llvm::AllocaInst>(&inst)) { in attachDebugInfo()
193 llvm::DISubprogram *ExpandedFunc = DebugInfo.createFunction( in attachDebugInfo()
202 llvm::IRBuilder<> ir(&*Func.getEntryBlock().begin()); in attachDebugInfo()
208 llvm::MDTuple *argTypes = kernelTypeMD->getTypeArray().get(); in attachDebugInfo()
209 for (llvm::Argument &arg : Func.getArgumentList()) { in attachDebugInfo()
215 llvm::DILocalVariable *argVarDI = DebugInfo.createParameterVariable( in attachDebugInfo()
217 llvm::cast<llvm::DIType>(argTypes->getOperand(argIdx).get()), in attachDebugInfo()
222 llvm::AllocaInst *argVar = in attachDebugInfo()
224 llvm::StoreInst *argStore = ir.CreateStore(&arg, argVar); in attachDebugInfo()
225 llvm::LoadInst *loadedVar = ir.CreateLoad(argVar, arg.getName() + ".l"); in attachDebugInfo()
227 llvm::DebugLoc::get(1, 1, ExpandedFunc), loadedVar); in attachDebugInfo()
228 for (llvm::Use &u : arg.uses()) in attachDebugInfo()
237 llvm::DILocalVariable *indexVarDI = DebugInfo.createAutoVariable( in attachDebugInfo()
243 llvm::Instruction *decl = DebugInfo.insertDeclare( in attachDebugInfo()
245 llvm::DebugLoc::get(1, 1, ExpandedFunc), indexVar); in attachDebugInfo()
250 for (llvm::Instruction &inst : llvm::instructions(Func)) { in attachDebugInfo()
251 inst.setDebugLoc(llvm::DebugLoc::get(1, 1, ExpandedFunc)); in attachDebugInfo()
259 void cleanupDebugInfo(llvm::Module& Module) { in cleanupDebugInfo()
264 llvm::SmallVector<llvm::MDNode*, 4> unitsTmp; in cleanupDebugInfo()
265 llvm::NamedMDNode *debugMD = in cleanupDebugInfo()
267 for (llvm::MDNode *cu : debugMD->operands()) in cleanupDebugInfo()
272 for (llvm::MDNode *cu : unitsTmp) in cleanupDebugInfo()
278 llvm::DISubroutineType* kernelTypeMD;
279 llvm::DIFile *sourceFileName;
280 llvm::DIExpression *emptyExpr;
281 llvm::DICompileUnit *abiMetaCU;
282 llvm::DIType *indexVarType;
287 static llvm::RegisterPass<RSAddDebugInfoPass> X("addrsdi", "Add RS DebugInfo Pass");
293 llvm::ModulePass * createRSAddDebugInfoPass() { in createRSAddDebugInfoPass()