[opt] Only create Verifier passes when requested
authorVedant Kumar <vsk@apple.com>
Thu, 10 Mar 2016 03:40:14 +0000 (03:40 +0000)
committerVedant Kumar <vsk@apple.com>
Thu, 10 Mar 2016 03:40:14 +0000 (03:40 +0000)
opt adds Verifier passes in AddOptimizationPasses even if
-disable-verify is on. Fix it so that the extra verification occurs
either when (1) -disable-verifier is off, or (2) -verify-each is on.

Thanks to David Jones for pointing out this behavior!

llvm-svn: 263090

llvm/tools/opt/opt.cpp

index 28c1c2b..11151b8 100644 (file)
@@ -217,7 +217,8 @@ static inline void addPass(legacy::PassManagerBase &PM, Pass *P) {
 static void AddOptimizationPasses(legacy::PassManagerBase &MPM,
                                   legacy::FunctionPassManager &FPM,
                                   unsigned OptLevel, unsigned SizeLevel) {
-  FPM.add(createVerifierPass()); // Verify that input is correct
+  if (!NoVerify || VerifyEach)
+    FPM.add(createVerifierPass()); // Verify that input is correct
 
   PassManagerBuilder Builder;
   Builder.OptLevel = OptLevel;