示例#1
0
void CSulPostFilterHDR2::in( osg::Texture2D* pTex )
{
	// we create a texture to be used for the final combined image
	m_rTex = createTexture( pTex->getTextureWidth(), pTex->getTextureHeight() );

	if ( m_sView=="brightpass" )
	{
		addPass( new CSulPassBrightPass( pTex, m_rTex ) );
		return;
	}

	///////////////////
	// downsample
	///////////////////

	sigma::uint32 w = pTex->getTextureWidth();
	sigma::uint32 h = pTex->getTextureHeight();
/*
	osg::ref_ptr<osg::Texture2D> tex_ds_1 = createTexture( w/2, h/2 );
	osg::ref_ptr<osg::Texture2D> tex_ds_1_tmp = createTexture( w/2, h/2 );
	osg::ref_ptr<osg::Texture2D> tex_ds_1_tmp2 = createTexture( w/2, h/2 );
	addPass( m_rPassBrightPass = new CSulPassBrightPass(pTex, tex_ds_1) );
	addPass( m_rStreak0 = new CSulPassStreaking( tex_ds_1, tex_ds_1_tmp2,  1.0f, 0.1f ) );
	addPass( m_rStreak1 = new CSulPassStreaking( tex_ds_1_tmp2, tex_ds_1,  4.0f, 0.1f ) );
	addPass( m_rStreak2 = new CSulPassStreaking( tex_ds_1, tex_ds_1_tmp2, 16.0f, 0.1f ) );
	addPass( m_rStreak3 = new CSulPassStreaking( tex_ds_1_tmp2, tex_ds_1, 64.0f, 0.1f ) );
	addPass( new CSulPassGaussH( tex_ds_1, tex_ds_1_tmp ) );
	addPass( new CSulPassGaussV(  tex_ds_1_tmp, tex_ds_1 ) );
*/
	osg::ref_ptr<osg::Texture2D> tex_ghost1 = createTexture( w, h );
	osg::ref_ptr<osg::Texture2D> tex_ghost2 = createTexture( w, h );


	osg::ref_ptr<osg::Texture2D> tex_ds_1 = createTexture( w/2, h/2 );
	osg::ref_ptr<osg::Texture2D> tex_ds_1_tmp = createTexture( w/2, h/2 );
	osg::ref_ptr<osg::Texture2D> tex_ds_1_tmp2 = createTexture( w/2, h/2 );
	addPass( m_rPassBrightPass = new CSulPassBrightPass(pTex, tex_ds_1) );

	addPass( new CSulPassGhost( tex_ds_1, tex_ghost2) );
	//addPass( new CSulPassGhost( tex_ghost1, tex_ghost2) );

	addPass( m_rStreak0 = new CSulPassStreaking( tex_ds_1, tex_ds_1_tmp2,  1.0f, 0.1f ) );
	addPass( m_rStreak1 = new CSulPassStreaking( tex_ds_1_tmp2, tex_ds_1,  4.0f, 0.1f ) );
	addPass( m_rStreak2 = new CSulPassStreaking( tex_ds_1, tex_ds_1_tmp2, 16.0f, 0.1f ) );
	addPass( m_rStreak3 = new CSulPassStreaking( tex_ds_1_tmp2, tex_ds_1, 64.0f, 0.1f ) );
	addPass( new CSulPassGaussH( tex_ds_1, tex_ds_1_tmp ) );
	addPass( new CSulPassGaussV(  tex_ds_1_tmp, tex_ds_1 ) );

	// downsample 1/4
	osg::ref_ptr<osg::Texture2D> tex_ds_2 = createTexture( w/4, h/4 );
	osg::ref_ptr<osg::Texture2D> tex_ds_2_tmp = createTexture( w/4, h/4 );
	addPass( new CSulPassGaussH( tex_ds_1, tex_ds_2_tmp ) );
	addPass( new CSulPassGaussV( tex_ds_2_tmp, tex_ds_2 ) );

	// downsample 1/8
	osg::ref_ptr<osg::Texture2D> tex_ds_3 = createTexture( w/8, h/8 );
	osg::ref_ptr<osg::Texture2D> tex_ds_3_tmp = createTexture( w/8, h/8 );
	addPass( new CSulPassGaussH( tex_ds_2, tex_ds_3_tmp ) );
	addPass( new CSulPassGaussV( tex_ds_3_tmp, tex_ds_3 ) );

	// downsampling combining here (we reuse tex_ds_1_tmp and tex_ds_1 as output)
	addPass( new CSulPassCombineTex( tex_ds_1, tex_ds_2, tex_ds_1_tmp ) );
	addPass( new CSulPassCombineTex( tex_ds_1_tmp, tex_ds_3, tex_ds_1 ) );

	addPass( new CSulPassCombineTex( tex_ds_1, tex_ghost2, tex_ds_1_tmp ) );
	

	// composer
	addPass( m_rPassToneMap = new CSulPassToneMap( pTex, tex_ds_1_tmp, m_rTex, m_fExp, m_fFactor, m_fMax) );
}
示例#2
0
void CSulPostFilterHDR2::in( osg::Texture2D* pTex )
{
	// we create a texture to be used for the final combined image
	m_rTex = createTexture( pTex->getTextureWidth(), pTex->getTextureHeight() );

	if ( m_sView=="brightpass" )
	{
		addPass( new CSulPassBrightPass( pTex, m_rTex ) );
		return;
	}

	sigma::uint32 w = pTex->getTextureWidth();
	sigma::uint32 h = pTex->getTextureHeight();

	/**/
	// calc luminance, we do this by down sampling the orginal image until we get
	// a texture that is 1x1
	// NOTE: I would like to keep this constant so the first down sample will 
	// be 512x512 which means we will process the following
	// 512x512
	// 256x256
	// 128x128
	// 64x64
	// 32x32
	// 16x16
	// 8x8
	// 4x4
	// 2x2	this is the minimum opengl can handle
	// that is 10 downsampling steps
	osg::ref_ptr<CSulTextureBuffer> texLum512 = new CSulTextureBuffer( 512, 512, 1 );
	osg::ref_ptr<CSulTextureBuffer> texLum256 = new CSulTextureBuffer( 256, 256, 1 );
	osg::ref_ptr<CSulTextureBuffer> texLum128 = new CSulTextureBuffer( 128, 128, 1 );
	osg::ref_ptr<CSulTextureBuffer> texLum64 = new CSulTextureBuffer( 64, 64, 1 );
	osg::ref_ptr<CSulTextureBuffer> texLum32 = new CSulTextureBuffer( 32, 32, 1 );
	osg::ref_ptr<CSulTextureBuffer> texLum16 = new CSulTextureBuffer( 16, 16, 1 );
	osg::ref_ptr<CSulTextureBuffer> texLum8 = new CSulTextureBuffer( 8, 8, 1 );
	osg::ref_ptr<CSulTextureBuffer> texLum4 = new CSulTextureBuffer( 4, 4, 1 );
	osg::ref_ptr<CSulTextureBuffer> texLum2 = new CSulTextureBuffer( 2, 2, 1 );
	
	CSulPassNormal* pLumLast = 0;

	addPass( new CSulPassNormal( pTex, texLum512 ) );
	addPass( new CSulPassNormal( texLum512, texLum256 ) );
	addPass( new CSulPassNormal( texLum256, texLum128 ) );
	addPass( new CSulPassNormal( texLum128, texLum64 ) );
	addPass( new CSulPassNormal( texLum64, texLum32 ) );
	addPass( new CSulPassNormal( texLum32, texLum16 ) );
	addPass( new CSulPassNormal( texLum16, texLum8 ) );
	addPass( new CSulPassNormal( texLum8, texLum4 ) );
	addPass( pLumLast = new CSulPassNormal( texLum4, texLum2 ) );

	texLum = texLum2;

	/**/

	// downsample 1/2 + streak + brightpass
	osg::ref_ptr<CSulTextureBuffer> texBuf2 = new CSulTextureBuffer( w/2, h/2 );
	texBuf2->setOut( pTex );
	addPass( m_rPassBrightPass = new CSulPassBrightPass( texBuf2 ) );

	osg::ref_ptr<CSulTextureBuffer> texBufGhost = new CSulTextureBuffer( w/2, h/2 );
	texBufGhost->setOut( texBuf2 );
	addPass( new CSulPassGhost( texBufGhost ) );
	addPass( new CSulPassGhost( texBufGhost ) );
	addPass( new CSulPassGaussH( texBufGhost ) );
	addPass( new CSulPassGaussV( texBufGhost ) );

	//addPass( m_rStreak0 = new CSulPassStreaking( texBuf2,  1.0f, 0.1f ) );
	//addPass( m_rStreak1 = new CSulPassStreaking( texBuf2,  4.0f, 0.1f ) );
	//addPass( m_rStreak2 = new CSulPassStreaking( texBuf2, 16.0f, 0.1f ) );
	//addPass( m_rStreak3 = new CSulPassStreaking( texBuf2, 64.0f, 0.1f ) );
	//addPass( new CSulPassGaussH( texBuf2 ) );
	//addPass( new CSulPassGaussV( texBuf2 ) );

	// downsample 1/4
	osg::ref_ptr<CSulTextureBuffer> texBuf4 = new CSulTextureBuffer( w/4, h/4 );
	texBuf4->setOut( texBuf2 );
	addPass( new CSulPassGaussH( texBuf4 ) );
	addPass( new CSulPassGaussV( texBuf4 ) );

	// downsample 1/8
	osg::ref_ptr<CSulTextureBuffer> texBuf8 = new CSulTextureBuffer( w/8, h/8 );
	texBuf8->setOut( texBuf4 );
	addPass( new CSulPassGaussH( texBuf8 ) );
	addPass( new CSulPassGaussV( texBuf8 ) );

	// downsampling combining here
	addPass( new CSulPassCombineTex( texBuf2, texBuf4 ) );
	addPass( new CSulPassCombineTex( texBuf2, texBuf8 ) );

	addPass( new CSulPassCombineTex( texBuf2, texBufGhost ) );

	// composer
	addPass( m_rPassToneMap = new CSulPassToneMap( pTex, texBuf2->getOut(), m_rTex, m_fExp, m_fFactor, m_fMax, pLumLast->getTexCam() ) );
}
示例#3
0
    ShaderTechnique::ShaderTechnique(Shader::ShaderManager& shaderManager, bool forcePerPixelLighting, bool clampLighting, const std::vector<TextureLayer>& layers,
                                                   const std::vector<osg::ref_ptr<osg::Texture2D> >& blendmaps, int blendmapScale, float layerTileSize)
    {
        bool firstLayer = true;
        int i=0;
        for (std::vector<TextureLayer>::const_iterator it = layers.begin(); it != layers.end(); ++it)
        {
            osg::ref_ptr<osg::StateSet> stateset (new osg::StateSet);

            if (!firstLayer)
            {
                stateset->setMode(GL_BLEND, osg::StateAttribute::ON);
                stateset->setAttributeAndModes(getEqualDepth(), osg::StateAttribute::ON);
            }

            int texunit = 0;

            stateset->setTextureAttributeAndModes(texunit, it->mDiffuseMap);

            stateset->setTextureAttributeAndModes(texunit, getLayerTexMat(layerTileSize), osg::StateAttribute::ON);

            stateset->addUniform(new osg::Uniform("diffuseMap", texunit));

            if(!firstLayer)
            {
                ++texunit;
                osg::ref_ptr<osg::Texture2D> blendmap = blendmaps.at(i++);

                stateset->setTextureAttributeAndModes(texunit, blendmap.get());

                stateset->setTextureAttributeAndModes(texunit, getBlendmapTexMat(blendmapScale));
                stateset->addUniform(new osg::Uniform("blendMap", texunit));
            }

            if (it->mNormalMap)
            {
                ++texunit;
                stateset->setTextureAttributeAndModes(texunit, it->mNormalMap);
                stateset->addUniform(new osg::Uniform("normalMap", texunit));
            }

            Shader::ShaderManager::DefineMap defineMap;
            defineMap["forcePPL"] = forcePerPixelLighting ? "1" : "0";
            defineMap["clamp"] = clampLighting ? "1" : "0";
            defineMap["normalMap"] = (it->mNormalMap) ? "1" : "0";
            defineMap["blendMap"] = !firstLayer ? "1" : "0";
            defineMap["colorMode"] = "2";
            defineMap["specularMap"] = it->mSpecular ? "1" : "0";
            defineMap["parallax"] = (it->mNormalMap && it->mParallax) ? "1" : "0";

            osg::ref_ptr<osg::Shader> vertexShader = shaderManager.getShader("terrain_vertex.glsl", defineMap, osg::Shader::VERTEX);
            osg::ref_ptr<osg::Shader> fragmentShader = shaderManager.getShader("terrain_fragment.glsl", defineMap, osg::Shader::FRAGMENT);
            if (!vertexShader || !fragmentShader)
                throw std::runtime_error("Unable to create shader");

            stateset->setAttributeAndModes(shaderManager.getProgram(vertexShader, fragmentShader));

            firstLayer = false;

            addPass(stateset);
        }
    }
