[PATCH] D46790: [bugpoint] Actually skip a modules that cause verifier errors

Keno Fischer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 11 18:54:04 PDT 2018


loladiro created this revision.
loladiro added a reviewer: aprantl.

When reducing modules, it is possible for us to introduce changes
that fail the verifier. The intent was for these modules to get skipped
such that we would try a different reduction instead. However, it
seems that while we did the verification, we nevertheless proceeded
with the broken module. Make sure to actually check for a broken module.


Repository:
  rL LLVM

https://reviews.llvm.org/D46790

Files:
  tools/bugpoint/CrashDebugger.cpp
  tools/bugpoint/ExtractFunction.cpp


Index: tools/bugpoint/ExtractFunction.cpp
===================================================================
--- tools/bugpoint/ExtractFunction.cpp
+++ tools/bugpoint/ExtractFunction.cpp
@@ -108,6 +108,10 @@
   // Remove the instruction from the program.
   TheInst->getParent()->getInstList().erase(TheInst);
 
+  // Verify that removing this instruction didn't cause a verifier error
+  if (verifyModule(*Clone, &llvm::outs()))
+    return nullptr;
+
   // Spiff up the output a little bit.
   std::vector<std::string> Passes;
 
Index: tools/bugpoint/CrashDebugger.cpp
===================================================================
--- tools/bugpoint/CrashDebugger.cpp
+++ tools/bugpoint/CrashDebugger.cpp
@@ -726,13 +726,9 @@
         }
       }
 
-  // Verify that this is still valid.
-  legacy::PassManager Passes;
-  Passes.add(createVerifierPass(/*FatalErrors=*/false));
-  Passes.run(*M);
-
-  // Try running on the hacked up program...
-  if (TestFn(BD, M.get())) {
+  // Verify that the Module is still valid and then
+  // try running on the hacked up program...
+  if (!verifyModule(*M, &llvm::outs()) && TestFn(BD, M.get())) {
     BD.setNewProgram(std::move(M)); // It crashed, keep the trimmed version...
 
     // Make sure to use instruction pointers that point into the now-current
@@ -742,7 +738,8 @@
       Insts.push_back(Inst);
     return true;
   }
-  // It didn't crash, try something else.
+
+  // It didn't crash (or the hacked up module was invalid), try something else.
   return false;
 }
 
@@ -801,13 +798,8 @@
   for (auto *NamedMD : ToDelete)
     NamedMD->eraseFromParent();
 
-  // Verify that this is still valid.
-  legacy::PassManager Passes;
-  Passes.add(createVerifierPass(/*FatalErrors=*/false));
-  Passes.run(*M);
-
   // Try running on the hacked up program...
-  if (TestFn(BD, M.get())) {
+  if (!verifyModule(*M, &llvm::outs()) && TestFn(BD, M.get())) {
     BD.setNewProgram(std::move(M)); // It crashed, keep the trimmed version...
     return true;
   }
@@ -866,13 +858,8 @@
         NewNamedMDNode->addOperand(cast<MDNode>(MapMetadata(op, VMap)));
   }
 
-  // Verify that this is still valid.
-  legacy::PassManager Passes;
-  Passes.add(createVerifierPass(/*FatalErrors=*/false));
-  Passes.run(*M);
-
   // Try running on the hacked up program...
-  if (TestFn(BD, M.get())) {
+  if (!verifyModule(*M, &llvm::outs()) && TestFn(BD, M.get())) {
     // Make sure to use instruction pointers that point into the now-current
     // module, and that they don't include any deleted blocks.
     NamedMDOps.clear();
@@ -1006,7 +993,7 @@
                   BD.deleteInstructionFromProgram(&*I, Simplification);
 
               // Find out if the pass still crashes on this pass...
-              if (TestFn(BD, M.get())) {
+              if (M && TestFn(BD, M.get())) {
                 // Yup, it does, we delete the old module, and continue trying
                 // to reduce the testcase...
                 BD.setNewProgram(std::move(M));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46790.146455.patch
Type: text/x-patch
Size: 3001 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180512/edbd415f/attachment.bin>


More information about the llvm-commits mailing list