<div dir="ltr">Reverted in r270389, the following test case has it's behavior regressed: <a href="https://ghostbin.com/paste/tpqbd">https://ghostbin.com/paste/tpqbd</a><div><br></div><div>The difference comes down to a function type which we don't emit with r270106:</div><div><div>   FuncId (0x1003) {</div><div>     TypeLeafKind: LF_FUNC_ID (0x1601)</div><div>     ParentScope: 0x0</div><div>     FunctionType: void () (0x1001)</div><div>     Name: opover2.A8.opIndexUnary!("-", int).opIndexUnary</div><div>   }</div></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 19, 2016 at 1:12 PM, Adrian McCarthy via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: amccarth<br>
Date: Thu May 19 15:12:56 2016<br>
New Revision: 270106<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=270106&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=270106&view=rev</a><br>
Log:<br>
Modify emitTypeInformation to use MemoryTypeTableBuilder<br>
<br>
A baby step toward translating DIType records to CodeView.<br>
<br>
This does not (yet) combine the record length with the record data. I'm going back and forth trying to determine if that's a good idea.<br>
<br>
Modified:<br>
    llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp<br>
    llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp?rev=270106&r1=270105&r2=270106&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp?rev=270106&r1=270105&r2=270106&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp Thu May 19 15:12:56 2016<br>
@@ -261,55 +261,30 @@ void CodeViewDebug::emitTypeInformation(<br>
   // This type info currently only holds function ids for use with inline call<br>
   // frame info. All functions are assigned a simple 'void ()' type. Emit that<br>
   // type here.<br>
-  unsigned ArgListIndex = getNextTypeIndex();<br>
-  OS.AddComment("Type record length");<br>
-  OS.EmitIntValue(ArgListRecord::getLayoutSize(), 2);<br>
-  OS.AddComment("Leaf type: LF_ARGLIST");<br>
-  OS.EmitIntValue(LF_ARGLIST, 2);<br>
-  OS.AddComment("Number of arguments");<br>
-  OS.EmitIntValue(0, 4);<br>
+  ArrayRef<TypeIndex> NoArgs;<br>
+  ArgListRecord ArgListRec(TypeRecordKind::ArgList, NoArgs);<br>
+  TypeIndex ArgListIndex = TypeTable.writeArgList(ArgListRec);<br>
<br>
-  unsigned VoidFnTyIdx = getNextTypeIndex();<br>
-  OS.AddComment("Type record length");<br>
-  OS.EmitIntValue(ProcedureRecord::getLayoutSize(), 2);<br>
-  OS.AddComment("Leaf type: LF_PROCEDURE");<br>
-  OS.EmitIntValue(LF_PROCEDURE, 2);<br>
-  OS.AddComment("Return type index");<br>
-  OS.EmitIntValue(TypeIndex::Void().getIndex(), 4);<br>
-  OS.AddComment("Calling convention");<br>
-  OS.EmitIntValue(char(CallingConvention::NearC), 1);<br>
-  OS.AddComment("Function options");<br>
-  OS.EmitIntValue(char(FunctionOptions::None), 1);<br>
-  OS.AddComment("# of parameters");<br>
-  OS.EmitIntValue(0, 2);<br>
-  OS.AddComment("Argument list type index");<br>
-  OS.EmitIntValue(ArgListIndex, 4);<br>
+  ProcedureRecord Procedure(TypeIndex::Void(), CallingConvention::NearC,<br>
+                            FunctionOptions::None, 0, ArgListIndex);<br>
+  TypeIndex VoidFnTyIdx = TypeTable.writeProcedure(Procedure);<br>
<br>
   // Emit LF_FUNC_ID records for all inlined subprograms to the type stream.<br>
   // Allocate one type index for each func id.<br>
-  unsigned NextIdx = getNextTypeIndex(InlinedSubprograms.size());<br>
-  (void)NextIdx;<br>
-  assert(NextIdx == FuncIdTypeIndexStart && "func id type indices broken");<br>
   for (auto *SP : InlinedSubprograms) {<br>
+    TypeIndex ParentScope = TypeIndex(0);<br>
     StringRef DisplayName = SP->getDisplayName();<br>
-    OS.AddComment("Type record length");<br>
-    MCSymbol *FuncBegin = MMI->getContext().createTempSymbol(),<br>
-             *FuncEnd = MMI->getContext().createTempSymbol();<br>
-    OS.emitAbsoluteSymbolDiff(FuncEnd, FuncBegin, 2);<br>
-    OS.EmitLabel(FuncBegin);<br>
-    OS.AddComment("Leaf type: LF_FUNC_ID");<br>
-    OS.EmitIntValue(LF_FUNC_ID, 2);<br>
-<br>
-    OS.AddComment("Scope type index");<br>
-    OS.EmitIntValue(0, 4);<br>
-    OS.AddComment("Function type");<br>
-    OS.EmitIntValue(VoidFnTyIdx, 4);<br>
-    {<br>
-      OS.AddComment("Function name");<br>
-      emitNullTerminatedSymbolName(OS, DisplayName);<br>
-    }<br>
-    OS.EmitLabel(FuncEnd);<br>
+    FuncIdRecord FuncId(ParentScope, VoidFnTyIdx, DisplayName);<br>
+    TypeTable.writeFuncId(FuncId);<br>
   }<br>
+<br>
+  TypeTable.ForEachRecord(<br>
+      [&](TypeIndex Index, const MemoryTypeTableBuilder::Record *R) {<br>
+        OS.AddComment("Type record length");<br>
+        OS.EmitIntValue(R->size(), 2);<br>
+        OS.AddComment("Type record data");<br>
+        OS.EmitBytes(StringRef(R->data(), R->size()));<br>
+      });<br>
 }<br>
<br>
 void CodeViewDebug::emitInlineeFuncIdsAndLines() {<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h?rev=270106&r1=270105&r2=270106&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h?rev=270106&r1=270105&r2=270106&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h Thu May 19 15:12:56 2016<br>
@@ -20,6 +20,7 @@<br>
 #include "llvm/CodeGen/AsmPrinter.h"<br>
 #include "llvm/CodeGen/MachineFunction.h"<br>
 #include "llvm/CodeGen/MachineModuleInfo.h"<br>
+#include "llvm/DebugInfo/CodeView/MemoryTypeTableBuilder.h"<br>
 #include "llvm/DebugInfo/CodeView/TypeIndex.h"<br>
 #include "llvm/IR/DebugInfo.h"<br>
 #include "llvm/IR/DebugLoc.h"<br>
@@ -34,6 +35,7 @@ class LexicalScope;<br>
 /// \brief Collects and handles line tables information in a CodeView format.<br>
 class LLVM_LIBRARY_VISIBILITY CodeViewDebug : public DebugHandlerBase {<br>
   MCStreamer &OS;<br>
+  codeview::MemoryTypeTableBuilder TypeTable;<br>
<br>
   /// Represents the most general definition range.<br>
   struct LocalVarDefRange {<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">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><br></div>