summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-lto2/llvm-lto2.cpp
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2016-12-08 05:28:30 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2016-12-08 05:28:30 +0000
commitf4257528e967dae1cf49328f2a8cfdc28815a2f3 (patch)
treefc36e6dc56613a56774c2e8b5476f0c09fc71ff0 /llvm/tools/llvm-lto2/llvm-lto2.cpp
parentb2979d84647ab3b2e449c5302b256da2b846e02e (diff)
downloadbcm5719-llvm-f4257528e967dae1cf49328f2a8cfdc28815a2f3.tar.gz
bcm5719-llvm-f4257528e967dae1cf49328f2a8cfdc28815a2f3.zip
LTO: Hash the parts of the LTO configuration that affect code generation.
Most importantly, we need to hash the relocation model, otherwise we can end up trying to link non-PIC object files into PIEs or DSOs. Differential Revision: https://reviews.llvm.org/D27556 llvm-svn: 289024
Diffstat (limited to 'llvm/tools/llvm-lto2/llvm-lto2.cpp')
-rw-r--r--llvm/tools/llvm-lto2/llvm-lto2.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/llvm/tools/llvm-lto2/llvm-lto2.cpp b/llvm/tools/llvm-lto2/llvm-lto2.cpp
index 01756d2c764..e8bf7a397f2 100644
--- a/llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ b/llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -17,6 +17,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/LTO/Caching.h"
+#include "llvm/CodeGen/CommandFlags.h"
#include "llvm/LTO/LTO.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/TargetSelect.h"
@@ -31,6 +32,11 @@ static cl::opt<char>
"(default = '-O2')"),
cl::Prefix, cl::ZeroOrMore, cl::init('2'));
+static cl::opt<char> CGOptLevel(
+ "cg-opt-level",
+ cl::desc("Codegen optimization level (0, 1, 2 or 3, default = '2')"),
+ cl::init('2'));
+
static cl::list<std::string> InputFilenames(cl::Positional, cl::OneOrMore,
cl::desc("<input bitcode files>"));
@@ -74,6 +80,15 @@ static cl::list<std::string> SymbolResolutions(
"A resolution for each symbol must be specified."),
cl::ZeroOrMore);
+static cl::opt<std::string> OverrideTriple(
+ "override-triple",
+ cl::desc("Replace target triples in input files with this triple"));
+
+static cl::opt<std::string> DefaultTriple(
+ "default-triple",
+ cl::desc(
+ "Replace unspecified target triples in input files with this triple"));
+
static void check(Error E, std::string Msg) {
if (!E)
return;
@@ -146,6 +161,13 @@ int main(int argc, char **argv) {
exit(1);
};
+ Conf.CPU = MCPU;
+ Conf.Options = InitTargetOptionsFromCodeGenFlags();
+ Conf.MAttrs = MAttrs;
+ if (auto RM = getRelocModel())
+ Conf.RelocModel = *RM;
+ Conf.CodeModel = CMModel;
+
if (SaveTemps)
check(Conf.addSaveTemps(OutputFilename + "."),
"Config::addSaveTemps failed");
@@ -155,6 +177,26 @@ int main(int argc, char **argv) {
Conf.AAPipeline = AAPipeline;
Conf.OptLevel = OptLevel - '0';
+ switch (CGOptLevel) {
+ case '0':
+ Conf.CGOptLevel = CodeGenOpt::None;
+ break;
+ case '1':
+ Conf.CGOptLevel = CodeGenOpt::Less;
+ break;
+ case '2':
+ Conf.CGOptLevel = CodeGenOpt::Default;
+ break;
+ case '3':
+ Conf.CGOptLevel = CodeGenOpt::Aggressive;
+ break;
+ default:
+ llvm::errs() << "invalid cg optimization level: " << CGOptLevel << '\n';
+ return 1;
+ }
+
+ Conf.OverrideTriple = OverrideTriple;
+ Conf.DefaultTriple = DefaultTriple;
ThinBackend Backend;
if (ThinLTODistributedIndexes)
OpenPOWER on IntegriCloud