[llvm] [CodeGen] Port GlobalMerge to new pass manager (PR #77474)

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 17 13:17:13 PST 2024


================
@@ -290,6 +291,9 @@ template <typename DerivedT> class CodeGenPassBuilder {
                                    inconvertibleErrorCode());
   }
 
+  /// Target can override this to add GlobalMergePass before all IR passes.
+  void addGlobalMergePass(AddIRPass &) const {}
----------------
efriedma-quic wrote:

It sounds like it already is running at the very beginning of the codegen pipeline?  doInitialization runs before any passes, I think.

If it did run in the optimization pipeline, it would have to be very late; the target hooks use information about the exact load/store ops that access the global to pick appropriate thresholds.  And it messes with alias analysis a bit for mutable variables.  So ultimately it wouldn't be much different from running it in early codegen.  (Which is really too early for constants, given the pass can't see constant pools, but that's a different issue.)

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


More information about the llvm-commits mailing list