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

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 27 06:01:51 PDT 2023


================
@@ -0,0 +1,39 @@
+//===- MergeFunctionsIgnoringConst.h - Merge Functions ----------*- C++ -*-===//
+//
+// 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 transforms simple global variables that never have their address
+// taken.  If obviously true, it marks read/write globals as constant, deletes
+// variables only stored to, etc.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TRANSFORMS_IPO_MERGEFUNCTIONSIGNORINGCONST_H
+#define LLVM_TRANSFORMS_IPO_MERGEFUNCTIONSIGNORINGCONST_H
+
+#include "llvm/IR/PassManager.h"
+
+namespace llvm {
+
+class Module;
+
+/// Merge functions that differ by constants.
+class MergeFuncIgnoringConstPass
+    : public PassInfoMixin<MergeFuncIgnoringConstPass> {
+  bool ptrAuthEnabled = false;
+  unsigned ptrAuthKey = 0;
+  std::string mergeFuncSuffix = ".Tm";
+public:
+  MergeFuncIgnoringConstPass() {}
+  MergeFuncIgnoringConstPass(bool ptrAuthEnabled, unsigned ptrAuthKey, std::string suffix)
----------------
fhahn wrote:

All those args are dead code ATM?

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


More information about the llvm-commits mailing list