diff options
author | Brock Wyma <brock.wyma@intel.com> | 2018-12-20 17:33:45 +0000 |
---|---|---|
committer | Brock Wyma <brock.wyma@intel.com> | 2018-12-20 17:33:45 +0000 |
commit | b17464e4e85bd31a566aefebb8e60e53acbe6c71 (patch) | |
tree | 61c8c51bd262bdc754c0a99e955cd6fb39f936b3 /llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h | |
parent | 79d6a7988b43f49f6e41f6d17234beb3f9138165 (diff) | |
download | bcm5719-llvm-b17464e4e85bd31a566aefebb8e60e53acbe6c71.tar.gz bcm5719-llvm-b17464e4e85bd31a566aefebb8e60e53acbe6c71.zip |
[CodeView] Emit global variables within lexical scopes to limit visibility
Emit static locals within the correct lexical scope so variables with the same
name will not confuse the debugger into getting the wrong value.
Differential Revision: https://reviews.llvm.org/D55336
llvm-svn: 349777
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h index fcc7c3290eb..1c2b9bf4d4b 100644 --- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h +++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h @@ -99,6 +99,11 @@ class LLVM_LIBRARY_VISIBILITY CodeViewDebug : public DebugHandlerBase { bool UseReferenceType = false; }; + struct CVGlobalVariable { + const DIGlobalVariable *DIGV; + const GlobalVariable *GV; + }; + struct InlineSite { SmallVector<LocalVariable, 1> InlinedLocals; SmallVector<const DILocation *, 1> ChildSites; @@ -112,6 +117,7 @@ class LLVM_LIBRARY_VISIBILITY CodeViewDebug : public DebugHandlerBase { // Combines information from DILexicalBlock and LexicalScope. struct LexicalBlock { SmallVector<LocalVariable, 1> Locals; + SmallVector<CVGlobalVariable, 1> Globals; SmallVector<LexicalBlock *, 1> Children; const MCSymbol *Begin; const MCSymbol *End; @@ -134,6 +140,7 @@ class LLVM_LIBRARY_VISIBILITY CodeViewDebug : public DebugHandlerBase { SmallVector<const DILocation *, 1> ChildSites; SmallVector<LocalVariable, 1> Locals; + SmallVector<CVGlobalVariable, 1> Globals; std::unordered_map<const DILexicalBlockBase*, LexicalBlock> LexicalBlocks; @@ -183,6 +190,17 @@ class LLVM_LIBRARY_VISIBILITY CodeViewDebug : public DebugHandlerBase { // and LexicalBlocks. DenseMap<const LexicalScope *, SmallVector<LocalVariable, 1>> ScopeVariables; + // Map to separate global variables according to the lexical scope they + // belong in. A null local scope represents the global scope. + typedef SmallVector<CVGlobalVariable, 1> GlobalVariableList; + DenseMap<const DIScope*, std::unique_ptr<GlobalVariableList> > ScopeGlobals; + + // Array of global variables which need to be emitted into a COMDAT section. + SmallVector<CVGlobalVariable, 1> ComdatVariables; + + // Array of non-COMDAT global variables. + SmallVector<CVGlobalVariable, 1> GlobalVariables; + /// 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. @@ -288,13 +306,13 @@ class LLVM_LIBRARY_VISIBILITY CodeViewDebug : public DebugHandlerBase { void emitDebugInfoForFunction(const Function *GV, FunctionInfo &FI); - void emitDebugInfoForGlobals(); - void emitDebugInfoForRetainedTypes(); void emitDebugInfoForUDTs(ArrayRef<std::pair<std::string, const DIType *>> UDTs); + void emitDebugInfoForGlobals(); + void emitGlobalVariableList(ArrayRef<CVGlobalVariable> Globals); void emitDebugInfoForGlobal(const DIGlobalVariable *DIGV, const GlobalVariable *GV, MCSymbol *GVSym); @@ -319,6 +337,7 @@ class LLVM_LIBRARY_VISIBILITY CodeViewDebug : public DebugHandlerBase { using InlinedEntity = DbgValueHistoryMap::InlinedEntity; + void collectGlobalVariableInfo(); void collectVariableInfo(const DISubprogram *SP); void collectVariableInfoFromMFTable(DenseSet<InlinedEntity> &Processed); @@ -327,10 +346,12 @@ class LLVM_LIBRARY_VISIBILITY CodeViewDebug : public DebugHandlerBase { // scopes, and populate it with local variables. void collectLexicalBlockInfo(SmallVectorImpl<LexicalScope *> &Scopes, SmallVectorImpl<LexicalBlock *> &Blocks, - SmallVectorImpl<LocalVariable> &Locals); + SmallVectorImpl<LocalVariable> &Locals, + SmallVectorImpl<CVGlobalVariable> &Globals); void collectLexicalBlockInfo(LexicalScope &Scope, SmallVectorImpl<LexicalBlock *> &ParentBlocks, - SmallVectorImpl<LocalVariable> &ParentLocals); + SmallVectorImpl<LocalVariable> &ParentLocals, + SmallVectorImpl<CVGlobalVariable> &ParentGlobals); /// Records information about a local variable in the appropriate scope. In /// particular, locals from inlined code live inside the inlining site. |