forked from OSchip/llvm-project
[LTO] Move DisableVerify setting to LTOCodeGenerator class (NFC).
To simplify the transition to using LTOBackend, move DisableVerify to the LTOCodeGenerator class, like most/all other options. Reviewed By: tejohnson Differential Revision: https://reviews.llvm.org/D95223
This commit is contained in:
parent
77adbe6a8c
commit
f959d8195d
|
@ -145,7 +145,7 @@ struct LTOCodeGenerator {
|
|||
/// \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
|
||||
|
@ -153,12 +153,12 @@ struct LTOCodeGenerator {
|
|||
/// 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
|
||||
|
@ -178,6 +178,8 @@ struct LTOCodeGenerator {
|
|||
/// 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; }
|
||||
|
@ -239,6 +241,7 @@ private:
|
|||
std::unique_ptr<ToolOutputFile> DiagnosticOutputFile;
|
||||
bool Freestanding = false;
|
||||
std::unique_ptr<ToolOutputFile> StatsFile = nullptr;
|
||||
bool DisableVerify = false;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -326,15 +326,15 @@ LTOCodeGenerator::compileOptimized() {
|
|||
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();
|
||||
|
@ -527,7 +527,7 @@ void LTOCodeGenerator::finishOptimizationRemarks() {
|
|||
}
|
||||
|
||||
/// Optimize merged modules using various IPO passes
|
||||
bool LTOCodeGenerator::optimize(bool DisableVerify) {
|
||||
bool LTOCodeGenerator::optimize() {
|
||||
if (!this->determineTarget())
|
||||
return false;
|
||||
|
||||
|
|
|
@ -953,6 +953,7 @@ int main(int argc, char **argv) {
|
|||
true);
|
||||
|
||||
LTOCodeGenerator CodeGen(Context);
|
||||
CodeGen.setDisableVerify(DisableVerify);
|
||||
|
||||
if (UseDiagnosticHandler)
|
||||
CodeGen.setDiagnosticHandler(handleDiagnostics, nullptr);
|
||||
|
@ -1026,7 +1027,7 @@ int main(int argc, char **argv) {
|
|||
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");
|
||||
}
|
||||
|
@ -1067,7 +1068,7 @@ int main(int argc, char **argv) {
|
|||
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.
|
||||
|
||||
|
|
|
@ -152,6 +152,7 @@ static void lto_add_attrs(lto_code_gen_t cg) {
|
|||
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() {
|
||||
|
@ -432,7 +433,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) {
|
||||
maybeParseOptions(cg);
|
||||
LibLTOCodeGenerator *CG = unwrap(cg);
|
||||
CG->NativeObjectFile = CG->compile(DisableVerify);
|
||||
CG->NativeObjectFile = CG->compile();
|
||||
if (!CG->NativeObjectFile)
|
||||
return nullptr;
|
||||
*length = CG->NativeObjectFile->getBufferSize();
|
||||
|
@ -441,7 +442,7 @@ const void *lto_codegen_compile(lto_code_gen_t cg, size_t *length) {
|
|||
|
||||
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) {
|
||||
|
@ -456,7 +457,7 @@ 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) {
|
||||
|
|
Loading…
Reference in New Issue