[PATCH] D87406: [DebugInfo] Fixing CodeView assert related to lowerBound field of DISubrange.

Alok Kumar Sharma via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 9 11:45:08 PDT 2020


alok created this revision.
alok added a reviewer: aprantl.
alok added a project: debug-info.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
alok requested review of this revision.

  This is to fix CodeView build failure https://bugs.llvm.org/show_bug.cgi?id=47287
  after DIsSubrange upgrade (https://reviews.llvm.org/D80197).
  
  Assert condition is updated to accept only
  Absent lowerBound, or
  lowerBound: 0
  Everything else will be rejected.
  
  The misleading Assert comment is also fixed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87406

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


Index: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -1578,8 +1578,13 @@
     assert(Element->getTag() == dwarf::DW_TAG_subrange_type);
 
     const DISubrange *Subrange = cast<DISubrange>(Element);
-    assert(!Subrange->getRawLowerBound() &&
-           "codeview doesn't support subranges with lower bounds");
+    // Codeview supports Subranges with either absent lowerBound or lowerBound
+    // with constant zero value. Everyting else will be rejected.
+    auto *LI = Subrange->getLowerBound().dyn_cast<ConstantInt *>();
+    assert(
+        (!Subrange->getRawLowerBound() || (LI && (LI->getSExtValue() == 0))) &&
+        "codeview doesn't support subranges with non zero lower bounds");
+
     int64_t Count = -1;
     if (auto *CI = Subrange->getCount().dyn_cast<ConstantInt*>())
       Count = CI->getSExtValue();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87406.290786.patch
Type: text/x-patch
Size: 998 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200909/e37cf078/attachment.bin>


More information about the llvm-commits mailing list