[PATCH] D58952: [llvm] Skip over empty line table entries.

Mircea Trofin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 4 22:37:50 PST 2019


mtrofin updated this revision to Diff 189278.
mtrofin added a comment.

- Fix search.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58952/new/

https://reviews.llvm.org/D58952

Files:
  llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
  llvm/test/tools/llvm-symbolizer/fission-ranges.test
  llvm/test/tools/llvm-symbolizer/sym-verbose.test


Index: llvm/test/tools/llvm-symbolizer/sym-verbose.test
===================================================================
--- llvm/test/tools/llvm-symbolizer/sym-verbose.test
+++ llvm/test/tools/llvm-symbolizer/sym-verbose.test
@@ -19,8 +19,8 @@
 #CHECK-NEXT: foo
 #CHECK-NEXT: Filename: /tmp{{[\\/]}}discrim.c
 #CHECK-NEXT: Function start line: 4
-#CHECK-NEXT: Line: 9
-#CHECK-NEXT: Column: 0
+#CHECK-NEXT: Line: 5
+#CHECK-NEXT: Column: 7
 #CHECK-NEXT: main
 #CHECK-NEXT: Filename: /tmp{{[\\/]}}discrim.c
 #CHECK-NEXT: Function start line: 9
Index: llvm/test/tools/llvm-symbolizer/fission-ranges.test
===================================================================
--- llvm/test/tools/llvm-symbolizer/fission-ranges.test
+++ llvm/test/tools/llvm-symbolizer/fission-ranges.test
@@ -1,4 +1,4 @@
 RUN: llvm-symbolizer --obj=%p/Inputs/fission-ranges.elf-x86_64 0x720 | FileCheck %s
 
 CHECK: main
-CHECK-NEXT: {{.*}}fission-ranges.cc:6
+CHECK-NEXT: {{.*}}fission-ranges.cc:2
Index: llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
===================================================================
--- llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
@@ -867,11 +867,17 @@
   Row.Address = Address;
   RowIter FirstRow = Rows.begin() + Seq.FirstRowIndex;
   RowIter LastRow = Rows.begin() + Seq.LastRowIndex;
+  // In some cases, e.g. first instruction in a function, the compiler generates
+  // two entries, both with the same address. We want the last one.
   LineTable::RowIter RowPos = std::lower_bound(
       FirstRow, LastRow, Row, DWARFDebugLine::Row::orderByAddress);
   if (RowPos == LastRow) {
     return Seq.LastRowIndex - 1;
   }
+  while (RowPos->Address.Address == (RowPos + 1)->Address.Address &&
+         RowPos < LastRow) {
+    ++RowPos;
+  }
   assert(Seq.SectionIndex == RowPos->Address.SectionIndex);
   uint32_t Index = Seq.FirstRowIndex + (RowPos - FirstRow);
   if (RowPos->Address.Address > Address.Address) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58952.189278.patch
Type: text/x-patch
Size: 1981 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190305/decbbf5f/attachment.bin>


More information about the llvm-commits mailing list