Adding debug support to tinylang – Advanced IR Generation-3Adding debug support to tinylang – Advanced IR Generation-3

void CGDebugInfo::emitProcedureEnd(ProcedureDeclaration *Decl, llvm::Function *Fn) {if (Fn && Fn->getSubprogram())DBuilder.finalizeSubprogram(Fn->getSubprogram());closeScope();} void CGDebugInfo::finalize() { DBuilder.finalize(); } Debug information should only be generated if the user requested it. This means that we will [...]

Adding debug support to tinylang – Advanced IR Generation-2Adding debug support to tinylang – Advanced IR Generation-2

llvm::DIType *CGDebugInfo::getAliasType(AliasTypeDeclaration *Ty) {return DBuilder.createTypedef(getType(Ty->getType()), Ty->getName(),CU->getFile(), getLineNumber(Ty->getLocation()),getScope());} llvm::DIType *CGDebugInfo::getArrayType(ArrayTypeDeclaration *Ty) {auto *ATy =llvm::cast(CGM.convertType(Ty));const llvm::DataLayout &DL =CGM.getModule()->getDataLayout();Expr *Nums = Ty->getNums();uint64_t NumElements =llvm::cast(Nums)->getValue().getZExtValue();llvm::SmallVector Subscripts;Subscripts.push_back(DBuilder.getOrCreateSubrange(0, NumElements));return DBuilder.createArrayType(DL.getTypeSizeInBits(ATy) * 8,1 << Log2(DL.getABITypeAlign(ATy)), getType(Ty->getType()),DBuilder.getOrCreateArray(Subscripts));} llvm::DIType [...]

Adding debug support to tinylang – Advanced IR Generation-1Adding debug support to tinylang – Advanced IR Generation-1

We encapsulate the generation of debug metadata in the new CGDebugInfo class. Additionally, we place the declaration in the tinylang/CodeGen/CGDebugInfo.h header file and the definition in the tinylang/CodeGen/CGDebugInfo.cpp file.The CGDebugInfo [...]