<div dir="ltr">This sort of shows a bit of a bug/weakness in LLVM's representation here.<br><br>This is a bit tricky to describe... <br><br>So, some back story: to ensure LLVM debug info metadata description of a type is consistent between different translation units (this was important for early versions of type merging I think - and also useful for DWARF type units & somewhat for general sanity), any parts of a type that could vary between translation units was removed from the member list and only listed the type as their scope.<br><br>(this includes things like: nested types (since they could appear as a declaration or a definition in different translation units), member function template instantiations (because there could be different instantiations in different translation units), and implicit special members (copy ctor/move ctor, etc - depending on whether or not they're used in a given translation unit))<br><br>But the way things are built if they're in the member list versus when they're just listing the class as their parent scope is different - that's how this bug exists. The DWARF backend would never see these member types in the member list - so wasn't tested with these situations, etc.<br><br>Other quality bugs exist here because of this approach - member-specific properties of these not-in-the-member-list entities aren't handled, such as access specifiers.<br><br>Ah well, maybe should be fixed one day, but not sure many consumers care greatly about access specifiers & not sure there's any other observable difference.<br><br><br>I'm good with the more localized fix, looks right to me (given the situation we're in).<br><br><div class="gmail_quote"><div dir="ltr">On Thu, Dec 14, 2017 at 4:54 PM Adrian McCarthy via Phabricator via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">amccarth created this revision.<br>
amccarth added reviewers: rnk, russell.gallop.<br>
Herald added subscribers: JDevlieghere, hiraditya, aprantl.<br>
<br>
It appears the code uses nullptr to represent a void type in debug metadata, which led to an assertion failure when building DeltaAlgorithm.cpp with a self-hosted clang on Windows.<br>
<br>
I'm not sure why/if the problem was Windows-specific.<br>
<br>
Fixes bug <a href="https://bugs.llvm.org/show_bug.cgi?id=35543" rel="noreferrer" target="_blank">https://bugs.llvm.org/show_bug.cgi?id=35543</a><br>
<br>
<br>
<a href="https://reviews.llvm.org/D41264" rel="noreferrer" target="_blank">https://reviews.llvm.org/D41264</a><br>
<br>
Files:<br>
  llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp<br>
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp<br>
<br>
<br>
Index: llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp<br>
===================================================================<br>
--- llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp<br>
+++ llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp<br>
@@ -761,7 +761,8 @@<br>
<br>
 void DwarfUnit::addType(DIE &Entity, const DIType *Ty,<br>
                         dwarf::Attribute Attribute) {<br>
-  assert(Ty && "Trying to add a type that doesn't exist?");<br>
+  if (!Ty)<br>
+    return;<br>
   addDIEEntry(Entity, Attribute, DIEEntry(*getOrCreateTypeDIE(Ty)));<br>
 }<br>
<br>
Index: llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp<br>
===================================================================<br>
--- llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp<br>
+++ llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp<br>
@@ -163,7 +163,8 @@<br>
<br>
   DIType *BaseType = DDTy->getBaseType().resolve();<br>
<br>
-  assert(BaseType && "Unexpected invalid base type");<br>
+  if (!BaseType)<br>
+    return 0;<br>
<br>
   // If this is a derived type, go ahead and get the base type, unless it's a<br>
   // reference then it's just the size of the field. Pointer types have no need<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div></div>