[llvm-commits] [llvm] r110705 - in /llvm/trunk: include/llvm-c/lto.h tools/gold/gold-plugin.cpp tools/lto/LTOCodeGenerator.cpp tools/lto/LTOCodeGenerator.h tools/lto/lto.cpp
Rafael Espindola
rafael.espindola at gmail.com
Tue Aug 10 11:55:09 PDT 2010
Author: rafael
Date: Tue Aug 10 13:55:09 2010
New Revision: 110705
URL: http://llvm.org/viewvc/llvm-project?rev=110705&view=rev
Log:
Make it possible to set the flags passed to the assembler.
Nick, please review.
Modified:
llvm/trunk/include/llvm-c/lto.h
llvm/trunk/tools/gold/gold-plugin.cpp
llvm/trunk/tools/lto/LTOCodeGenerator.cpp
llvm/trunk/tools/lto/LTOCodeGenerator.h
llvm/trunk/tools/lto/lto.cpp
Modified: llvm/trunk/include/llvm-c/lto.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/lto.h?rev=110705&r1=110704&r2=110705&view=diff
==============================================================================
--- llvm/trunk/include/llvm-c/lto.h (original)
+++ llvm/trunk/include/llvm-c/lto.h Tue Aug 10 13:55:09 2010
@@ -220,6 +220,12 @@
extern void
lto_codegen_set_assembler_path(lto_code_gen_t cg, const char* path);
+/**
+ * Sets extra arguments that libLTO should pass to the assembler.
+ */
+extern void
+lto_codegen_set_assembler_args(lto_code_gen_t cg, const char **args,
+ int nargs);
/**
* Adds to a list of all global symbols that must exist in the final
Modified: llvm/trunk/tools/gold/gold-plugin.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/gold/gold-plugin.cpp?rev=110705&r1=110704&r2=110705&view=diff
==============================================================================
--- llvm/trunk/tools/gold/gold-plugin.cpp (original)
+++ llvm/trunk/tools/gold/gold-plugin.cpp Tue Aug 10 13:55:09 2010
@@ -66,6 +66,7 @@
static generate_bc generate_bc_file = BC_NO;
static std::string bc_path;
static std::string as_path;
+ static std::vector<std::string> as_args;
static std::vector<std::string> pass_through;
static std::string extra_library_path;
static std::string triple;
@@ -91,6 +92,9 @@
} else {
as_path = opt.substr(strlen("as="));
}
+ } else if (opt.startswith("as-arg=")) {
+ llvm::StringRef item = opt.substr(strlen("as-arg="));
+ as_args.push_back(item.str());
} else if (opt.startswith("extra-library-path=")) {
extra_library_path = opt.substr(strlen("extra_library_path="));
} else if (opt.startswith("pass-through=")) {
@@ -401,6 +405,14 @@
sys::Path p = sys::Program::FindProgramByName(options::as_path);
lto_codegen_set_assembler_path(cg, p.c_str());
}
+ if (!options::as_args.empty()) {
+ std::vector<const char *> as_args_p;
+ for (std::vector<std::string>::iterator I = options::as_args.begin(),
+ E = options::as_args.end(); I != E; ++I) {
+ as_args_p.push_back(I->c_str());
+ }
+ lto_codegen_set_assembler_args(cg, &as_args_p[0], as_args_p.size());
+ }
// Pass through extra options to the code generator.
if (!options::extra.empty()) {
for (std::vector<std::string>::iterator it = options::extra.begin();
Modified: llvm/trunk/tools/lto/LTOCodeGenerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.cpp?rev=110705&r1=110704&r2=110705&view=diff
==============================================================================
--- llvm/trunk/tools/lto/LTOCodeGenerator.cpp (original)
+++ llvm/trunk/tools/lto/LTOCodeGenerator.cpp Tue Aug 10 13:55:09 2010
@@ -126,6 +126,14 @@
_assemblerPath = new sys::Path(path);
}
+void LTOCodeGenerator::setAssemblerArgs(const char** args, int nargs)
+{
+ for (int i = 0; i < nargs; ++i) {
+ const char *arg = args[i];
+ _assemblerArgs.push_back(arg);
+ }
+}
+
void LTOCodeGenerator::addMustPreserveSymbol(const char* sym)
{
_mustPreserveSymbols[sym] = 1;
@@ -257,6 +265,11 @@
args.push_back("-c");
args.push_back("-x");
args.push_back("assembler");
+ } else {
+ for (std::vector<std::string>::iterator I = _assemblerArgs.begin(),
+ E = _assemblerArgs.end(); I != E; ++I) {
+ args.push_back(I->c_str());
+ }
}
args.push_back("-o");
args.push_back(objPath.c_str());
Modified: llvm/trunk/tools/lto/LTOCodeGenerator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.h?rev=110705&r1=110704&r2=110705&view=diff
==============================================================================
--- llvm/trunk/tools/lto/LTOCodeGenerator.h (original)
+++ llvm/trunk/tools/lto/LTOCodeGenerator.h Tue Aug 10 13:55:09 2010
@@ -37,6 +37,7 @@
bool setDebugInfo(lto_debug_model, std::string& errMsg);
bool setCodePICModel(lto_codegen_model, std::string& errMsg);
void setAssemblerPath(const char* path);
+ void setAssemblerArgs(const char** args, int nargs);
void addMustPreserveSymbol(const char* sym);
bool writeMergedModules(const char* path,
std::string& errMsg);
@@ -62,6 +63,7 @@
llvm::MemoryBuffer* _nativeObjectFile;
std::vector<const char*> _codegenOptions;
llvm::sys::Path* _assemblerPath;
+ std::vector<std::string> _assemblerArgs;
};
#endif // LTO_CODE_GENERATOR_H
Modified: llvm/trunk/tools/lto/lto.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/lto.cpp?rev=110705&r1=110704&r2=110705&view=diff
==============================================================================
--- llvm/trunk/tools/lto/lto.cpp (original)
+++ llvm/trunk/tools/lto/lto.cpp Tue Aug 10 13:55:09 2010
@@ -218,6 +218,16 @@
cg->setAssemblerPath(path);
}
+
+//
+// sets extra arguments that libLTO should pass to the assembler
+//
+void lto_codegen_set_assembler_args(lto_code_gen_t cg, const char** args,
+ int nargs)
+{
+ cg->setAssemblerArgs(args, nargs);
+}
+
//
// adds to a list of all global symbols that must exist in the final
// generated code. If a function is not listed there, it might be
More information about the llvm-commits
mailing list