Can I dump LLVM IR after each pass in Clang BackendUtil.cpp

Dear llvm-dev,

I am trying to debug some passes , these passes are added to
legacy::PassManager(MPM) in Clang's lib/CodeGen/BackendUtil.cpp :

//******
void EmitAssemblyHelper::CreatePasses() {
//******
   if (CodeGenOpts.MemSafety) {
     //
     // Add passes that record information about run-time checks.
     //
     MPM->add (createCommonMSCInfoPass());
     MPM->add (createSAFECodeMSCInfoPass());
//******

Could I dump the output LLVM IR after each pass in PassManager MPM?

Best regards,
Zhengyang.

It solved my question, thank you.

Best regards,

Zhengyang.

Alternatively, you can add a BitcodeWriter (or whatever it’s called) pass. This pass writes the bitcode out to a file. As it is an LLVM pass, you can schedule it like any other pass. Regards, John Criswell