summaryrefslogtreecommitdiffstats
path: root/tools/lto
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2014-04-23 16:57:46 -0700
committerStephen Hines <srhines@google.com>2014-04-24 15:53:16 -0700
commit36b56886974eae4f9c5ebc96befd3e7bfe5de338 (patch)
treee6cfb69fbbd937f450eeb83bfb83b9da3b01275a /tools/lto
parent69a8640022b04415ae9fac62f8ab090601d8f889 (diff)
downloadexternal_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.zip
external_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.tar.gz
external_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.tar.bz2
Update to LLVM 3.5a.
Change-Id: Ifadecab779f128e62e430c2b4f6ddd84953ed617
Diffstat (limited to 'tools/lto')
-rw-r--r--tools/lto/CMakeLists.txt49
-rw-r--r--tools/lto/Makefile14
-rw-r--r--tools/lto/lto.cpp80
-rw-r--r--tools/lto/lto.exports6
4 files changed, 65 insertions, 84 deletions
diff --git a/tools/lto/CMakeLists.txt b/tools/lto/CMakeLists.txt
index 957a9f0..542053b 100644
--- a/tools/lto/CMakeLists.txt
+++ b/tools/lto/CMakeLists.txt
@@ -1,6 +1,11 @@
set(LLVM_LINK_COMPONENTS
${LLVM_TARGETS_TO_BUILD}
- ipo scalaropts linker bitreader bitwriter lto mcdisassembler vectorize)
+ Core
+ LTO
+ MC
+ MCDisassembler
+ Support
+ )
add_definitions( -DLLVM_VERSION_INFO=\"${PACKAGE_VERSION}\" )
@@ -9,43 +14,13 @@ set(SOURCES
lto.cpp
)
-if( NOT CYGWIN AND LLVM_ENABLE_PIC )
- if ( WIN32 )
- # Create .def file containing a list of exports preceeded by
- # 'EXPORTS'. The file "lto.exports" already contains the list, so we
- # massage it into the correct format here to create "lto.exports.def".
- set(LTO_EXPORTS_DEF ${CMAKE_CURRENT_BINARY_DIR}/lto.exports.def)
- set(LTO_EXPORTS_DEF_TEMP ${LTO_EXPORTS_DEF}.txt)
- file(READ "lto.exports" exports_list)
- file(WRITE ${LTO_EXPORTS_DEF_TEMP} "LIBRARY LTO\n")
- file(APPEND ${LTO_EXPORTS_DEF_TEMP} "EXPORTS\n")
- file(APPEND ${LTO_EXPORTS_DEF_TEMP} ${exports_list})
-
- # Copy the file only if it has changed.
- execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
- ${LTO_EXPORTS_DEF_TEMP} ${LTO_EXPORTS_DEF})
-
- set(SHARED_LIB_SOURCES ${SOURCES} ${LTO_EXPORTS_DEF})
- else()
- set(SHARED_LIB_SOURCES ${SOURCES})
- endif()
+set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/lto.exports)
- set(bsl ${BUILD_SHARED_LIBS})
- set(BUILD_SHARED_LIBS ON)
- add_llvm_library(LTO ${SHARED_LIB_SOURCES})
- set_property(TARGET LTO PROPERTY OUTPUT_NAME "LTO")
- set(BUILD_SHARED_LIBS ${bsl})
- set(LTO_STATIC_TARGET_NAME LTO_static)
-else()
- set(LTO_STATIC_TARGET_NAME LTO)
+if(NOT CYGWIN AND LLVM_ENABLE_PIC)
+ set(ENABLE_SHARED SHARED)
endif()
-if( NOT BUILD_SHARED_LIBS )
- add_llvm_library(${LTO_STATIC_TARGET_NAME} ${SOURCES})
- set_property(TARGET ${LTO_STATIC_TARGET_NAME} PROPERTY OUTPUT_NAME "LTO")
-endif()
+add_llvm_library(LTO ${ENABLE_SHARED} STATIC ${SOURCES})
-if( NOT CYGWIN )
- install(FILES ${LLVM_MAIN_INCLUDE_DIR}/llvm-c/lto.h
- DESTINATION include/llvm-c)
-endif()
+install(FILES ${LLVM_MAIN_INCLUDE_DIR}/llvm-c/lto.h
+ DESTINATION include/llvm-c)
diff --git a/tools/lto/Makefile b/tools/lto/Makefile
index cedbee1..a4fe9ac 100644
--- a/tools/lto/Makefile
+++ b/tools/lto/Makefile
@@ -9,8 +9,7 @@
LEVEL := ../..
LIBRARYNAME := LTO
-LINK_COMPONENTS := all-targets ipo scalaropts linker bitreader bitwriter \
- lto mcdisassembler vectorize
+LINK_COMPONENTS := all-targets core lto mc mcdisassembler support
LINK_LIBS_IN_SHARED := 1
SHARED_LIBRARY := 1
@@ -37,17 +36,6 @@ ifeq ($(HOST_OS),Darwin)
-Wl,$(LTO_LIBRARY_VERSION).$(LLVM_SUBMIT_SUBVERSION) \
-Wl,-compatibility_version -Wl,1
endif
- # extra options to override libtool defaults
- LLVMLibsOptions := $(LLVMLibsOptions) \
- -Wl,-dead_strip
-
- # Mac OS X 10.4 and earlier tools do not allow a second -install_name on command line
- DARWIN_VERS := $(shell echo $(TARGET_TRIPLE) | sed 's/.*darwin\([0-9]*\).*/\1/')
- ifneq ($(DARWIN_VERS),8)
- LLVMLibsOptions := $(LLVMLibsOptions) \
- -Wl,-install_name \
- -Wl,"@executable_path/../lib/lib$(LIBRARYNAME)$(SHLIBEXT)"
- endif
# If we're doing an Apple-style build, add the LTO object path.
ifeq ($(RC_XBS),YES)
diff --git a/tools/lto/lto.cpp b/tools/lto/lto.cpp
index 7bfddcd..cc8318a 100644
--- a/tools/lto/lto.cpp
+++ b/tools/lto/lto.cpp
@@ -13,11 +13,11 @@
//===----------------------------------------------------------------------===//
#include "llvm-c/lto.h"
+#include "llvm-c/Core.h"
+#include "llvm-c/Target.h"
#include "llvm/CodeGen/CommandFlags.h"
#include "llvm/LTO/LTOCodeGenerator.h"
#include "llvm/LTO/LTOModule.h"
-#include "llvm-c/Core.h"
-#include "llvm-c/Target.h"
// extra command-line flags needed for LTOCodeGenerator
static cl::opt<bool>
@@ -56,28 +56,6 @@ static void lto_initialize() {
}
}
-static void lto_set_target_options(llvm::TargetOptions &Options) {
- Options.LessPreciseFPMADOption = EnableFPMAD;
- Options.NoFramePointerElim = DisableFPElim;
- Options.AllowFPOpFusion = FuseFPOps;
- Options.UnsafeFPMath = EnableUnsafeFPMath;
- Options.NoInfsFPMath = EnableNoInfsFPMath;
- Options.NoNaNsFPMath = EnableNoNaNsFPMath;
- Options.HonorSignDependentRoundingFPMathOption =
- EnableHonorSignDependentRoundingFPMath;
- Options.UseSoftFloat = GenerateSoftFloatCalls;
- if (FloatABIForCalls != llvm::FloatABI::Default)
- Options.FloatABIType = FloatABIForCalls;
- Options.NoZerosInBSS = DontPlaceZerosInBSS;
- Options.GuaranteedTailCallOpt = EnableGuaranteedTailCallOpt;
- Options.DisableTailCalls = DisableTailCalls;
- Options.StackAlignmentOverride = OverrideStackAlignment;
- Options.TrapFuncName = TrapFuncName;
- Options.PositionIndependentExecutable = EnablePIE;
- Options.EnableSegmentedStacks = SegmentedStacks;
- Options.UseInitArray = UseInitArray;
-}
-
/// lto_get_version - Returns a printable string.
extern const char* lto_get_version() {
return LTOCodeGenerator::getVersionString();
@@ -120,8 +98,7 @@ lto_module_is_object_file_in_memory_for_target(const void* mem,
/// (check lto_get_error_message() for details).
lto_module_t lto_module_create(const char* path) {
lto_initialize();
- llvm::TargetOptions Options;
- lto_set_target_options(Options);
+ llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
return LTOModule::makeLTOModule(path, Options, sLastErrorString);
}
@@ -129,8 +106,7 @@ lto_module_t lto_module_create(const char* path) {
/// error (check lto_get_error_message() for details).
lto_module_t lto_module_create_from_fd(int fd, const char *path, size_t size) {
lto_initialize();
- llvm::TargetOptions Options;
- lto_set_target_options(Options);
+ llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
return LTOModule::makeLTOModule(fd, path, size, Options, sLastErrorString);
}
@@ -141,8 +117,7 @@ lto_module_t lto_module_create_from_fd_at_offset(int fd, const char *path,
size_t map_size,
off_t offset) {
lto_initialize();
- llvm::TargetOptions Options;
- lto_set_target_options(Options);
+ llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
return LTOModule::makeLTOModule(fd, path, map_size, offset, Options,
sLastErrorString);
}
@@ -151,11 +126,20 @@ lto_module_t lto_module_create_from_fd_at_offset(int fd, const char *path,
/// NULL on error (check lto_get_error_message() for details).
lto_module_t lto_module_create_from_memory(const void* mem, size_t length) {
lto_initialize();
- llvm::TargetOptions Options;
- lto_set_target_options(Options);
+ llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
return LTOModule::makeLTOModule(mem, length, Options, sLastErrorString);
}
+/// Loads an object file from memory with an extra path argument.
+/// Returns NULL on error (check lto_get_error_message() for details).
+lto_module_t lto_module_create_from_memory_with_path(const void* mem,
+ size_t length,
+ const char *path) {
+ lto_initialize();
+ llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
+ return LTOModule::makeLTOModule(mem, length, Options, sLastErrorString, path);
+}
+
/// lto_module_dispose - Frees all memory for a module. Upon return the
/// lto_module_t is no longer valid.
void lto_module_dispose(lto_module_t mod) {
@@ -193,13 +177,41 @@ lto_symbol_attributes lto_module_get_symbol_attribute(lto_module_t mod,
return mod->getSymbolAttributes(index);
}
+/// lto_module_get_num_deplibs - Returns the number of dependent libraries in
+/// the object module.
+unsigned int lto_module_get_num_deplibs(lto_module_t mod) {
+ return mod->getDependentLibraryCount();
+}
+
+/// lto_module_get_deplib - Returns the ith dependent library in the module.
+const char* lto_module_get_deplib(lto_module_t mod, unsigned int index) {
+ return mod->getDependentLibrary(index);
+}
+
+/// lto_module_get_num_linkeropts - Returns the number of linker options in the
+/// object module.
+unsigned int lto_module_get_num_linkeropts(lto_module_t mod) {
+ return mod->getLinkerOptCount();
+}
+
+/// lto_module_get_linkeropt - Returns the ith linker option in the module.
+const char* lto_module_get_linkeropt(lto_module_t mod, unsigned int index) {
+ return mod->getLinkerOpt(index);
+}
+
+/// Set a diagnostic handler.
+void lto_codegen_set_diagnostic_handler(lto_code_gen_t cg,
+ lto_diagnostic_handler_t diag_handler,
+ void *ctxt) {
+ cg->setDiagnosticHandler(diag_handler, ctxt);
+}
+
/// lto_codegen_create - Instantiates a code generator. Returns NULL if there
/// is an error.
lto_code_gen_t lto_codegen_create(void) {
lto_initialize();
- TargetOptions Options;
- lto_set_target_options(Options);
+ TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
LTOCodeGenerator *CodeGen = new LTOCodeGenerator();
if (CodeGen)
diff --git a/tools/lto/lto.exports b/tools/lto/lto.exports
index 46d0d74..b10ab1a 100644
--- a/tools/lto/lto.exports
+++ b/tools/lto/lto.exports
@@ -5,6 +5,11 @@ lto_module_create
lto_module_create_from_fd
lto_module_create_from_fd_at_offset
lto_module_create_from_memory
+lto_module_create_from_memory_with_path
+lto_module_get_deplib
+lto_module_get_linkeropt
+lto_module_get_num_deplibs
+lto_module_get_num_linkeropts
lto_module_get_num_symbols
lto_module_get_symbol_attribute
lto_module_get_symbol_name
@@ -15,6 +20,7 @@ lto_module_is_object_file_for_target
lto_module_is_object_file_in_memory
lto_module_is_object_file_in_memory_for_target
lto_module_dispose
+lto_codegen_set_diagnostic_handler
lto_codegen_add_module
lto_codegen_add_must_preserve_symbol
lto_codegen_compile