llvm-project/llvm/lib/Target/AMDGPU/AMDGPUSplitModule.h
Pierre van Houtryve 43fd244b3d Reland "[AMDGPU] Add AMDGPU-specific module splitting (#89245)"
(with fix for ubsan)

This enables the --lto-partitions option to work more consistently.

This module splitting logic is fully aware of AMDGPU modules and their
specificities and takes advantage of
them to split modules in a way that avoids compilation issue (such as
resource usage being incorrectly represented).

This also includes a logging system that's more elaborate than just
LLVM_DEBUG which allows
printing logs to uniquely named files, and optionally with all value
names hidden so they can be safely shared without leaking informatiton
about the source. Logs can also be enabled through an environment
variable, which avoids the sometimes complicated process of passing a
-mllvm option all the way from clang driver to the offload linker that
handles full LTO codegen.
2024-05-27 10:43:00 +02:00

31 lines
1.0 KiB
C++

//===- AMDGPUSplitModule.h -------------------------------------*- 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
//
//===----------------------------------------------------------------------===//
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_TARGET_AMDGPUSPLITMODULE_H
#define LLVM_TARGET_AMDGPUSPLITMODULE_H
#include "llvm/ADT/STLFunctionalExtras.h"
#include <memory>
namespace llvm {
class Module;
class AMDGPUTargetMachine;
/// Splits the module M into N linkable partitions. The function ModuleCallback
/// is called N times passing each individual partition as the MPart argument.
void splitAMDGPUModule(
const AMDGPUTargetMachine &TM, Module &M, unsigned N,
function_ref<void(std::unique_ptr<Module> MPart)> ModuleCallback);
} // end namespace llvm
#endif // LLVM_TARGET_AMDGPUSPLITMODULE_H