[PATCH] D59518: [DwarfDebug] Skip entries to big for 16 bit size field in Dwarf < 5.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 18 15:38:12 PDT 2019


fhahn created this revision.
fhahn added reviewers: probinson, aprantl, davide.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

Nothing prevents entries from being bigger than the 16 bit size field in
Dwarf < 5. For entries that are too big, there is nothing we can do
other than not emitting them, unless I missed something.

This fixes PR41038.

The minimal test case attached to the bug report is 500 KB as bitcode and
2.2 MB as IR. Not sure if it makes sense to attach it?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D59518

Files:
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp


Index: llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -1980,8 +1980,12 @@
   Asm->OutStreamer->AddComment("Loc expr size");
   if (getDwarfVersion() >= 5)
     Asm->EmitULEB128(DebugLocs.getBytes(Entry).size());
-  else
+  else if (DebugLocs.getBytes(Entry).size() <= std::numeric_limits<uint16_t>::max())
     Asm->emitInt16(DebugLocs.getBytes(Entry).size());
+  else
+    // The entry is too big to fit into 16 bit, drop it as there is nothing we
+    // can do.
+    return;
   // Emit the entry.
   APByteStreamer Streamer(*Asm);
   emitDebugLocEntry(Streamer, Entry);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59518.191195.patch
Type: text/x-patch
Size: 734 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190318/32b59393/attachment-0001.bin>


More information about the llvm-commits mailing list