Index: include/llvm/LTO/LTO.h =================================================================== --- /dev/null +++ include/llvm/LTO/LTO.h @@ -1,74 +0,0 @@ -//===-LTO.h - LLVM Link Time Optimizer ------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file declares functions and classes used to support LTO. It is intended -// to be used both by LTO classes as well as by clients (gold-plugin) that -// don't utilize the LTO code generator interfaces. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_LTO_LTO_H -#define LLVM_LTO_LTO_H - -#include "llvm/ADT/StringMap.h" -#include "llvm/IR/ModuleSummaryIndex.h" - -namespace llvm { - -class LLVMContext; -class MemoryBufferRef; -class Module; - -/// Helper to load a module from bitcode. -std::unique_ptr loadModuleFromBuffer(const MemoryBufferRef &Buffer, - LLVMContext &Context, bool Lazy); - -/// Provide a "loader" for the FunctionImporter to access function from other -/// modules. -class ModuleLoader { - /// The context that will be used for importing. - LLVMContext &Context; - - /// Map from Module identifier to MemoryBuffer. Used by clients like the - /// FunctionImported to request loading a Module. - StringMap &ModuleMap; - -public: - ModuleLoader(LLVMContext &Context, StringMap &ModuleMap) - : Context(Context), ModuleMap(ModuleMap) {} - - /// Load a module on demand. - std::unique_ptr operator()(StringRef Identifier) { - return loadModuleFromBuffer(ModuleMap[Identifier], Context, /*Lazy*/ true); - } -}; - - -/// Resolve Weak and LinkOnce values in the \p Index. Linkage changes recorded -/// in the index and the ThinLTO backends must apply the changes to the Module -/// via thinLTOResolveWeakForLinkerModule. -/// -/// This is done for correctness (if value exported, ensure we always -/// emit a copy), and compile-time optimization (allow drop of duplicates). -void thinLTOResolveWeakForLinkerInIndex( - ModuleSummaryIndex &Index, - function_ref - isPrevailing, - function_ref - recordNewLinkage); - -/// Update the linkages in the given \p Index to mark exported values -/// as external and non-exported values as internal. The ThinLTO backends -/// must apply the changes to the Module via thinLTOInternalizeModule. -void thinLTOInternalizeAndPromoteInIndex( - ModuleSummaryIndex &Index, - function_ref isExported); -} - -#endif Index: lib/LTO/CMakeLists.txt =================================================================== --- lib/LTO/CMakeLists.txt +++ lib/LTO/CMakeLists.txt @@ -48,7 +48,6 @@ add_llvm_library(LLVMLTO - LTO.cpp LTOModule.cpp LTOCodeGenerator.cpp UpdateCompilerUsed.cpp @@ -60,3 +59,5 @@ ) add_dependencies(LLVMLTO intrinsics_gen) + +add_subdirectory(Resolution) Index: lib/LTO/LLVMBuild.txt =================================================================== --- lib/LTO/LLVMBuild.txt +++ lib/LTO/LLVMBuild.txt @@ -15,6 +15,9 @@ ; ;===------------------------------------------------------------------------===; +[common] +subdirectories = Resolution + [component_0] type = Library name = LTO @@ -27,6 +30,7 @@ Core IPO InstCombine + LTOResolution Linker MC ObjCARC @@ -34,4 +38,4 @@ Scalar Support Target - TransformUtils \ No newline at end of file + TransformUtils Index: lib/LTO/Resolution/CMakeLists.txt =================================================================== --- /dev/null +++ lib/LTO/Resolution/CMakeLists.txt @@ -0,0 +1,3 @@ +add_llvm_library(LLVMLTOResolution + LTO.cpp +) Index: lib/LTO/Resolution/LLVMBuild.txt =================================================================== --- lib/LTO/Resolution/LLVMBuild.txt +++ lib/LTO/Resolution/LLVMBuild.txt @@ -1,4 +1,4 @@ -;===- ./lib/LTO/LLVMBuild.txt ----------------------------------*- Conf -*--===; +;===- ./lib/LTO/Resolution/LLVMBuild.txt -----------------------*- Conf -*--===; ; ; The LLVM Compiler Infrastructure ; @@ -17,21 +17,10 @@ [component_0] type = Library -name = LTO +name = LTOResolution parent = Libraries required_libraries = - Analysis BitReader BitWriter - CodeGen Core - IPO - InstCombine - Linker - MC - ObjCARC - Object - Scalar Support - Target - TransformUtils \ No newline at end of file Index: lib/LTO/Resolution/LTO.cpp =================================================================== --- lib/LTO/Resolution/LTO.cpp +++ lib/LTO/Resolution/LTO.cpp @@ -11,7 +11,7 @@ // //===----------------------------------------------------------------------===// -#include "llvm/LTO/LTO.h" +#include "llvm/LTO/Resolution/LTO.h" #include "llvm/Bitcode/ReaderWriter.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/SourceMgr.h" Index: lib/LTO/ThinLTOCodeGenerator.cpp =================================================================== --- lib/LTO/ThinLTOCodeGenerator.cpp +++ lib/LTO/ThinLTOCodeGenerator.cpp @@ -31,7 +31,7 @@ #include "llvm/IR/LegacyPassManager.h" #include "llvm/IR/Mangler.h" #include "llvm/IRReader/IRReader.h" -#include "llvm/LTO/LTO.h" +#include "llvm/LTO/Resolution/LTO.h" #include "llvm/Linker/Linker.h" #include "llvm/MC/SubtargetFeature.h" #include "llvm/Object/IRObjectFile.h" Index: tools/gold/gold-plugin.cpp =================================================================== --- tools/gold/gold-plugin.cpp +++ tools/gold/gold-plugin.cpp @@ -28,7 +28,7 @@ #include "llvm/IR/LegacyPassManager.h" #include "llvm/IR/Module.h" #include "llvm/IR/Verifier.h" -#include "llvm/LTO/LTO.h" +#include "llvm/LTO/Resolution/LTO.h" #include "llvm/Linker/IRMover.h" #include "llvm/MC/SubtargetFeature.h" #include "llvm/Object/IRObjectFile.h"