[RFC] Running LLVM Verifier right out of CodeGen

I believe that is not true, there is a verifier pass already, and it’s on by default, even for Release builds.

See for yourself:

Defaults to 1: https://github.com/llvm/llvm-project/blob/185eab1974bf3f13315980f8741816dd44d35f4f/clang/include/clang/Basic/CodeGenOptions.def#L326C1-L326C83
CODEGENOPT(VerifyModule , 1, 1) ///< Control whether the module should be run

Can only be turned off: https://github.com/llvm/llvm-project/blob/185eab1974bf3f13315980f8741816dd44d35f4f/clang/include/clang/Driver/Options.td#L6604

def disable_llvm_verifier : Flag<["-"], "disable-llvm-verifier">,
  HelpText<"Don't run the LLVM IR verifier pass">,
  MarshallingInfoNegativeFlag<CodeGenOpts<"VerifyModule">>;

Is connected to run a verifier pass, post optimization: https://github.com/llvm/llvm-project/blob/185eab1974bf3f13315980f8741816dd44d35f4f/clang/lib/CodeGen/BackendUtil.cpp#L1038

  if (!actionRequiresCodeGen(Action) && CodeGenOpts.VerifyModule)
    MPM.addPass(VerifierPass());

So, I think I should put the new pass under that same flag, as in retrospect I think it’s useful to allow people to disable it, just for testing and easily obtaining the invalid IR for analysis.

But still, there is a cost to running it potentially a second time, so that’s why I am asking :slight_smile: