Skip to content
DwarfDebug.cpp 83.3 KiB
Newer Older
2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428

  for (Value::use_iterator UI = RootC->use_begin(), UE = Root->use_end();
       UI != UE; ++UI)
    for (Value::use_iterator UUI = UI->use_begin(), UUE = UI->use_end();
         UUI != UUE; ++UUI) {
      GlobalVariable *GV = cast<GlobalVariable>(*UUI);
      ConstructCompileUnit(GV);
    }
}

bool DwarfDebug::ConstructGlobalVariableDIE(GlobalVariable *GV) {
  DIGlobalVariable DI_GV(GV);
  CompileUnit *DW_Unit = MainCU;
  if (!DW_Unit)
    DW_Unit = &FindCompileUnit(DI_GV.getCompileUnit());

  // Check for pre-existence.
  DIE *&Slot = DW_Unit->getDieMapSlotFor(DI_GV.getGV());
  if (Slot)
    return false;

  DIE *VariableDie = CreateGlobalVariableDIE(DW_Unit, DI_GV);

  // Add address.
  DIEBlock *Block = new DIEBlock();
  AddUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_addr);
  std::string GLN;
  AddObjectLabel(Block, 0, dwarf::DW_FORM_udata,
                 Asm->getGlobalLinkName(DI_GV.getGlobal(), GLN));
  AddBlock(VariableDie, dwarf::DW_AT_location, 0, Block);

  // Add to map.
  Slot = VariableDie;

  // Add to context owner.
  DW_Unit->getDie()->AddChild(VariableDie);

  // Expose as global. FIXME - need to check external flag.
  std::string Name;
  DW_Unit->AddGlobal(DI_GV.getName(Name), VariableDie);
  return true;
}

/// ConstructGlobalVariableDIEs - Create DIEs for each of the externally visible
/// global variables. Return true if at least one global DIE is created.
bool DwarfDebug::ConstructGlobalVariableDIEs() {
  GlobalVariable *Root = M->getGlobalVariable("llvm.dbg.global_variables");
  if (!Root)
    return false;

  assert(Root->hasLinkOnceLinkage() && Root->hasOneUse() &&
         "Malformed global variable descriptor anchor type");
  Constant *RootC = cast<Constant>(*Root->use_begin());
  assert(RootC->hasNUsesOrMore(1) &&
         "Malformed global variable descriptor anchor type");

  bool Result = false;
  for (Value::use_iterator UI = RootC->use_begin(), UE = Root->use_end();
       UI != UE; ++UI)
    for (Value::use_iterator UUI = UI->use_begin(), UUE = UI->use_end();
         UUI != UUE; ++UUI)
      Result |= ConstructGlobalVariableDIE(cast<GlobalVariable>(*UUI));

  return Result;
}

bool DwarfDebug::ConstructSubprogram(GlobalVariable *GV) {
  DISubprogram SP(GV);
  CompileUnit *Unit = MainCU;
  if (!Unit)
    Unit = &FindCompileUnit(SP.getCompileUnit());

  // Check for pre-existence.
  DIE *&Slot = Unit->getDieMapSlotFor(GV);
  if (Slot)
    return false;

  if (!SP.isDefinition())
    // This is a method declaration which will be handled while constructing
    // class type.
    return false;

  DIE *SubprogramDie = CreateSubprogramDIE(Unit, SP);

  // Add to map.
  Slot = SubprogramDie;

  // Add to context owner.
  Unit->getDie()->AddChild(SubprogramDie);

  // Expose as global.
  std::string Name;
  Unit->AddGlobal(SP.getName(Name), SubprogramDie);
  return true;
}

