[llvm] Reland: Port Swift's merge function pass to llvm: merging functions that differ in constants (PR #71584)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 7 13:11:57 PST 2023


================
@@ -0,0 +1,1187 @@
+//===--- MergeFunctionsIgnoringConst.cpp - Merge functions ----------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This pass looks for similar functions that are mergeable and folds them.
+// The implementation is similar to LLVM's MergeFunctions pass. Instead of
+// merging identical functions, it merges functions which only differ by a few
+// constants in certain instructions.
+// This is copied from Swift's implementation.
+//
+// This pass should run after LLVM's MergeFunctions pass, because it works best
+// if there are no _identical_ functions in the module.
+// Note: it would also work for identical functions but could produce more
+// code overhead than the LLVM pass.
----------------
nikic wrote:

Talking about "the LLVM pass" is odd when this is also an LLVM pass.

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


More information about the llvm-commits mailing list