From f3b9ba49419b9d541f639414eadfb0efd4e2a784 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Fri, 29 Jan 2016 18:16:43 +0000 Subject: [codeview] Begin to add support for inlined call sites Summary: There are three parts to inlined call frames: 1. The inlinee line subsection 2. The inline site symbol record 3. The function ids referenced by both This change starts by emitting function ids (3) for all subprograms and emitting the base inline site symbol record (2). The actual line numbers in (2) use an encoded format that will come next, along with the inlinee line subsection. Reviewers: majnemer Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D16333 llvm-svn: 259217 --- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h | 30 ++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h') diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h index 77b5ed39c1f..4883905e907 100644 --- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h +++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h @@ -22,6 +22,7 @@ #include "llvm/CodeGen/LexicalScopes.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineModuleInfo.h" +#include "llvm/DebugInfo/CodeView/TypeIndex.h" #include "llvm/IR/DebugInfo.h" #include "llvm/IR/DebugLoc.h" #include "llvm/MC/MCStreamer.h" @@ -33,19 +34,31 @@ class LLVM_LIBRARY_VISIBILITY CodeViewDebug : public AsmPrinterHandler { AsmPrinter *Asm; DebugLoc PrevInstLoc; + struct InlineSite { + TinyPtrVector ChildSites; + const DISubprogram *Inlinee = nullptr; + unsigned SiteFuncId = 0; + }; + // For each function, store a vector of labels to its instructions, as well as // to the end of the function. struct FunctionInfo { + /// Map from inlined call site to inlined instructions and child inlined + /// call sites. Listed in program order. + MapVector InlineSites; + DebugLoc LastLoc; MCSymbol *End = nullptr; unsigned FuncId = 0; - unsigned LastFileId; + unsigned LastFileId = 0; bool HaveLineInfo = false; }; FunctionInfo *CurFn; unsigned NextFuncId = 0; + InlineSite &getInlineSite(const DILocation *Loc); + /// Remember some debug info about each function. Keep it in a stable order to /// emit at the end of the TU. MapVector FnDebugInfo; @@ -53,6 +66,16 @@ class LLVM_LIBRARY_VISIBILITY CodeViewDebug : public AsmPrinterHandler { /// Map from DIFile to .cv_file id. DenseMap FileIdMap; + DenseMap SubprogramToFuncId; + + unsigned TypeCount = 0; + + /// Gets the next type index and increments the count of types streamed so + /// far. + codeview::TypeIndex getNextTypeIndex() { + return codeview::TypeIndex(codeview::TypeIndex::FirstNonSimpleIndex + TypeCount++); + } + typedef std::map FileToFilepathMapTy; FileToFilepathMapTy FileToFilepathMap; StringRef getFullFilepath(const DIFile *S); @@ -68,8 +91,13 @@ class LLVM_LIBRARY_VISIBILITY CodeViewDebug : public AsmPrinterHandler { FileToFilepathMap.clear(); } + void emitTypeInformation(); + void emitDebugInfoForFunction(const Function *GV, FunctionInfo &FI); + void emitInlinedCallSite(const FunctionInfo &FI, const DILocation *InlinedAt, + const InlineSite &Site); + public: CodeViewDebug(AsmPrinter *Asm); -- cgit v1.2.3