/// ConstructSubprograms - Create DIEs for each of the externally visible
/// subprograms. Return true if at least one subprogram DIE is created.
bool DwarfDebug::ConstructSubprograms() {
  GlobalVariable *Root = M->getGlobalVariable("llvm.dbg.subprograms");
  if (!Root)
    return false;

  assert(Root->hasLinkOnceLinkage() && Root->hasOneUse() &&
         "Malformed subprogram descriptor anchor type");
  Constant *RootC = cast<Constant>(*Root->use_begin());
  assert(RootC->hasNUsesOrMore(1) &&
         "Malformed subprogram descriptor anchor type");

  bool Result = false;
  for (Value::use_iterator UI = RootC->use_begin(), UE = Root->use_end();
       UI != UE; ++UI)
    for (Value::use_iterator UUI = UI->use_begin(), UUE = UI->use_end();
         UUI != UUE; ++UUI)
      Result |= ConstructSubprogram(cast<GlobalVariable>(*UUI));

  return Result;
}

/// SetDebugInfo - Create global DIEs and emit initial debug info sections.
/// This is inovked by the target AsmPrinter.
void DwarfDebug::SetDebugInfo(MachineModuleInfo *mmi) {
  if (TimePassesIsEnabled)
    DebugTimer->startTimer();

  // Create all the compile unit DIEs.
  ConstructCompileUnits();

  if (CompileUnits.empty()) {
    if (TimePassesIsEnabled)
      DebugTimer->stopTimer();

    return;
  }

  // Create DIEs for each of the externally visible global variables.
  bool globalDIEs = ConstructGlobalVariableDIEs();

  // Create DIEs for each of the externally visible subprograms.
  bool subprogramDIEs = ConstructSubprograms();

  // If there is not any debug info available for any global variables and any
  // subprograms then there is not any debug info to emit.
  if (!globalDIEs && !subprogramDIEs) {
    if (TimePassesIsEnabled)
      DebugTimer->stopTimer();

    return;
  }

  MMI = mmi;
  shouldEmit = true;
  MMI->setDebugInfoAvailability(true);

  // Prime section data.
  SectionMap.insert(TAI->getTextSection());

  // Print out .file directives to specify files for .loc directives. These are
  // printed out early so that they precede any .loc directives.
  if (TAI->hasDotLocAndDotFile()) {
    for (unsigned i = 1, e = getNumSourceIds()+1; i != e; ++i) {
      // Remember source id starts at 1.
      std::pair<unsigned, unsigned> Id = getSourceDirectoryAndFileIds(i);
      sys::Path FullPath(getSourceDirectoryName(Id.first));
      bool AppendOk =
        FullPath.appendComponent(getSourceFileName(Id.second));
      assert(AppendOk && "Could not append filename to directory!");
      AppendOk = false;
      Asm->EmitFile(i, FullPath.toString());
      Asm->EOL();
    }
  }

  // Emit initial sections
  EmitInitial();

  if (TimePassesIsEnabled)
    DebugTimer->stopTimer();
}

/// EndModule - Emit all Dwarf sections that should come after the content.
///
void DwarfDebug::EndModule() {
  if (!ShouldEmitDwarfDebug())
    return;

  if (TimePassesIsEnabled)
    DebugTimer->startTimer();

  // Standard sections final addresses.
  Asm->SwitchToSection(TAI->getTextSection());
  EmitLabel("text_end", 0);
  Asm->SwitchToSection(TAI->getDataSection());
  EmitLabel("data_end", 0);

  // End text sections.
  for (unsigned i = 1, N = SectionMap.size(); i <= N; ++i) {
    Asm->SwitchToSection(SectionMap[i]);
    EmitLabel("section_end", i);
  }

  // Emit common frame information.
  EmitCommonDebugFrame();

  // Emit function debug frame information
  for (std::vector<FunctionDebugFrameInfo>::iterator I = DebugFrames.begin(),
         E = DebugFrames.end(); I != E; ++I)
    EmitFunctionDebugFrame(*I);

  // Compute DIE offsets and sizes.
  SizeAndOffsets();

  // Emit all the DIEs into a debug info section
  EmitDebugInfo();

  // Corresponding abbreviations into a abbrev section.
  EmitAbbreviations();

  // Emit source line correspondence into a debug line section.
  EmitDebugLines();

  // Emit info into a debug pubnames section.
  EmitDebugPubNames();

  // Emit info into a debug str section.
  EmitDebugStr();

  // Emit info into a debug loc section.
  EmitDebugLoc();

  // Emit info into a debug aranges section.
  EmitDebugARanges();

  // Emit info into a debug ranges section.
  EmitDebugRanges();

  // Emit info into a debug macinfo section.
  EmitDebugMacInfo();

  // Emit inline info.
  EmitDebugInlineInfo();

  if (TimePassesIsEnabled)
    DebugTimer->stopTimer();
}

/// BeginFunction - Gather pre-function debug information.  Assumes being
/// emitted immediately after the function entry point.
void DwarfDebug::BeginFunction(MachineFunction *MF) {
  this->MF = MF;

  if (!ShouldEmitDwarfDebug()) return;

  if (TimePassesIsEnabled)
    DebugTimer->startTimer();

  // Begin accumulating function debug information.
  MMI->BeginFunction(MF);

  // Assumes in correct section after the entry point.
  EmitLabel("func_begin", ++SubprogramCount);

  // Emit label for the implicitly defined dbg.stoppoint at the start of the
  // function.
  DebugLoc FDL = MF->getDefaultDebugLoc();
  if (!FDL.isUnknown()) {
    DebugLocTuple DLT = MF->getDebugLocTuple(FDL);
    unsigned LabelID = RecordSourceLine(DLT.Line, DLT.Col,
                                        DICompileUnit(DLT.CompileUnit));
    Asm->printLabel(LabelID);
  }

  if (TimePassesIsEnabled)
    DebugTimer->stopTimer();
}

/// EndFunction - Gather and emit post-function debug information.
///
void DwarfDebug::EndFunction(MachineFunction *MF) {
  if (!ShouldEmitDwarfDebug()) return;

  if (TimePassesIsEnabled)
    DebugTimer->startTimer();

  // Define end label for subprogram.
  EmitLabel("func_end", SubprogramCount);

  // Get function line info.
  if (!Lines.empty()) {
    // Get section line info.
    unsigned ID = SectionMap.insert(Asm->CurrentSection_);
    if (SectionSourceLines.size() < ID) SectionSourceLines.resize(ID);
    std::vector<SrcLineInfo> &SectionLineInfos = SectionSourceLines[ID-1];
    // Append the function info to section info.
    SectionLineInfos.insert(SectionLineInfos.end(),
                            Lines.begin(), Lines.end());
  }

  // Construct the DbgScope for abstract instances.
  for (SmallVector<DbgScope *, 32>::iterator
         I = AbstractInstanceRootList.begin(),
         E = AbstractInstanceRootList.end(); I != E; ++I)
    ConstructAbstractDbgScope(*I);

  // Construct scopes for subprogram.
  if (FunctionDbgScope)
    ConstructFunctionDbgScope(FunctionDbgScope);
  else
    // FIXME: This is wrong. We are essentially getting past a problem with
    // debug information not being able to handle unreachable blocks that have
    // debug information in them. In particular, those unreachable blocks that
    // have "region end" info in them. That situation results in the "root
    // scope" not being created. If that's the case, then emit a "default"
    // scope, i.e., one that encompasses the whole function. This isn't
    // desirable. And a better way of handling this (and all of the debugging
    // information) needs to be explored.
    ConstructDefaultDbgScope(MF);

  DebugFrames.push_back(FunctionDebugFrameInfo(SubprogramCount,
                                               MMI->getFrameMoves()));

  // Clear debug info
  if (FunctionDbgScope) {
    delete FunctionDbgScope;
    DbgScopeMap.clear();
    DbgAbstractScopeMap.clear();
    DbgConcreteScopeMap.clear();
    InlinedVariableScopes.clear();
    FunctionDbgScope = NULL;
    LexicalScopeStack.clear();
    AbstractInstanceRootList.clear();
  }

  Lines.clear();

  if (TimePassesIsEnabled)
    DebugTimer->stopTimer();
}

