diff options
author | Brock Wyma <brock.wyma@intel.com> | 2018-03-15 11:52:17 +0000 |
---|---|---|
committer | Brock Wyma <brock.wyma@intel.com> | 2018-03-15 11:52:17 +0000 |
commit | 3cc5710cec68e41bca7a073b4a0ade31a9d12da6 (patch) | |
tree | 9705855cd65ea7babee55f39b0cdf00bc95470c4 /llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h | |
parent | 194a407bda2b604ca0e43edbb56ce51989a7dc0a (diff) | |
download | llvm-3cc5710cec68e41bca7a073b4a0ade31a9d12da6.zip llvm-3cc5710cec68e41bca7a073b4a0ade31a9d12da6.tar.gz llvm-3cc5710cec68e41bca7a073b4a0ade31a9d12da6.tar.bz2 |
[CodeView] Initial support for emitting S_BLOCK32 symbols for lexical scopes
This patch sorts local variables by lexical scope and emits them inside
an appropriate S_BLOCK32 CodeView symbol.
Differential Revision: https://reviews.llvm.org/D42926
llvm-svn: 327620
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h index fdc8dd4..821879e 100644 --- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h +++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h @@ -107,6 +107,15 @@ class LLVM_LIBRARY_VISIBILITY CodeViewDebug : public DebugHandlerBase { unsigned SiteFuncId = 0; }; + // Combines information from DILexicalBlock and LexicalScope. + struct LexicalBlock { + SmallVector<LocalVariable, 1> Locals; + SmallVector<LexicalBlock *, 1> Children; + const MCSymbol *Begin; + const MCSymbol *End; + StringRef Name; + }; + // For each function, store a vector of labels to its instructions, as well as // to the end of the function. struct FunctionInfo { @@ -119,6 +128,11 @@ class LLVM_LIBRARY_VISIBILITY CodeViewDebug : public DebugHandlerBase { SmallVector<LocalVariable, 1> Locals; + std::unordered_map<const DILexicalBlockBase*, LexicalBlock> LexicalBlocks; + + // Lexical blocks containing local variables. + SmallVector<LexicalBlock *, 1> ChildBlocks; + std::vector<std::pair<MCSymbol *, MDNode *>> Annotations; const MCSymbol *Begin = nullptr; @@ -129,6 +143,12 @@ class LLVM_LIBRARY_VISIBILITY CodeViewDebug : public DebugHandlerBase { }; FunctionInfo *CurFn = nullptr; + // Map used to seperate variables according to the lexical scope they belong + // in. This is populated by recordLocalVariable() before + // collectLexicalBlocks() separates the variables between the FunctionInfo + // and LexicalBlocks. + DenseMap<const LexicalScope *, SmallVector<LocalVariable, 1>> ScopeVariables; + /// The set of comdat .debug$S sections that we've seen so far. Each section /// must start with a magic version number that must only be emitted once. /// This set tracks which sections we've already opened. @@ -253,9 +273,18 @@ class LLVM_LIBRARY_VISIBILITY CodeViewDebug : public DebugHandlerBase { void collectVariableInfoFromMFTable(DenseSet<InlinedVariable> &Processed); + // Construct the lexical block tree for a routine, pruning emptpy lexical + // scopes, and populate it with local variables. + void collectLexicalBlockInfo(SmallVectorImpl<LexicalScope *> &Scopes, + SmallVectorImpl<LexicalBlock *> &Blocks, + SmallVectorImpl<LocalVariable> &Locals); + void collectLexicalBlockInfo(LexicalScope &Scope, + SmallVectorImpl<LexicalBlock *> &ParentBlocks, + SmallVectorImpl<LocalVariable> &ParentLocals); + /// Records information about a local variable in the appropriate scope. In /// particular, locals from inlined code live inside the inlining site. - void recordLocalVariable(LocalVariable &&Var, const DILocation *Loc); + void recordLocalVariable(LocalVariable &&Var, const LexicalScope *LS); /// Emits local variables in the appropriate order. void emitLocalVariableList(ArrayRef<LocalVariable> Locals); @@ -263,6 +292,13 @@ class LLVM_LIBRARY_VISIBILITY CodeViewDebug : public DebugHandlerBase { /// Emits an S_LOCAL record and its associated defined ranges. void emitLocalVariable(const LocalVariable &Var); + /// Emits a sequence of lexical block scopes and their children. + void emitLexicalBlockList(ArrayRef<LexicalBlock *> Blocks, + const FunctionInfo& FI); + + /// Emit a lexical block scope and its children. + void emitLexicalBlock(const LexicalBlock &Block, const FunctionInfo& FI); + /// Translates the DIType to codeview if necessary and returns a type index /// for it. codeview::TypeIndex getTypeIndex(DITypeRef TypeRef, |