[Attributor][NFC] Run the verifier only on functions and under EXPENSIVE_CHECKS
authorJohannes Doerfert <johannes@jdoerfert.de>
Mon, 13 Apr 2020 17:24:09 +0000 (12:24 -0500)
committerJohannes Doerfert <johannes@jdoerfert.de>
Thu, 16 Apr 2020 05:55:33 +0000 (00:55 -0500)
Running the verifier is expensive so we want to avoid it even in runs
that enable assertions. As we move closer to enabling the Attributor
this code will be executed by some buildbots but not cause overhead for
most people.

llvm/lib/Transforms/IPO/Attributor.cpp

index 6475185..4cf2812 100644 (file)
@@ -1248,6 +1248,14 @@ ChangeStatus Attributor::run() {
                      "specified iterations!");
   }
 
+#ifdef EXPENSIVE_CHECKS
+  for (Function *F : Functions) {
+    if (ToBeDeletedFunctions.count(F))
+      continue;
+    assert(!verifyFunction(*F, &errs()) && "Module verification failed!");
+  }
+#endif
+
   return ManifestChange;
 }
 
@@ -1982,10 +1990,7 @@ static bool runAttributorOnFunctions(InformationCache &InfoCache,
     A.identifyDefaultAbstractAttributes(*F);
   }
 
-  Module &M = *Functions.front()->getParent();
-  (void)M;
   ChangeStatus Changed = A.run();
-  assert(!verifyModule(M, &errs()) && "Module verification failed!");
   LLVM_DEBUG(dbgs() << "[Attributor] Done with " << Functions.size()
                     << " functions, result: " << Changed << ".\n");
   return Changed == ChangeStatus::CHANGED;