<p dir="ltr">You probably want to check the error message in the test.</p>
<div class="gmail_quote">On Apr 12, 2016 2:28 PM, "Davide Italiano via llvm-commits" <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: davide<br>
Date: Tue Apr 12 13:22:33 2016<br>
New Revision: 266102<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=266102&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=266102&view=rev</a><br>
Log:<br>
[IR/Verifier] Each DISubprogram with isDefinition: true must belong to a CU.<br>
<br>
Add a check to catch violations. ~60 tests were broken and prevented<br>
this change to be committed. Adrian and I (thanks Adrian!) went<br>
through them in the last week or so updating. The check can be<br>
done more efficiently but I'd still like to get this in ASAP to<br>
avoid more broken tests to be checked in (if any).<br>
<br>
PR:  27101<br>
<br>
Added:<br>
    llvm/trunk/test/Verifier/disubprogram-nocu.ll<br>
Modified:<br>
    llvm/trunk/lib/IR/Verifier.cpp<br>
<br>
Modified: llvm/trunk/lib/IR/Verifier.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=266102&r1=266101&r2=266102&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=266102&r1=266101&r2=266102&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/IR/Verifier.cpp (original)<br>
+++ llvm/trunk/lib/IR/Verifier.cpp Tue Apr 12 13:22:33 2016<br>
@@ -1011,6 +1011,22 @@ void Verifier::visitDISubprogram(const D<br>
<br>
   if (N.isDefinition())<br>
     Assert(N.isDistinct(), "subprogram definitions must be distinct", &N);<br>
+<br>
+  // Ensure that every DISubprogram with isDefinition: true belongs<br>
+  // to a DICompileUnit.<br>
+  // FIXME: This is a very inefficient way of handling the problem.<br>
+  // Use a SmallSetPtr which contains the Listed DISubprograms in the CU<br>
+  // instead.<br>
+  if (N.isDefinition()) {<br>
+    auto *CUs = M->getNamedMetadata("<a href="http://llvm.dbg.cu" rel="noreferrer" target="_blank">llvm.dbg.cu</a>");<br>
+    Assert(CUs, "subprogram must belong to a compile unit", &N);<br>
+    for (auto *CU : CUs->operands())<br>
+      if (auto Subprograms = cast<DICompileUnit>(CU)->getSubprograms())<br>
+        for (const auto *Sp : Subprograms)<br>
+          if (Sp == &N)<br>
+            return;<br>
+    Assert(false, "subprogram not found in any compile unit", &N);<br>
+  }<br>
 }<br>
<br>
 void Verifier::visitDILexicalBlockBase(const DILexicalBlockBase &N) {<br>
<br>
Added: llvm/trunk/test/Verifier/disubprogram-nocu.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Verifier/disubprogram-nocu.ll?rev=266102&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Verifier/disubprogram-nocu.ll?rev=266102&view=auto</a><br>
==============================================================================<br>
--- llvm/trunk/test/Verifier/disubprogram-nocu.ll (added)<br>
+++ llvm/trunk/test/Verifier/disubprogram-nocu.ll Tue Apr 12 13:22:33 2016<br>
@@ -0,0 +1,22 @@<br>
+; Reject if DISubprogram does not belong to a DICompileUnit.<br>
+; RUN: not llvm-as %s<br>
+<br>
+@_ZZNK4llvm6object15MachOObjectFile21getRelocationTypeNameENS0_11DataRefImplERNS_15SmallVectorImplIcEEE5Table = external unnamed_addr constant [6 x i8*], align 16<br>
+<br>
+!<a href="http://llvm.dbg.cu" rel="noreferrer" target="_blank">llvm.dbg.cu</a> = !{!0}<br>
+!llvm.module.flags = !{!13}<br>
+<br>
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, isOptimized: false, runtimeVersion: 0, emissionKind: 0, globals: !2, imports: !9)<br>
+!1 = !DIFile(filename: "../lib/Object/MachOObjectFile.cpp", directory: "/home/davide/work/llvm/build-lto-debug")<br>
+!2 = !{!3, !8}<br>
+!3 = !DIGlobalVariable(name: "Table", scope: !4, isLocal: false, isDefinition: true, variable: [6 x i8*]* @_ZZNK4llvm6object15MachOObjectFile21getRelocationTypeNameENS0_11DataRefImplERNS_15SmallVectorImplIcEEE5Table)<br>
+!4 = distinct !DILexicalBlock(scope: !5, line: 722, column: 23)<br>
+!5 = distinct !DILexicalBlock(scope: !6, line: 721, column: 17)<br>
+!6 = distinct !DISubprogram(name: "getRelocationTypeName", scope: null, isLocal: false, isDefinition: true, isOptimized: false, variables: !7)<br>
+!7 = !{}<br>
+!8 = !DIGlobalVariable(name: "IsLittleEndianHost", scope: null, isLocal: false, isDefinition: true, variable: i1 true)<br>
+!9 = !{!10, !12}<br>
+!10 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !11, line: 121)<br>
+!11 = !DINamespace(name: "std", scope: null, line: 1967)<br>
+!12 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !0, line: 32)<br>
+!13 = !{i32 2, !"Debug Info Version", i32 3}<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>