示例#4
0
    bool TextMaterialLoader::loadMaterial(IFile* file, Material* material)
    {
        if (!file)
            return false;

        std::vector<char> data = FileUtils::loadFile(file);

        const char* p = data.data();
        size_t size = data.size();
        if (size >= 3 && uint8_t(p[0]) == 0xEF && uint8_t(p[1]) == 0xBB && uint8_t(p[2]) == 0xBF) {
            B3D_LOGW("Material file \"" << file->name() << "\" contains an UTF-8 byte order mark.");
            p += 3;
            size -= 3;
        }

        GrammarActions::Context context;
        context.materialFileName = file->name();

        try {
            assert(pegtl::analyze<Grammar::File>() == 0);
            pegtl::parse<Grammar::File, GrammarActions::Action>(p, size, "", context);
        } catch (const pegtl::parse_error& error) {
            B3D_LOGE("Unable to parse material \"" << file->name() << "\": " << error.what());
            return false;
        }

        assert(context.currentTechnique == nullptr);
        assert(context.currentPass == nullptr);
        assert(context.optionLists.size() == 1);
        assert(&context.currentOptionList() == context.currentFile.get());
        assert(context.boolValues.empty());
        assert(context.stringValues.empty());
        assert(context.floatValues.empty());
        assert(context.blendFuncValues.empty());
        assert(context.uniformValue == nullptr);
        assert(context.techniqueName == nullptr);
        assert(context.passName == nullptr);

        auto rootTree = context.currentFile;
        for (const auto& techniqueTree : rootTree->techniques) {
            const std::string& techniqueName = (techniqueTree->name ? *techniqueTree->name : gEmptyString);
            auto technique = std::make_shared<MaterialTechnique>(techniqueName);

            if (techniqueTree->passes.empty()) {
                B3D_LOGW("In material file \"" << file->name()
                    << "\": technique \"" << techniqueName << "\" does not have passes.");
            }

            for (const auto& passTree : techniqueTree->passes) {
                const std::string& passName = (passTree->name ? *passTree->name : gEmptyString);
                auto pass = std::make_shared<MaterialPass>(passName);

                for (const auto& option : rootTree->options)
                    option->applyToPass(*pass);
                for (const auto& option : techniqueTree->options)
                    option->applyToPass(*pass);
                for (const auto& option : passTree->options)
                    option->applyToPass(*pass);

                for (const auto& uniform : rootTree->uniforms)
                    uniform.second->applyToPass(*pass, uniform.first);
                for (const auto& uniform : techniqueTree->uniforms)
                    uniform.second->applyToPass(*pass, uniform.first);
                for (const auto& uniform : passTree->uniforms)
                    uniform.second->applyToPass(*pass, uniform.first);

                technique->addPass(pass);
            }

            material->addTechnique(std::move(technique));
        }

        return true;
    }
