summaryrefslogtreecommitdiff
path: root/tools/lto
diff options
context:
space:
mode:
authorTom Roeder <tmroeder@google.com>2014-04-25 21:46:51 +0000
committerTom Roeder <tmroeder@google.com>2014-04-25 21:46:51 +0000
commit817f5e2fa137b15b536c952bcc1e75b1dd34b4b1 (patch)
treef514566a78e689fcc0c138b83fde6342a4c26c9a /tools/lto
parentc744a371534456c1bb6557f053705f066ac33b62 (diff)
downloadllvm-817f5e2fa137b15b536c952bcc1e75b1dd34b4b1.tar.gz
llvm-817f5e2fa137b15b536c952bcc1e75b1dd34b4b1.tar.bz2
llvm-817f5e2fa137b15b536c952bcc1e75b1dd34b4b1.tar.xz
Add an -mattr option to the gold plugin to support subtarget features in LTO
This adds support for an -mattr option to the gold plugin and to llvm-lto. This allows the caller to specify details of the subtarget architecture, like +aes, or +ssse3 on x86. Note that this requires a change to the include/llvm-c/lto.h interface: it adds a function lto_codegen_set_attr and it increments the version of the interface. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207279 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/lto')
-rw-r--r--tools/lto/lto.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/tools/lto/lto.cpp b/tools/lto/lto.cpp
index cc8318a8ba..06b1b05e7e 100644
--- a/tools/lto/lto.cpp
+++ b/tools/lto/lto.cpp
@@ -56,6 +56,20 @@ static void lto_initialize() {
}
}
+// Convert the subtarget features into a string to pass to LTOCodeGenerator.
+static void lto_add_attrs(lto_code_gen_t cg) {
+ if (MAttrs.size()) {
+ std::string attrs;
+ for (unsigned i = 0; i < MAttrs.size(); ++i) {
+ if (i > 0)
+ attrs.append(",");
+ attrs.append(MAttrs[i]);
+ }
+
+ cg->setAttr(attrs.c_str());
+ }
+}
+
/// lto_get_version - Returns a printable string.
extern const char* lto_get_version() {
return LTOCodeGenerator::getVersionString();
@@ -252,6 +266,11 @@ void lto_codegen_set_cpu(lto_code_gen_t cg, const char *cpu) {
return cg->setCpu(cpu);
}
+/// lto_codegen_set_attr - Sets the attr to generate code for.
+void lto_codegen_set_attr(lto_code_gen_t cg, const char *attr) {
+ return cg->setAttr(attr);
+}
+
/// lto_codegen_set_assembler_path - Sets the path to the assembler tool.
void lto_codegen_set_assembler_path(lto_code_gen_t cg, const char *path) {
// In here only for backwards compatibility. We use MC now.
@@ -278,6 +297,7 @@ void lto_codegen_add_must_preserve_symbol(lto_code_gen_t cg,
bool lto_codegen_write_merged_modules(lto_code_gen_t cg, const char *path) {
if (!parsedOptions) {
cg->parseCodeGenDebugOptions();
+ lto_add_attrs(cg);
parsedOptions = true;
}
return !cg->writeMergedModules(path, sLastErrorString);
@@ -292,6 +312,7 @@ bool lto_codegen_write_merged_modules(lto_code_gen_t cg, const char *path) {
const void *lto_codegen_compile(lto_code_gen_t cg, size_t *length) {
if (!parsedOptions) {
cg->parseCodeGenDebugOptions();
+ lto_add_attrs(cg);
parsedOptions = true;
}
return cg->compile(length, DisableOpt, DisableInline, DisableGVNLoadPRE,
@@ -304,6 +325,7 @@ const void *lto_codegen_compile(lto_code_gen_t cg, size_t *length) {
bool lto_codegen_compile_to_file(lto_code_gen_t cg, const char **name) {
if (!parsedOptions) {
cg->parseCodeGenDebugOptions();
+ lto_add_attrs(cg);
parsedOptions = true;
}
return !cg->compile_to_file(name, DisableOpt, DisableInline, DisableGVNLoadPRE,