[llvm-commits] [llvm] r105414 - /llvm/trunk/tools/gold/gold-plugin.cpp
Rafael Espindola
rafael.espindola at gmail.com
Thu Jun 3 14:11:20 PDT 2010
Author: rafael
Date: Thu Jun 3 16:11:20 2010
New Revision: 105414
URL: http://llvm.org/viewvc/llvm-project?rev=105414&view=rev
Log:
Add a emit-llvm option to the plugin and make the path argument to also-emit-llvm optional.
Modified:
llvm/trunk/tools/gold/gold-plugin.cpp
Modified: llvm/trunk/tools/gold/gold-plugin.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/gold/gold-plugin.cpp?rev=105414&r1=105413&r2=105414&view=diff
==============================================================================
--- llvm/trunk/tools/gold/gold-plugin.cpp (original)
+++ llvm/trunk/tools/gold/gold-plugin.cpp Thu Jun 3 16:11:20 2010
@@ -53,12 +53,15 @@
};
lto_codegen_model output_type = LTO_CODEGEN_PIC_MODEL_STATIC;
+ std::string output_name = "";
std::list<claimed_file> Modules;
std::vector<sys::Path> Cleanup;
}
namespace options {
+ enum generate_bc { BC_NO, BC_ALSO, BC_ONLY };
static bool generate_api_file = false;
+ static generate_bc generate_bc_file = BC_NO;
static std::string bc_path;
static const char *as_path = NULL;
// Additional options to pass into the code generator.
@@ -82,8 +85,13 @@
} else {
as_path = strdup(opt + 3);
}
+ } else if (strcmp("emit-llvm", opt) == 0) {
+ generate_bc_file = BC_ONLY;
+ } else if (strcmp("also-emit-llvm", opt) == 0) {
+ generate_bc_file = BC_ALSO;
} else if (llvm::StringRef(opt).startswith("also-emit-llvm=")) {
const char *path = opt + strlen("also-emit-llvm=");
+ generate_bc_file = BC_ALSO;
if (!bc_path.empty()) {
(*message)(LDPL_WARNING, "Path to the output IL file specified twice. "
"Discarding %s", opt);
@@ -122,6 +130,9 @@
case LDPT_GOLD_VERSION: // major * 100 + minor
gold_version = tv->tv_u.tv_val;
break;
+ case LDPT_OUTPUT_NAME:
+ output_name = tv->tv_u.tv_string;
+ break;
case LDPT_LINKER_OUTPUT:
switch (tv->tv_u.tv_val) {
case LDPO_REL: // .o
@@ -381,10 +392,20 @@
}
}
- if (!options::bc_path.empty()) {
- bool err = lto_codegen_write_merged_modules(cg, options::bc_path.c_str());
+
+ if (options::generate_bc_file != options::BC_NO) {
+ std::string path;
+ if (options::generate_bc_file == options::BC_ONLY)
+ path = output_name;
+ else if (!options::bc_path.empty())
+ path = options::bc_path;
+ else
+ path = output_name + ".bc";
+ bool err = lto_codegen_write_merged_modules(cg, path.c_str());
if (err)
(*message)(LDPL_FATAL, "Failed to write the output file.");
+ if (options::generate_bc_file == options::BC_ONLY)
+ exit(0);
}
size_t bufsize = 0;
const char *buffer = static_cast<const char *>(lto_codegen_compile(cg,
More information about the llvm-commits
mailing list