示例#5
0
文件: Optimize.cpp 项目: bwzhou/Gklee
static void AddStandardCompilePasses(PassManager &PM) {
  PM.add(createVerifierPass());                  // Verify that input is correct

#if LLVM_VERSION_CODE < LLVM_VERSION(3, 0)
  addPass(PM, createLowerSetJmpPass());          // Lower llvm.setjmp/.longjmp
#endif

  // If the -strip-debug command line option was specified, do it.
  if (StripDebug)
    addPass(PM, createStripSymbolsPass(true));

  if (DisableOptimizations) return;

#if LLVM_VERSION_CODE < LLVM_VERSION(2, 7)
  addPass(PM, createRaiseAllocationsPass());     // call %malloc -> malloc inst
#endif
  addPass(PM, createCFGSimplificationPass());    // Clean up disgusting code
  addPass(PM, createPromoteMemoryToRegisterPass());// Kill useless allocas
  addPass(PM, createGlobalOptimizerPass());      // Optimize out global vars
  addPass(PM, createGlobalDCEPass());            // Remove unused fns and globs
  addPass(PM, createIPConstantPropagationPass());// IP Constant Propagation
  addPass(PM, createDeadArgEliminationPass());   // Dead argument elimination
  addPass(PM, createInstructionCombiningPass()); // Clean up after IPCP & DAE
  addPass(PM, createCFGSimplificationPass());    // Clean up after IPCP & DAE

  addPass(PM, createPruneEHPass());              // Remove dead EH info
  addPass(PM, createFunctionAttrsPass());        // Deduce function attrs

  if (!DisableInline)
    addPass(PM, createFunctionInliningPass());   // Inline small functions
  addPass(PM, createArgumentPromotionPass());    // Scalarize uninlined fn args

  addPass(PM, createSimplifyLibCallsPass());     // Library Call Optimizations
  addPass(PM, createInstructionCombiningPass()); // Cleanup for scalarrepl.
  addPass(PM, createJumpThreadingPass());        // Thread jumps.
  addPass(PM, createCFGSimplificationPass());    // Merge & remove BBs
  addPass(PM, createScalarReplAggregatesPass()); // Break up aggregate allocas
  addPass(PM, createInstructionCombiningPass()); // Combine silly seq's
#if LLVM_VERSION_CODE < LLVM_VERSION(2, 7)
  addPass(PM, createCondPropagationPass());      // Propagate conditionals
#endif

  addPass(PM, createTailCallEliminationPass());  // Eliminate tail calls
  addPass(PM, createCFGSimplificationPass());    // Merge & remove BBs
  addPass(PM, createReassociatePass());          // Reassociate expressions
  addPass(PM, createLoopRotatePass());
  addPass(PM, createLICMPass());                 // Hoist loop invariants
  addPass(PM, createLoopUnswitchPass());         // Unswitch loops.
#if LLVM_VERSION_CODE < LLVM_VERSION(2, 9)
  addPass(PM, createLoopIndexSplitPass());       // Index split loops.
#endif
  // FIXME : Removing instcombine causes nestedloop regression.
  addPass(PM, createInstructionCombiningPass());
  addPass(PM, createIndVarSimplifyPass());       // Canonicalize indvars
  addPass(PM, createLoopDeletionPass());         // Delete dead loops
  addPass(PM, createLoopUnrollPass());           // Unroll small loops
  addPass(PM, createInstructionCombiningPass()); // Clean up after the unroller
  addPass(PM, createGVNPass());                  // Remove redundancies
  addPass(PM, createMemCpyOptPass());            // Remove memcpy / form memset
  addPass(PM, createSCCPPass());                 // Constant prop with SCCP

  // Run instcombine after redundancy elimination to exploit opportunities
  // opened up by them.
  addPass(PM, createInstructionCombiningPass());
#if LLVM_VERSION_CODE < LLVM_VERSION(2, 7)
  addPass(PM, createCondPropagationPass());      // Propagate conditionals
#endif

  addPass(PM, createDeadStoreEliminationPass()); // Delete dead stores
  addPass(PM, createAggressiveDCEPass());        // Delete dead instructions
  addPass(PM, createCFGSimplificationPass());    // Merge & remove BBs
  addPass(PM, createStripDeadPrototypesPass());  // Get rid of dead prototypes
#if LLVM_VERSION_CODE < LLVM_VERSION(3, 0)
  addPass(PM, createDeadTypeEliminationPass());  // Eliminate dead types
#endif
  addPass(PM, createConstantMergePass());        // Merge dup global constants
}
示例#6
0
文件: Optimize.cpp 项目: bwzhou/Gklee
/// Optimize - Perform link time optimizations. This will run the scalar
/// optimizations, any loaded plugin-optimization modules, and then the
/// inter-procedural optimizations if applicable.
void Optimize(Module* M) {

  // Instantiate the pass manager to organize the passes.
  PassManager Passes;

  // If we're verifying, start off with a verification pass.
  if (VerifyEach)
    Passes.add(createVerifierPass());

  // Add an appropriate TargetData instance for this module...
#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 1)
  addPass(Passes, new DataLayout(M));
#else
  addPass(Passes, new TargetData(M));
#endif

  // DWD - Run the opt standard pass list as well.
  AddStandardCompilePasses(Passes);

  if (!DisableOptimizations) {
    // Now that composite has been compiled, scan through the module, looking
    // for a main function.  If main is defined, mark all other functions
    // internal.
    if (!DisableInternalize)
#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 2)
      addPass(Passes, createInternalizePass());
#else
      addPass(Passes, createInternalizePass(true));
#endif

    // Propagate constants at call sites into the functions they call.  This
    // opens opportunities for globalopt (and inlining) by substituting function
    // pointers passed as arguments to direct uses of functions.  
    addPass(Passes, createIPSCCPPass());

    // Now that we internalized some globals, see if we can hack on them!
    addPass(Passes, createGlobalOptimizerPass());

    // Linking modules together can lead to duplicated global constants, only
    // keep one copy of each constant...
    addPass(Passes, createConstantMergePass());

    // Remove unused arguments from functions...
    addPass(Passes, createDeadArgEliminationPass());

    // Reduce the code after globalopt and ipsccp.  Both can open up significant
    // simplification opportunities, and both can propagate functions through
    // function pointers.  When this happens, we often have to resolve varargs
    // calls, etc, so let instcombine do this.
    addPass(Passes, createInstructionCombiningPass());

    if (!DisableInline)
      addPass(Passes, createFunctionInliningPass()); // Inline small functions

    addPass(Passes, createPruneEHPass());            // Remove dead EH info
    addPass(Passes, createGlobalOptimizerPass());    // Optimize globals again.
    addPass(Passes, createGlobalDCEPass());          // Remove dead functions

    // If we didn't decide to inline a function, check to see if we can
    // transform it to pass arguments by value instead of by reference.
    addPass(Passes, createArgumentPromotionPass());

    // The IPO passes may leave cruft around.  Clean up after them.
    addPass(Passes, createInstructionCombiningPass());
    addPass(Passes, createJumpThreadingPass());        // Thread jumps.
    addPass(Passes, createScalarReplAggregatesPass()); // Break up allocas

    // Run a few AA driven optimizations here and now, to cleanup the code.
    addPass(Passes, createFunctionAttrsPass());      // Add nocapture
    addPass(Passes, createGlobalsModRefPass());      // IP alias analysis

    addPass(Passes, createLICMPass());               // Hoist loop invariants
    addPass(Passes, createGVNPass());                // Remove redundancies
    addPass(Passes, createMemCpyOptPass());          // Remove dead memcpy's
    addPass(Passes, createDeadStoreEliminationPass()); // Nuke dead stores

    // Cleanup and simplify the code after the scalar optimizations.
    addPass(Passes, createInstructionCombiningPass());

    addPass(Passes, createJumpThreadingPass());        // Thread jumps.
    addPass(Passes, createPromoteMemoryToRegisterPass()); // Cleanup jumpthread.
    
    // Delete basic blocks, which optimization passes may have killed...
    addPass(Passes, createCFGSimplificationPass());

    // Now that we have optimized the program, discard unreachable functions...
    addPass(Passes, createGlobalDCEPass());
  }

  // If the -s or -S command line options were specified, strip the symbols out
  // of the resulting program to make it smaller.  -s and -S are GNU ld options
  // that we are supporting; they alias -strip-all and -strip-debug.
  if (Strip || StripDebug)
    addPass(Passes, createStripSymbolsPass(StripDebug && !Strip));

#if 0
  // Create a new optimization pass for each one specified on the command line
  std::auto_ptr<TargetMachine> target;
  for (unsigned i = 0; i < OptimizationList.size(); ++i) {
    const PassInfo *Opt = OptimizationList[i];
    if (Opt->getNormalCtor())
      addPass(Passes, Opt->getNormalCtor()());
    else
      std::cerr << "llvm-ld: cannot create pass: "******"\n";
  }
#endif

  // The user's passes may leave cruft around. Clean up after them them but
  // only if we haven't got DisableOptimizations set
  if (!DisableOptimizations) {
    addPass(Passes, createInstructionCombiningPass());
    addPass(Passes, createCFGSimplificationPass());
    addPass(Passes, createAggressiveDCEPass());
    addPass(Passes, createGlobalDCEPass());
  }

  // Make sure everything is still good.
  if (!DontVerify)
    Passes.add(createVerifierPass());

  // Run our queue of passes all at once now, efficiently.
  Passes.run(*M);
}