[clang] [clang][codegen] Add a verifier IR pass before any further passes. (PR #68015)

Matheus Izvekov via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 2 12:50:32 PDT 2023


================
@@ -923,6 +923,8 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
   PB.crossRegisterProxies(LAM, FAM, CGAM, MAM);
 
   ModulePassManager MPM;
+  // Add a verifier pass, before any other passes, to catch CodeGen issues.
+  MPM.addPass(VerifierPass());
----------------
mizvekov wrote:

Yeah, you are right, it does add some non-insignificant cost: http://llvm-compile-time-tracker.com/compare.php?from=e0cb340f8ef77e2fefa42a3d6f4bd9aab42ad660&to=e728912a39421291d44f94c8304789710fe7bb67&stat=instructions:u

Though I believe these tests are all lightweight on Sema, don't use templates much, so the cost probably would not show as bad in the problematic case.

The docs encourage frontends to run the verifier before any optimizations: https://llvm.org/docs/Passes.html#verify-module-verifier

And this post https://discourse.llvm.org/t/should-clang-verify-ir-when-passing-a-llvm-ir-file/62926/3, though in a different context, does appear favorable towards the verifier, versus cost.

https://github.com/llvm/llvm-project/pull/68015


More information about the cfe-commits mailing list