/// RecordSourceLine - Records location information and associates it with a
/// label. Returns a unique label ID used to generate a label and provide
/// correspondence to the source line list.
unsigned DwarfDebug::RecordSourceLine(Value *V, unsigned Line, unsigned Col) {
  if (TimePassesIsEnabled)
    DebugTimer->startTimer();

  CompileUnit *Unit = CompileUnitMap[V];
  assert(Unit && "Unable to find CompileUnit");
  unsigned ID = MMI->NextLabelID();
  Lines.push_back(SrcLineInfo(Line, Col, Unit->getID(), ID));

  if (TimePassesIsEnabled)
    DebugTimer->stopTimer();

  return ID;
}

/// RecordSourceLine - Records location information and associates it with a
/// label. Returns a unique label ID used to generate a label and provide
/// correspondence to the source line list.
unsigned DwarfDebug::RecordSourceLine(unsigned Line, unsigned Col,
                                      DICompileUnit CU) {
  if (TimePassesIsEnabled)
    DebugTimer->startTimer();

  std::string Dir, Fn;
  unsigned Src = GetOrCreateSourceID(CU.getDirectory(Dir),
                                     CU.getFilename(Fn));
  unsigned ID = MMI->NextLabelID();
  Lines.push_back(SrcLineInfo(Line, Col, Src, ID));

  if (TimePassesIsEnabled)
    DebugTimer->stopTimer();

  return ID;
}

/// getOrCreateSourceID - Public version of GetOrCreateSourceID. This can be
/// timed. Look up the source id with the given directory and source file
/// names. If none currently exists, create a new id and insert it in the
/// SourceIds map. This can update DirectoryNames and SourceFileNames maps as
/// well.
unsigned DwarfDebug::getOrCreateSourceID(const std::string &DirName,
                                         const std::string &FileName) {
  if (TimePassesIsEnabled)
    DebugTimer->startTimer();

  unsigned SrcId = GetOrCreateSourceID(DirName, FileName);

  if (TimePassesIsEnabled)
    DebugTimer->stopTimer();

  return SrcId;
}

/// RecordRegionStart - Indicate the start of a region.
unsigned DwarfDebug::RecordRegionStart(GlobalVariable *V) {
  if (TimePassesIsEnabled)
    DebugTimer->startTimer();

  DbgScope *Scope = getOrCreateScope(V);
  unsigned ID = MMI->NextLabelID();
  if (!Scope->getStartLabelID()) Scope->setStartLabelID(ID);
  LexicalScopeStack.push_back(Scope);

  if (TimePassesIsEnabled)
    DebugTimer->stopTimer();

  return ID;
}

/// RecordRegionEnd - Indicate the end of a region.
unsigned DwarfDebug::RecordRegionEnd(GlobalVariable *V) {
  if (TimePassesIsEnabled)
    DebugTimer->startTimer();

  DbgScope *Scope = getOrCreateScope(V);
  unsigned ID = MMI->NextLabelID();
  Scope->setEndLabelID(ID);
  if (LexicalScopeStack.size() != 0)
    LexicalScopeStack.pop_back();

  if (TimePassesIsEnabled)
    DebugTimer->stopTimer();

  return ID;
}

