[llvm] r232418 - Verifier: Don't call debug info verifier if the module is broken

Duncan P. N. Exon Smith dexonsmith at apple.com
Mon Mar 16 14:23:56 PDT 2015

Author: dexonsmith
Date: Mon Mar 16 16:23:56 2015
New Revision: 232418

URL: http://llvm.org/viewvc/llvm-project?rev=232418&view=rev
Verifier: Don't call debug info verifier if the module is broken

If `Verifier` has already found a failure, don't call
`DebugInfoVerifier`.  The latter sometimes crashes in `DebugInfoFinder`
when the former would give a nice message.  The only two cases I found
it crashing are explicit verifier tests I've added:

  - test/Verifier/llvm.dbg.declare-expression.ll
  - test/Verifier/llvm.dbg.value-expression.ll

However, I assume frontends with bugs will create invalid IR as well.

IMO, the `DebugInfoVerifier` should never crash (instead, it should fail
to verify), but subtleties like that will be easier to work out once
it's enabled again.

This is part of PR22777.


Modified: llvm/trunk/lib/IR/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=232418&r1=232417&r2=232418&view=diff
--- llvm/trunk/lib/IR/Verifier.cpp (original)
+++ llvm/trunk/lib/IR/Verifier.cpp Mon Mar 16 16:23:56 2015
@@ -3113,8 +3113,13 @@ bool llvm::verifyModule(const Module &M,
   // Note that this function's return value is inverted from what you would
   // expect of a function called "verify".
+  if (!V.verify(M) || Broken)
+    return true;
+  // Run the debug info verifier only if the regular verifier succeeds, since
+  // sometimes checks that have already failed will cause crashes here.
   DebugInfoVerifier DIV(OS ? *OS : NullStr);
-  return !V.verify(M) || !DIV.verify(M) || Broken;
+  return !DIV.verify(M);
 namespace {

More information about the llvm-commits mailing list