ThinLTO("thinlto", cl::init(false),
cl::desc("Only write combined global index for ThinLTO backends"));
+static cl::opt<bool>
+SaveModuleFile("save-merged-module", cl::init(false),
+ cl::desc("Write merged LTO module to file before CodeGen"));
+
static cl::list<std::string>
InputFilenames(cl::Positional, cl::OneOrMore,
cl::desc("<input bitcode files>"));
if (!attrs.empty())
CodeGen.setAttr(attrs.c_str());
+ if (FileType.getNumOccurrences())
+ CodeGen.setFileType(FileType);
+
if (!OutputFilename.empty()) {
if (!CodeGen.optimize(DisableVerify, DisableInline, DisableGVNLoadPRE,
DisableLTOVectorization)) {
return 1;
}
+ if (SaveModuleFile) {
+ std::string ModuleFilename = OutputFilename;
+ ModuleFilename += ".merged.bc";
+ std::string ErrMsg;
+
+ if (!CodeGen.writeMergedModules(ModuleFilename.c_str())) {
+ errs() << argv[0] << ": writing merged module failed.\n";
+ return 1;
+ }
+ }
+
std::list<tool_output_file> OSs;
std::vector<raw_pwrite_stream *> OSPtrs;
for (unsigned I = 0; I != Parallelism; ++I) {
return 1;
}
+ if (SaveModuleFile) {
+ errs() << argv[0] << ": -save-merged-module must be specified with -o\n";
+ return 1;
+ }
+
const char *OutputName = nullptr;
if (!CodeGen.compile_to_file(&OutputName, DisableVerify, DisableInline,
DisableGVNLoadPRE, DisableLTOVectorization)) {