diff options
author | A. Unique TensorFlower <gardener@tensorflow.org> | 2017-06-13 14:21:43 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2017-06-13 14:26:08 -0700 |
commit | f0eedc18ebcb49ad7a00bd019c29d8d25733918a (patch) | |
tree | c8a1055f0a2ee8c04f7630665b65bcd3ddb1822c | |
parent | 5c6015f89c3d500bb6d5f4145572aaaab3432bb1 (diff) |
Explicitly call the IR verifier in the compiler functor instead of
calling it via the module pass manager.
This seems to be a better separation of concerns (IR verification is
not an optimization). It also makes sure we verify the IR before
running function passes: earlier we were running function passes on
unverified IR, which makes debugging incorrect IR generation harder
than it needs to be.
PiperOrigin-RevId: 158897874
-rw-r--r-- | tensorflow/compiler/xla/service/cpu/compiler_functor.cc | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/tensorflow/compiler/xla/service/cpu/compiler_functor.cc b/tensorflow/compiler/xla/service/cpu/compiler_functor.cc index 89b3302bca..8ebf9ab110 100644 --- a/tensorflow/compiler/xla/service/cpu/compiler_functor.cc +++ b/tensorflow/compiler/xla/service/cpu/compiler_functor.cc @@ -81,12 +81,17 @@ operator()(llvm::Module& module) const { // Run optimization passes on module. function_passes.doInitialization(); + + CHECK(!llvm::verifyModule(module, &llvm::dbgs())); + for (auto func = module.begin(); func != module.end(); ++func) { function_passes.run(*func); } function_passes.doFinalization(); module_passes.run(module); + CHECK(!llvm::verifyModule(module, &llvm::dbgs())); + // Buffer for holding machine code prior to constructing the ObjectFile. llvm::SmallVector<char, 0> stream_buffer; llvm::raw_svector_ostream ostream(stream_buffer); @@ -192,8 +197,6 @@ void CompilerFunctor::AddOptimizationPasses( module_passes->add(createTargetTransformInfoWrapperPass( target_machine_->getTargetIRAnalysis())); - module_passes->add(llvm::createVerifierPass()); - llvm::PassManagerBuilder builder; builder.OptLevel = opt_level_; builder.SizeLevel = 0; @@ -212,8 +215,6 @@ void CompilerFunctor::AddOptimizationPasses( builder.populateFunctionPassManager(*function_passes); builder.populateModulePassManager(*module_passes); - - module_passes->add(llvm::createVerifierPass()); } } // namespace cpu |