]> granicus.if.org Git - llvm/commitdiff
[IR/Verifier] Don't visit DISubprograms more than needed.
authorDavide Italiano <davide@freebsd.org>
Sat, 18 Feb 2017 03:02:44 +0000 (03:02 +0000)
committerDavide Italiano <davide@freebsd.org>
Sat, 18 Feb 2017 03:02:44 +0000 (03:02 +0000)
Before this patch we happened to visit twice, one when scanning
MDNodes and the other one while visiting the function. Remove
the explicit call to visitDISubprogram there, so we don't emit
the same error twice in case the verifier fail and we save some
time when running it.
Thanks to Justin Bogner for the report and Adrian for the quick
review!

PR: 31995

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295537 91177308-0d34-0410-b5e6-96231b3b80d8

lib/IR/Verifier.cpp
test/DebugInfo/Generic/invalid.ll [new file with mode: 0644]

index 9c2da10c9e1a2c77856a95f12478aa0b8546311e..c14e2bbdee469e3902aaa26bcab1cc8065ed697a 100644 (file)
@@ -2119,8 +2119,6 @@ void Verifier::visitFunction(const Function &F) {
   if (!N)
     return;
 
-  visitDISubprogram(*N);
-
   // Check that all !dbg attachments lead to back to N (or, at least, another
   // subprogram that describes the same function).
   //
diff --git a/test/DebugInfo/Generic/invalid.ll b/test/DebugInfo/Generic/invalid.ll
new file mode 100644 (file)
index 0000000..fdb68d9
--- /dev/null
@@ -0,0 +1,17 @@
+; RUN: not opt -verify %s 2>&1 | FileCheck %s
+
+; Make sure we emit this diagnostic only once (which means we don't visit the
+; same DISubprogram twice.
+; CHECK: subprogram definitions must have a compile unit
+; CHECK-NEXT: !3 = distinct !DISubprogram(name: "patatino", scope: null, isLocal: false, isDefinition: true, isOptimized: false)
+; CHECK-NOT: subprogram definitions must have a compile unit
+; CHECK-NOT: !3 = distinct !DISubprogram(name: "patatino", scope: null, isLocal: false, isDefinition: true, isOptimized: false)
+
+define void @tinkywinky() !dbg !3 { ret void }
+
+!llvm.module.flags = !{!4}
+!llvm.dbg.cu = !{!0}
+!0 = distinct !DICompileUnit(language: 12, file: !1)
+!1 = !DIFile(filename: "/home/davide", directory: "/home/davide")
+!3 = distinct !DISubprogram(name: "patatino", isDefinition: true)
+!4 = !{i32 2, !"Debug Info Version", i32 3}