/// RecordVariable - Indicate the declaration of a local variable.
void DwarfDebug::RecordVariable(GlobalVariable *GV, unsigned FrameIndex,
                                const MachineInstr *MI) {
  if (TimePassesIsEnabled)
    DebugTimer->startTimer();

  DIDescriptor Desc(GV);
  DbgScope *Scope = NULL;

  if (Desc.getTag() == dwarf::DW_TAG_variable) {
    // GV is a global variable.
    DIGlobalVariable DG(GV);
    Scope = getOrCreateScope(DG.getContext().getGV());
  } else {
    DenseMap<const MachineInstr *, DbgScope *>::iterator
      SI = InlinedVariableScopes.find(MI);

    if (SI != InlinedVariableScopes.end()) {
      // or GV is an inlined local variable.
      Scope = SI->second;
    } else {
      DIVariable DV(GV);
      GlobalVariable *V = DV.getContext().getGV();

      // FIXME: The code that checks for the inlined local variable is a hack!
      DenseMap<const GlobalVariable *, DbgScope *>::iterator
        AI = AbstractInstanceRootMap.find(V);

      if (AI != AbstractInstanceRootMap.end()) {
        // This method is called each time a DECLARE node is encountered. For an
        // inlined function, this could be many, many times. We don't want to
        // re-add variables to that DIE for each time. We just want to add them
        // once. Check to make sure that we haven't added them already.
        DenseMap<const GlobalVariable *,
          SmallSet<const GlobalVariable *, 32> >::iterator
          IP = InlinedParamMap.find(V);

        if (IP != InlinedParamMap.end()) {
          SmallSet<const GlobalVariable*, 32> &S = IP->second;

          if (S.count(GV) > 0) {
            if (TimePassesIsEnabled)
              DebugTimer->stopTimer();
            return;
          }

        }

        // or GV is an inlined local variable.
        Scope = AI->second;
        // or GV is a local variable.
        Scope = getOrCreateScope(V);
    }
  }

  assert(Scope && "Unable to find the variable's scope");
  DbgVariable *DV = new DbgVariable(DIVariable(GV), FrameIndex);
  Scope->AddVariable(DV);

  if (TimePassesIsEnabled)
    DebugTimer->stopTimer();
}

//// RecordInlinedFnStart - Indicate the start of inlined subroutine.
unsigned DwarfDebug::RecordInlinedFnStart(DISubprogram &SP, DICompileUnit CU,
                                          unsigned Line, unsigned Col) {
  unsigned LabelID = MMI->NextLabelID();

  if (!TAI->doesDwarfUsesInlineInfoSection())
    return LabelID;

  if (TimePassesIsEnabled)
    DebugTimer->startTimer();

  GlobalVariable *GV = SP.getGV();
  DenseMap<const GlobalVariable *, DbgScope *>::iterator
    II = AbstractInstanceRootMap.find(GV);

  if (II == AbstractInstanceRootMap.end()) {
    // Create an abstract instance entry for this inlined function if it doesn't
    // already exist.
    DbgScope *Scope = new DbgScope(NULL, DIDescriptor(GV));

    // Get the compile unit context.
    CompileUnit *Unit = &FindCompileUnit(SP.getCompileUnit());
    DIE *SPDie = Unit->getDieMapSlotFor(GV);
    if (!SPDie)
      SPDie = CreateSubprogramDIE(Unit, SP, false, true);

    // Mark as being inlined. This makes this subprogram entry an abstract
    // instance root.
    // FIXME: Our debugger doesn't care about the value of DW_AT_inline, only
    // that it's defined. That probably won't change in the future. However,
    // this could be more elegant.
    AddUInt(SPDie, dwarf::DW_AT_inline, 0, dwarf::DW_INL_declared_not_inlined);

    // Keep track of the abstract scope for this function.
    DbgAbstractScopeMap[GV] = Scope;

    AbstractInstanceRootMap[GV] = Scope;
    AbstractInstanceRootList.push_back(Scope);
  }

  // Create a concrete inlined instance for this inlined function.
  DbgConcreteScope *ConcreteScope = new DbgConcreteScope(DIDescriptor(GV));
  DIE *ScopeDie = new DIE(dwarf::DW_TAG_inlined_subroutine);
  CompileUnit *Unit = &FindCompileUnit(SP.getCompileUnit());
  ScopeDie->setAbstractCompileUnit(Unit);

  DIE *Origin = Unit->getDieMapSlotFor(GV);
  AddDIEEntry(ScopeDie, dwarf::DW_AT_abstract_origin,
              dwarf::DW_FORM_ref4, Origin);
  AddUInt(ScopeDie, dwarf::DW_AT_call_file, 0, Unit->getID());
  AddUInt(ScopeDie, dwarf::DW_AT_call_line, 0, Line);
  AddUInt(ScopeDie, dwarf::DW_AT_call_column, 0, Col);

  ConcreteScope->setDie(ScopeDie);
  ConcreteScope->setStartLabelID(LabelID);
  MMI->RecordUsedDbgLabel(LabelID);

  LexicalScopeStack.back()->AddConcreteInst(ConcreteScope);

  // Keep track of the concrete scope that's inlined into this function.
  DenseMap<GlobalVariable *, SmallVector<DbgScope *, 8> >::iterator
    SI = DbgConcreteScopeMap.find(GV);

  if (SI == DbgConcreteScopeMap.end())
    DbgConcreteScopeMap[GV].push_back(ConcreteScope);
  else
    SI->second.push_back(ConcreteScope);

  // Track the start label for this inlined function.
  DenseMap<GlobalVariable *, SmallVector<unsigned, 4> >::iterator
    I = InlineInfo.find(GV);

  if (I == InlineInfo.end())
    InlineInfo[GV].push_back(LabelID);
  else
    I->second.push_back(LabelID);

  if (TimePassesIsEnabled)
    DebugTimer->stopTimer();

  return LabelID;
}

/// RecordInlinedFnEnd - Indicate the end of inlined subroutine.
unsigned DwarfDebug::RecordInlinedFnEnd(DISubprogram &SP) {
  if (!TAI->doesDwarfUsesInlineInfoSection())
    return 0;

  if (TimePassesIsEnabled)
    DebugTimer->startTimer();

  GlobalVariable *GV = SP.getGV();
  DenseMap<GlobalVariable *, SmallVector<DbgScope *, 8> >::iterator
    I = DbgConcreteScopeMap.find(GV);

  if (I == DbgConcreteScopeMap.end()) {
    // FIXME: Can this situation actually happen? And if so, should it?
    if (TimePassesIsEnabled)
      DebugTimer->stopTimer();

    return 0;
  }

  SmallVector<DbgScope *, 8> &Scopes = I->second;
  assert(!Scopes.empty() && "We should have at least one debug scope!");
  DbgScope *Scope = Scopes.back(); Scopes.pop_back();
  unsigned ID = MMI->NextLabelID();
  MMI->RecordUsedDbgLabel(ID);
  Scope->setEndLabelID(ID);

  if (TimePassesIsEnabled)
    DebugTimer->stopTimer();

  return ID;
}

/// RecordVariableScope - Record scope for the variable declared by
/// DeclareMI. DeclareMI must describe TargetInstrInfo::DECLARE. Record scopes
/// for only inlined subroutine variables. Other variables's scopes are
/// determined during RecordVariable().
void DwarfDebug::RecordVariableScope(DIVariable &DV,
                                     const MachineInstr *DeclareMI) {
  if (TimePassesIsEnabled)
    DebugTimer->startTimer();

  DISubprogram SP(DV.getContext().getGV());

  if (SP.isNull()) {
    if (TimePassesIsEnabled)
      DebugTimer->stopTimer();

    return;
  }

  DenseMap<GlobalVariable *, DbgScope *>::iterator
    I = DbgAbstractScopeMap.find(SP.getGV());
  if (I != DbgAbstractScopeMap.end())
    InlinedVariableScopes[DeclareMI] = I->second;

  if (TimePassesIsEnabled)
    DebugTimer->stopTimer();
}