[llvm] [offload][SYCL] Add Module splitting by categories. (PR #131347)

Shilei Tian via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 17 18:59:24 PDT 2025


================
@@ -0,0 +1,44 @@
+//===-------- SplitModuleByCategory.h - module split ------------*- 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
+//
+//===----------------------------------------------------------------------===//
+// Functionality to split a module by categories.
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TRANSFORM_UTILS_SPLIT_MODULE_BY_CATEGORY_H
+#define LLVM_TRANSFORM_UTILS_SPLIT_MODULE_BY_CATEGORY_H
+
+#include "llvm/ADT/STLFunctionalExtras.h"
+
+#include <memory>
+#include <optional>
+#include <string>
+
+namespace llvm {
+
+class Module;
+class Function;
+
+/// Splits the given module \p M using the given \p FunctionCategorizer.
+/// \p FunctionCategorizer returns integer category for an input Function.
----------------
shiltian wrote:

A side note, I think it'd be more helpful (at least putting on my AMD hat) to be able to determine where a global variable goes as well, if we'd like to make this pass generic to support all potential targets. The reason is, for AMDGPU, we probably need to categorize all functions that could potentially reference a global variable in the sam module, due to the lowering of LDS (shared) variables.

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


More information about the llvm-commits mailing list