10b57cec5SDimitry Andric //===- SplitModule.h - Split a module into partitions -----------*- C++ -*-===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric // 90b57cec5SDimitry Andric // This file defines the function llvm::SplitModule, which splits a module 100b57cec5SDimitry Andric // into multiple linkable partitions. It can be used to implement parallel code 110b57cec5SDimitry Andric // generation for link-time optimization. 120b57cec5SDimitry Andric // 130b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 140b57cec5SDimitry Andric 150b57cec5SDimitry Andric #ifndef LLVM_TRANSFORMS_UTILS_SPLITMODULE_H 160b57cec5SDimitry Andric #define LLVM_TRANSFORMS_UTILS_SPLITMODULE_H 170b57cec5SDimitry Andric 1881ad6265SDimitry Andric #include "llvm/ADT/STLFunctionalExtras.h" 190b57cec5SDimitry Andric #include <memory> 200b57cec5SDimitry Andric 210b57cec5SDimitry Andric namespace llvm { 220b57cec5SDimitry Andric 230b57cec5SDimitry Andric class Module; 240b57cec5SDimitry Andric 250b57cec5SDimitry Andric /// Splits the module M into N linkable partitions. The function ModuleCallback 260b57cec5SDimitry Andric /// is called N times passing each individual partition as the MPart argument. 27*0fca6ea1SDimitry Andric /// PreserveLocals: Split without externalizing locals. 28*0fca6ea1SDimitry Andric /// RoundRobin: Use round-robin distribution of functions to modules instead 29*0fca6ea1SDimitry Andric /// of the default name-hash-based one. 300b57cec5SDimitry Andric /// 310b57cec5SDimitry Andric /// FIXME: This function does not deal with the somewhat subtle symbol 320b57cec5SDimitry Andric /// visibility issues around module splitting, including (but not limited to): 330b57cec5SDimitry Andric /// 340b57cec5SDimitry Andric /// - Internal symbols should not collide with symbols defined outside the 350b57cec5SDimitry Andric /// module. 360b57cec5SDimitry Andric /// - Internal symbols defined in module-level inline asm should be visible to 370b57cec5SDimitry Andric /// each partition. 380b57cec5SDimitry Andric void SplitModule( 39fe6060f1SDimitry Andric Module &M, unsigned N, 400b57cec5SDimitry Andric function_ref<void(std::unique_ptr<Module> MPart)> ModuleCallback, 41*0fca6ea1SDimitry Andric bool PreserveLocals = false, bool RoundRobin = false); 420b57cec5SDimitry Andric 430b57cec5SDimitry Andric } // end namespace llvm 440b57cec5SDimitry Andric 450b57cec5SDimitry Andric #endif // LLVM_TRANSFORMS_UTILS_SPLITMODULE_H 46