summaryrefslogtreecommitdiff
path: root/tools/llvm-lto/llvm-lto.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-09-30 16:39:19 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-09-30 16:39:19 +0000
commitc13c9e5a9d288eac494a38f0710d34446167f940 (patch)
tree9963870fcea50321766abe308393c6f996187897 /tools/llvm-lto/llvm-lto.cpp
parent4b5205d2a3e0df909f29de0bff8ea775ad21fe0f (diff)
downloadllvm-c13c9e5a9d288eac494a38f0710d34446167f940.tar.gz
llvm-c13c9e5a9d288eac494a38f0710d34446167f940.tar.bz2
llvm-c13c9e5a9d288eac494a38f0710d34446167f940.tar.xz
Move command line options to the users of libLTO. Fixes --enable-shared build.
Patch by Richard Sandiford. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191680 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-lto/llvm-lto.cpp')
-rw-r--r--tools/llvm-lto/llvm-lto.cpp57
1 files changed, 48 insertions, 9 deletions
diff --git a/tools/llvm-lto/llvm-lto.cpp b/tools/llvm-lto/llvm-lto.cpp
index 82a2c8288f..2f51c0c3d0 100644
--- a/tools/llvm-lto/llvm-lto.cpp
+++ b/tools/llvm-lto/llvm-lto.cpp
@@ -12,6 +12,7 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/CodeGen/CommandFlags.h"
#include "llvm/LTO/LTOCodeGenerator.h"
#include "llvm/LTO/LTOModule.h"
#include "llvm/Support/CommandLine.h"
@@ -23,13 +24,26 @@
using namespace llvm;
-static cl::list<std::string> InputFilenames(cl::Positional, cl::OneOrMore,
- cl::desc("<input bitcode files>"));
+static cl::opt<bool>
+DisableOpt("disable-opt", cl::init(false),
+ cl::desc("Do not run any optimization passes"));
-static cl::opt<std::string> OutputFilename("o",
- cl::desc("Override output filename"),
- cl::init(""),
- cl::value_desc("filename"));
+static cl::opt<bool>
+DisableInline("disable-inlining", cl::init(false),
+ cl::desc("Do not run the inliner pass"));
+
+static cl::opt<bool>
+DisableGVNLoadPRE("disable-gvn-loadpre", cl::init(false),
+ cl::desc("Do not run the GVN load PRE pass"));
+
+static cl::list<std::string>
+InputFilenames(cl::Positional, cl::OneOrMore,
+ cl::desc("<input bitcode files>"));
+
+static cl::opt<std::string>
+OutputFilename("o", cl::init(""),
+ cl::desc("Override output filename"),
+ cl::value_desc("filename"));
int main(int argc, char **argv) {
// Print a stack trace if we signal out.
@@ -45,6 +59,28 @@ int main(int argc, char **argv) {
InitializeAllAsmPrinters();
InitializeAllAsmParsers();
+ // set up the TargetOptions for the machine
+ 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 != 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;
+
unsigned BaseArg = 0;
std::string ErrorMessage;
@@ -52,11 +88,12 @@ int main(int argc, char **argv) {
CodeGen.setCodePICModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC);
CodeGen.setDebugInfo(LTO_DEBUG_MODEL_DWARF);
+ CodeGen.setTargetOptions(Options);
for (unsigned i = BaseArg; i < InputFilenames.size(); ++i) {
std::string error;
OwningPtr<LTOModule> Module(LTOModule::makeLTOModule(InputFilenames[i].c_str(),
- error));
+ Options, error));
if (!error.empty()) {
errs() << argv[0] << ": error loading file '" << InputFilenames[i]
<< "': " << error << "\n";
@@ -74,7 +111,8 @@ int main(int argc, char **argv) {
if (!OutputFilename.empty()) {
size_t len = 0;
std::string ErrorInfo;
- const void *Code = CodeGen.compile(&len, ErrorInfo);
+ const void *Code = CodeGen.compile(&len, DisableOpt, DisableInline,
+ DisableGVNLoadPRE, ErrorInfo);
if (Code == NULL) {
errs() << argv[0]
<< ": error compiling the code: " << ErrorInfo << "\n";
@@ -92,7 +130,8 @@ int main(int argc, char **argv) {
} else {
std::string ErrorInfo;
const char *OutputName = NULL;
- if (!CodeGen.compile_to_file(&OutputName, ErrorInfo)) {
+ if (!CodeGen.compile_to_file(&OutputName, DisableOpt, DisableInline,
+ DisableGVNLoadPRE, ErrorInfo)) {
errs() << argv[0]
<< ": error compiling the code: " << ErrorInfo
<< "\n";