<p dir="ltr">Hey Adrian - what's the reason we need the type's size for optimized debug info output?</p>
<div class="gmail_quote">On Mar 1, 2015 2:11 PM, "Peter Collingbourne" <<a href="mailto:peter@pcc.me.uk">peter@pcc.me.uk</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: pcc<br>
Date: Sun Mar  1 16:07:04 2015<br>
New Revision: 230914<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=230914&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=230914&view=rev</a><br>
Log:<br>
DebugInfo: Give externally defined types a size and alignment where<br>
possible. Fixes PR22736.<br>
<br>
Modified:<br>
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br>
    cfe/trunk/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=230914&r1=230913&r2=230914&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=230914&r1=230913&r2=230914&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Sun Mar  1 16:07:04 2015<br>
@@ -647,11 +647,19 @@ CGDebugInfo::getOrCreateRecordFwdDecl(co<br>
   unsigned Line = getLineNumber(RD->getLocation());<br>
   StringRef RDName = getClassName(RD);<br>
<br>
+  uint64_t Size = 0;<br>
+  uint64_t Align = 0;<br>
+<br>
+  const RecordDecl *D = RD->getDefinition();<br>
+  if (D && D->isCompleteDefinition()) {<br>
+    Size = CGM.getContext().getTypeSize(Ty);<br>
+    Align = CGM.getContext().getTypeAlign(Ty);<br>
+  }<br>
<br>
   // Create the type.<br>
   SmallString<256> FullName = getUniqueTagTypeName(Ty, CGM, TheCU);<br>
   llvm::DICompositeType RetTy = DBuilder.createReplaceableCompositeType(<br>
-      getTagForRecord(RD), RDName, Ctx, DefUnit, Line, 0, 0, 0,<br>
+      getTagForRecord(RD), RDName, Ctx, DefUnit, Line, 0, Size, Align,<br>
       llvm::DIDescriptor::FlagFwdDecl, FullName);<br>
   ReplaceMap.emplace_back(<br>
       std::piecewise_construct, std::make_tuple(Ty),<br>
<br>
Modified: cfe/trunk/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp?rev=230914&r1=230913&r2=230914&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp?rev=230914&r1=230913&r2=230914&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp (original)<br>
+++ cfe/trunk/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp Sun Mar  1 16:07:04 2015<br>
@@ -99,3 +99,11 @@ template <><br>
 struct k<int>;<br>
 template struct k<int>;<br>
 // CHECK-NOT: ; [ DW_TAG_structure_type ] [k<int>]<br>
+<br>
+template <typename T><br>
+struct l {<br>
+  int x;<br>
+};<br>
+extern template class l<int>;<br>
+l<int> li;<br>
+// CHECK: [ DW_TAG_structure_type ] [l<int>] {{.*}}size {{[^0]}}<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div>