summaryrefslogtreecommitdiff
path: root/tools/lto
diff options
context:
space:
mode:
authorEli Bendersky <eliben@google.com>2014-02-19 17:09:35 +0000
committerEli Bendersky <eliben@google.com>2014-02-19 17:09:35 +0000
commitcf42174647af5265e35f0e15fbffa17445ae0e80 (patch)
tree70f756244b660fb0330b77a87251b188ffb1a82a /tools/lto
parenteb5fe7002aa9276b86581da2220c895a85202a9a (diff)
downloadllvm-cf42174647af5265e35f0e15fbffa17445ae0e80.tar.gz
llvm-cf42174647af5265e35f0e15fbffa17445ae0e80.tar.bz2
llvm-cf42174647af5265e35f0e15fbffa17445ae0e80.tar.xz
Refactor TargetOptions initialization into a single place.
The same code (~20 lines) for initializing a TargetOptions object from CodeGen cmdline flags is duplicated 4 times in 4 different tools. This patch moves it into a utility function. Since the CodeGen/CommandFlags.h file defines cl::opt flags in a header, it's a bit of a touchy situation because we should only link them into tools. So this patch puts the init function in the header. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201699 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/lto')
-rw-r--r--tools/lto/lto.cpp40
1 files changed, 6 insertions, 34 deletions
diff --git a/tools/lto/lto.cpp b/tools/lto/lto.cpp
index d2f1ffdfa2..1b1e4626ef 100644
--- a/tools/lto/lto.cpp
+++ b/tools/lto/lto.cpp
@@ -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,8 +126,7 @@ 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);
}
@@ -162,8 +136,7 @@ lto_module_t lto_module_create_from_memory_with_path(const void* mem,
size_t length,
const char *path) {
lto_initialize();
- llvm::TargetOptions Options;
- lto_set_target_options(Options);
+ llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
return LTOModule::makeLTOModule(mem, length, Options, sLastErrorString, path);
}
@@ -238,8 +211,7 @@ void lto_codegen_set_diagnostic_handler(lto_code_gen_t cg,
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)