[llvm] r363334 - Symbolize: Remove dead code. NFCI.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 13 15:49:34 PDT 2019


Author: pcc
Date: Thu Jun 13 15:49:34 2019
New Revision: 363334

URL: http://llvm.org/viewvc/llvm-project?rev=363334&view=rev
Log:
Symbolize: Remove dead code. NFCI.

The only caller of SymbolizableObjectFile::create passes a non-null
DebugInfoContext and asserts that they do so. Move the assert into
SymbolizableObjectFile::create and remove null checks.

Differential Revision: https://reviews.llvm.org/D63298

Modified:
    llvm/trunk/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
    llvm/trunk/lib/DebugInfo/Symbolize/Symbolize.cpp

Modified: llvm/trunk/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp?rev=363334&r1=363333&r2=363334&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp (original)
+++ llvm/trunk/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp Thu Jun 13 15:49:34 2019
@@ -44,6 +44,7 @@ getDILineInfoSpecifier(FunctionNameKind
 ErrorOr<std::unique_ptr<SymbolizableObjectFile>>
 SymbolizableObjectFile::create(object::ObjectFile *Obj,
                                std::unique_ptr<DIContext> DICtx) {
+  assert(DICtx);
   std::unique_ptr<SymbolizableObjectFile> res(
       new SymbolizableObjectFile(Obj, std::move(DICtx)));
   std::unique_ptr<DataExtractor> OpdExtractor;
@@ -244,16 +245,12 @@ DILineInfo
 SymbolizableObjectFile::symbolizeCode(object::SectionedAddress ModuleOffset,
                                       FunctionNameKind FNKind,
                                       bool UseSymbolTable) const {
-  DILineInfo LineInfo;
-
   if (ModuleOffset.SectionIndex == object::SectionedAddress::UndefSection)
     ModuleOffset.SectionIndex =
         getModuleSectionIndexForAddress(ModuleOffset.Address);
+  DILineInfo LineInfo = DebugInfoContext->getLineInfoForAddress(
+      ModuleOffset, getDILineInfoSpecifier(FNKind));
 
-  if (DebugInfoContext) {
-    LineInfo = DebugInfoContext->getLineInfoForAddress(
-        ModuleOffset, getDILineInfoSpecifier(FNKind));
-  }
   // Override function name from symbol table if necessary.
   if (shouldOverrideWithSymbolTable(FNKind, UseSymbolTable)) {
     std::string FunctionName;
@@ -269,15 +266,12 @@ SymbolizableObjectFile::symbolizeCode(ob
 DIInliningInfo SymbolizableObjectFile::symbolizeInlinedCode(
     object::SectionedAddress ModuleOffset, FunctionNameKind FNKind,
     bool UseSymbolTable) const {
-  DIInliningInfo InlinedContext;
-
   if (ModuleOffset.SectionIndex == object::SectionedAddress::UndefSection)
     ModuleOffset.SectionIndex =
         getModuleSectionIndexForAddress(ModuleOffset.Address);
+  DIInliningInfo InlinedContext = DebugInfoContext->getInliningInfoForAddress(
+      ModuleOffset, getDILineInfoSpecifier(FNKind));
 
-  if (DebugInfoContext)
-    InlinedContext = DebugInfoContext->getInliningInfoForAddress(
-        ModuleOffset, getDILineInfoSpecifier(FNKind));
   // Make sure there is at least one frame in context.
   if (InlinedContext.getNumberOfFrames() == 0)
     InlinedContext.addFrame(DILineInfo());

Modified: llvm/trunk/lib/DebugInfo/Symbolize/Symbolize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/Symbolize/Symbolize.cpp?rev=363334&r1=363333&r2=363334&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/Symbolize/Symbolize.cpp (original)
+++ llvm/trunk/lib/DebugInfo/Symbolize/Symbolize.cpp Thu Jun 13 15:49:34 2019
@@ -425,7 +425,6 @@ LLVMSymbolizer::getOrCreateModuleInfo(co
     Context =
         DWARFContext::create(*Objects.second, nullptr,
                              DWARFContext::defaultErrorHandler, Opts.DWPName);
-  assert(Context);
   auto InfoOrErr =
       SymbolizableObjectFile::create(Objects.first, std::move(Context));
   std::unique_ptr<SymbolizableModule> SymMod;




More information about the llvm-commits mailing list