1 //===- SplitModule.h - Split a module into partitions -----------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This file defines the function llvm::SplitModule, which splits a module 10 // into multiple linkable partitions. It can be used to implement parallel code 11 // generation for link-time optimization. 12 // 13 //===----------------------------------------------------------------------===// 14 15 #ifndef LLVM_TRANSFORMS_UTILS_SPLITMODULE_H 16 #define LLVM_TRANSFORMS_UTILS_SPLITMODULE_H 17 18 #include "llvm/ADT/STLFunctionalExtras.h" 19 #include <memory> 20 21 namespace llvm { 22 23 class Module; 24 25 /// Splits the module M into N linkable partitions. The function ModuleCallback 26 /// is called N times passing each individual partition as the MPart argument. 27 /// PreserveLocals: Split without externalizing locals. 28 /// RoundRobin: Use round-robin distribution of functions to modules instead 29 /// of the default name-hash-based one. 30 /// 31 /// FIXME: This function does not deal with the somewhat subtle symbol 32 /// visibility issues around module splitting, including (but not limited to): 33 /// 34 /// - Internal symbols should not collide with symbols defined outside the 35 /// module. 36 /// - Internal symbols defined in module-level inline asm should be visible to 37 /// each partition. 38 void SplitModule( 39 Module &M, unsigned N, 40 function_ref<void(std::unique_ptr<Module> MPart)> ModuleCallback, 41 bool PreserveLocals = false, bool RoundRobin = false); 42 43 } // end namespace llvm 44 45 #endif // LLVM_TRANSFORMS_UTILS_SPLITMODULE_H 46