From e018bbd83594507171bc731b2d922fe0eed64595 Mon Sep 17 00:00:00 2001 From: Wolfgang Pieb Date: Wed, 19 Jul 2017 19:36:40 +0000 Subject: Fixing an issue with the initialization of LexicalScopes objects when mixing debug and non-debug units. Patch by Andrea DiBiagio. Differential Revision: https://reviews.llvm.org/D35637 llvm-svn: 308513 --- llvm/lib/CodeGen/LexicalScopes.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'llvm/lib/CodeGen/LexicalScopes.cpp') diff --git a/llvm/lib/CodeGen/LexicalScopes.cpp b/llvm/lib/CodeGen/LexicalScopes.cpp index 995c58a6356..47ab4ef65c7 100644 --- a/llvm/lib/CodeGen/LexicalScopes.cpp +++ b/llvm/lib/CodeGen/LexicalScopes.cpp @@ -47,11 +47,11 @@ void LexicalScopes::reset() { /// initialize - Scan machine function and constuct lexical scope nest. void LexicalScopes::initialize(const MachineFunction &Fn) { + reset(); // Don't attempt any lexical scope creation for a NoDebug compile unit. if (Fn.getFunction()->getSubprogram()->getUnit()->getEmissionKind() == DICompileUnit::NoDebug) return; - reset(); MF = &Fn; SmallVector MIRanges; DenseMap MI2ScopeMap; @@ -277,7 +277,9 @@ void LexicalScopes::assignInstructionRanges( /// DebugLoc. void LexicalScopes::getMachineBasicBlocks( const DILocation *DL, SmallPtrSetImpl &MBBs) { + assert(MF && "Method called on a uninitialized LexicalScopes object!"); MBBs.clear(); + LexicalScope *Scope = getOrCreateLexicalScope(DL); if (!Scope) return; @@ -296,6 +298,7 @@ void LexicalScopes::getMachineBasicBlocks( /// dominates - Return true if DebugLoc's lexical scope dominates at least one /// machine instruction's lexical scope in a given machine basic block. bool LexicalScopes::dominates(const DILocation *DL, MachineBasicBlock *MBB) { + assert(MF && "Unexpected uninitialized LexicalScopes object!"); LexicalScope *Scope = getOrCreateLexicalScope(DL); if (!Scope) return false; -- cgit v1.2.3