[PATCH] D61460: Fix bug in getCompleteTypeIndex in codeview debug info

Amy Huang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 2 13:40:15 PDT 2019


akhuang created this revision.
akhuang added a reviewer: rnk.
Herald added subscribers: llvm-commits, arphaman, hiraditya, aprantl.
Herald added a project: LLVM.

When there are multiple instances of a forward decl record type, only the first one is emitted with a type index, because
the type is added to a map with a null type index. Avoid this by reordering so that forward decl types aren't added to the map.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D61460

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
@@ -2497,11 +2497,7 @@
     return getTypeIndex(Ty);
   }
 
-  // Check if we've already translated the complete record type.
   const auto *CTy = cast<DICompositeType>(Ty);
-  auto InsertResult = CompleteTypeIndices.insert({CTy, TypeIndex()});
-  if (!InsertResult.second)
-    return InsertResult.first->second;
 
   TypeLoweringScope S(*this);
 
@@ -2519,6 +2515,11 @@
       return FwdDeclTI;
   }
 
+  // Check if we've already translated the complete record type.
+  auto InsertResult = CompleteTypeIndices.insert({CTy, TypeIndex()});
+  if (!InsertResult.second)
+    return InsertResult.first->second;
+
   TypeIndex TI;
   switch (CTy->getTag()) {
   case dwarf::DW_TAG_class_type:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61460.197855.patch
Type: text/x-patch
Size: 912 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190502/d1fbf0c0/attachment.bin>


More information about the llvm-commits mailing list