/// \note It is up to the linker to remove the intermediate output file. Do
/// not try to remove the object file in LTOCodeGenerator's destructor as we
/// don't who (LTOCodeGenerator or the output file) will last longer.
- bool compile_to_file(const char **Name, bool DisableVerify);
+ bool compile_to_file(const char **Name);
/// As with compile_to_file(), this function compiles the merged module into
/// single output file. Instead of returning the output file path to the
/// to the caller. This function should delete the intermediate file once
/// its content is brought to memory. Return NULL if the compilation was not
/// successful.
- std::unique_ptr<MemoryBuffer> compile(bool DisableVerify);
+ std::unique_ptr<MemoryBuffer> compile();
/// Optimizes the merged module. Returns true on success.
///
/// Calls \a verifyMergedModuleOnce().
- bool optimize(bool DisableVerify);
+ bool optimize();
/// Compiles the merged optimized module into a single output file. It brings
/// the output to a buffer, and returns the buffer to the caller. Return NULL
/// assume builtins are present on the target.
void setFreestanding(bool Enabled) { Freestanding = Enabled; }
+ void setDisableVerify(bool Value) { DisableVerify = Value; }
+
void setDiagnosticHandler(lto_diagnostic_handler_t, void *);
LLVMContext &getContext() { return Context; }
std::unique_ptr<ToolOutputFile> DiagnosticOutputFile;
bool Freestanding = false;
std::unique_ptr<ToolOutputFile> StatsFile = nullptr;
+ bool DisableVerify = false;
};
}
#endif
return std::move(*BufferOrErr);
}
-bool LTOCodeGenerator::compile_to_file(const char **Name, bool DisableVerify) {
- if (!optimize(DisableVerify))
+bool LTOCodeGenerator::compile_to_file(const char **Name) {
+ if (!optimize())
return false;
return compileOptimizedToFile(Name);
}
-std::unique_ptr<MemoryBuffer> LTOCodeGenerator::compile(bool DisableVerify) {
- if (!optimize(DisableVerify))
+std::unique_ptr<MemoryBuffer> LTOCodeGenerator::compile() {
+ if (!optimize())
return nullptr;
return compileOptimized();
}
/// Optimize merged modules using various IPO passes
-bool LTOCodeGenerator::optimize(bool DisableVerify) {
+bool LTOCodeGenerator::optimize() {
if (!this->determineTarget())
return false;
true);
LTOCodeGenerator CodeGen(Context);
+ CodeGen.setDisableVerify(DisableVerify);
if (UseDiagnosticHandler)
CodeGen.setDiagnosticHandler(handleDiagnostics, nullptr);
error("writing linked module failed.");
}
- if (!CodeGen.optimize(DisableVerify)) {
+ if (!CodeGen.optimize()) {
// Diagnostic messages should have been printed by the handler.
error("error optimizing the code");
}
error(": -save-merged-module must be specified with -o");
const char *OutputName = nullptr;
- if (!CodeGen.compile_to_file(&OutputName, DisableVerify))
+ if (!CodeGen.compile_to_file(&OutputName))
error("error compiling the code");
// Diagnostic messages should have been printed by the handler.
report_fatal_error("Optimization level must be between 0 and 3");
CG->setOptLevel(OptLevel - '0');
CG->setFreestanding(EnableFreestanding);
+ CG->setDisableVerify(DisableVerify);
}
extern const char* lto_get_version() {
const void *lto_codegen_compile(lto_code_gen_t cg, size_t *length) {
maybeParseOptions(cg);
LibLTOCodeGenerator *CG = unwrap(cg);
- CG->NativeObjectFile = CG->compile(DisableVerify);
+ CG->NativeObjectFile = CG->compile();
if (!CG->NativeObjectFile)
return nullptr;
*length = CG->NativeObjectFile->getBufferSize();
bool lto_codegen_optimize(lto_code_gen_t cg) {
maybeParseOptions(cg);
- return !unwrap(cg)->optimize(DisableVerify);
+ return !unwrap(cg)->optimize();
}
const void *lto_codegen_compile_optimized(lto_code_gen_t cg, size_t *length) {
bool lto_codegen_compile_to_file(lto_code_gen_t cg, const char **name) {
maybeParseOptions(cg);
- return !unwrap(cg)->compile_to_file(name, DisableVerify);
+ return !unwrap(cg)->compile_to_file(name);
}
void lto_codegen_debug_options(lto_code_gen_t cg, const char *opt) {