[lld] 65b1c49 - [LLD] [COFF] Use the local dwarf code instead of Symbolizer for resolving code locations. NFC.

Martin Storsjo via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 21 01:00:56 PDT 2019


Author: Martin Storsjo
Date: 2019-10-21T08:01:59Z
New Revision: 65b1c497d2a6824ab23411611127dc0c3f17c400

URL: https://github.com/llvm/llvm-project/commit/65b1c497d2a6824ab23411611127dc0c3f17c400
DIFF: https://github.com/llvm/llvm-project/commit/65b1c497d2a6824ab23411611127dc0c3f17c400.diff

LOG: [LLD] [COFF] Use the local dwarf code instead of Symbolizer for resolving code locations. NFC.

As we now have code that parses the dwarf info for variable locations,
we can use that instead of relying on the higher level Symbolizer library,
reducing the previous two different dwarf codepaths into one.

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

llvm-svn: 375391

Added: 
    

Modified: 
    lld/COFF/CMakeLists.txt
    lld/COFF/Config.h
    lld/COFF/InputFiles.cpp
    lld/COFF/InputFiles.h
    lld/COFF/SymbolTable.cpp

Removed: 
    


################################################################################
diff  --git a/lld/COFF/CMakeLists.txt b/lld/COFF/CMakeLists.txt
index a30df7c4faac..7c5e8b79b7fe 100644
--- a/lld/COFF/CMakeLists.txt
+++ b/lld/COFF/CMakeLists.txt
@@ -38,7 +38,6 @@ add_lld_library(lldCOFF
   Object
   Option
   Support
-  Symbolize
   WindowsManifest
 
   LINK_LIBS

diff  --git a/lld/COFF/Config.h b/lld/COFF/Config.h
index cd597ddca4fa..309e1fbf99e3 100644
--- a/lld/COFF/Config.h
+++ b/lld/COFF/Config.h
@@ -18,12 +18,6 @@
 #include <set>
 #include <string>
 
-namespace llvm {
-namespace symbolize {
-class LLVMSymbolizer;
-}
-} // namespace llvm
-
 namespace lld {
 namespace coff {
 
@@ -232,8 +226,6 @@ struct Configuration {
   bool swaprunNet = false;
   bool thinLTOEmitImportsFiles;
   bool thinLTOIndexOnly;
-
-  llvm::symbolize::LLVMSymbolizer *symbolizer = nullptr;
 };
 
 extern Configuration *config;

diff  --git a/lld/COFF/InputFiles.cpp b/lld/COFF/InputFiles.cpp
index 4097cda59579..faec3ba160a5 100644
--- a/lld/COFF/InputFiles.cpp
+++ b/lld/COFF/InputFiles.cpp
@@ -807,6 +807,19 @@ ObjFile::getVariableLocation(StringRef var) {
   return std::make_pair(saver.save(ret->first), ret->second);
 }
 
+// Used only for DWARF debug info, which is not common (except in MinGW
+// environments).
+Optional<DILineInfo> ObjFile::getDILineInfo(uint32_t offset,
+                                            uint32_t sectionIndex) {
+  if (!dwarf) {
+    dwarf = make<DWARFCache>(DWARFContext::create(*getCOFFObj()));
+    if (!dwarf)
+      return None;
+  }
+
+  return dwarf->getDILineInfo(offset, sectionIndex);
+}
+
 StringRef ltrim1(StringRef s, const char *chars) {
   if (!s.empty() && strchr(chars, s[0]))
     return s.substr(1);

diff  --git a/lld/COFF/InputFiles.h b/lld/COFF/InputFiles.h
index 66249715e216..1004432c683f 100644
--- a/lld/COFF/InputFiles.h
+++ b/lld/COFF/InputFiles.h
@@ -26,6 +26,7 @@
 #include <vector>
 
 namespace llvm {
+struct DILineInfo;
 namespace pdb {
 class DbiModuleDescriptorBuilder;
 }
@@ -206,6 +207,9 @@ class ObjFile : public InputFile {
   llvm::Optional<std::pair<StringRef, uint32_t>>
   getVariableLocation(StringRef var);
 
+  llvm::Optional<llvm::DILineInfo> getDILineInfo(uint32_t offset,
+                                                 uint32_t sectionIndex);
+
 private:
   const coff_section* getSection(uint32_t i);
   const coff_section *getSection(COFFSymbolRef sym) {

diff  --git a/lld/COFF/SymbolTable.cpp b/lld/COFF/SymbolTable.cpp
index 183761f1c198..869dfc7a2ee5 100644
--- a/lld/COFF/SymbolTable.cpp
+++ b/lld/COFF/SymbolTable.cpp
@@ -110,13 +110,11 @@ static std::vector<std::string> getSymbolLocations(BitcodeFile *file) {
 
 static Optional<std::pair<StringRef, uint32_t>>
 getFileLineDwarf(const SectionChunk *c, uint32_t addr) {
-  if (!config->symbolizer)
-    config->symbolizer = make<symbolize::LLVMSymbolizer>();
-  Expected<DILineInfo> expectedLineInfo = config->symbolizer->symbolizeCode(
-      *c->file->getCOFFObj(), {addr, c->getSectionNumber() - 1});
-  if (!expectedLineInfo)
+  Optional<DILineInfo> optionalLineInfo =
+      c->file->getDILineInfo(addr, c->getSectionNumber() - 1);
+  if (!optionalLineInfo)
     return None;
-  const DILineInfo &lineInfo = *expectedLineInfo;
+  const DILineInfo &lineInfo = *optionalLineInfo;
   if (lineInfo.FileName == DILineInfo::BadString)
     return None;
   return std::make_pair(saver.save(lineInfo.FileName), lineInfo.Line);


        


More information about the llvm-commits mailing list