[PATCH] D62805: [DebugInfo] Fix possible invalid dereference of non-engaged Optional.

Clement Courbet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 3 02:02:52 PDT 2019


courbet created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

This triggers with `EXPENSIVE_CHECKS` on for a bunch of checks (e.g. `fold-sext-trunc.ll`).
Unexpected Failures goes from 144 to 29.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62805

Files:
  llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h


Index: llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h
+++ llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h
@@ -178,8 +178,11 @@
 /// Compare two fragments based on their offset.
 inline bool operator<(const DebugLocEntry::Value &A,
                       const DebugLocEntry::Value &B) {
-  return A.getExpression()->getFragmentInfo()->OffsetInBits <
-         B.getExpression()->getFragmentInfo()->OffsetInBits;
+  const auto AFI = A.getExpression()->getFragmentInfo();
+  const auto BFI = A.getExpression()->getFragmentInfo();
+  if (AFI.hasValue() && BFI.hasValue())
+   return AFI->OffsetInBits < BFI->OffsetInBits;
+  return AFI.hasValue() < BFI.hasValue();
 }
 
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62805.202666.patch
Type: text/x-patch
Size: 779 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190603/8ecd7fb5/attachment.bin>


More information about the llvm-commits mailing list