52
52
#include " xls/jit/function_base_jit.h"
53
53
#include " xls/jit/function_jit.h"
54
54
#include " xls/jit/jit_proc_runtime.h"
55
+ #include " xls/jit/llvm_compiler.h"
55
56
#include " xls/jit/llvm_type_converter.h"
56
57
#include " xls/jit/observer.h"
57
58
#include " xls/jit/type_layout.pb.h"
@@ -75,6 +76,9 @@ ABSL_FLAG(std::optional<std::string>, output_llvm_opt_ir, std::nullopt,
75
76
" Path at which to write the output optimized llvm file." );
76
77
ABSL_FLAG (std::optional<std::string>, output_asm, std::nullopt,
77
78
" Path at which to write the output optimized llvm file." );
79
+ ABSL_FLAG (int64_t , llvm_opt_level, xls::LlvmCompiler::kDefaultOptLevel ,
80
+ " The optimization level to use for the LLVM optimizer." );
81
+
78
82
#ifdef ABSL_HAVE_MEMORY_SANITIZER
79
83
static constexpr bool kHasMsan = true ;
80
84
#else
@@ -227,7 +231,7 @@ absl::Status RealMain(const std::string& input_ir_path,
227
231
const std::optional<std::string>& top,
228
232
const std::optional<std::string>& output_object_path,
229
233
const std::optional<std::string>& output_proto_path,
230
- bool include_msan,
234
+ bool include_msan, int64_t llvm_opt_level,
231
235
const std::optional<std::string>& output_textproto_path,
232
236
const std::optional<std::string>& output_llvm_ir_path,
233
237
const std::optional<std::string>& output_llvm_opt_ir_path,
@@ -258,26 +262,26 @@ absl::Status RealMain(const std::string& input_ir_path,
258
262
259
263
std::optional<JitObjectCode> object_code;
260
264
if (f->IsFunction ()) {
261
- XLS_ASSIGN_OR_RETURN (
262
- object_code,
263
- FunctionJit::CreateObjectCode (f->AsFunctionOrDie (),
264
- /* opt_level = */ 3 , include_msan, &obs));
265
+ XLS_ASSIGN_OR_RETURN (object_code, FunctionJit::CreateObjectCode (
266
+ f->AsFunctionOrDie (), llvm_opt_level,
267
+ include_msan, &obs));
265
268
} else if (f->IsProc ()) {
266
269
if (f->AsProcOrDie ()->is_new_style_proc ()) {
267
270
XLS_ASSIGN_OR_RETURN (
268
- object_code,
269
- CreateProcAotObjectCode (f-> AsProcOrDie (), include_msan, &obs));
271
+ object_code, CreateProcAotObjectCode (f-> AsProcOrDie (), llvm_opt_level,
272
+ include_msan, &obs));
270
273
} else {
271
274
// all procs
272
- XLS_ASSIGN_OR_RETURN (object_code, CreateProcAotObjectCode (
273
- package.get (), include_msan, &obs));
275
+ XLS_ASSIGN_OR_RETURN (
276
+ object_code, CreateProcAotObjectCode (package.get (), llvm_opt_level,
277
+ include_msan, &obs));
274
278
}
275
279
} else {
276
280
XLS_ASSIGN_OR_RETURN (BlockElaboration elab,
277
281
BlockElaboration::Elaborate (f->AsBlockOrDie ()));
278
282
XLS_ASSIGN_OR_RETURN (
279
283
object_code,
280
- BlockJit::CreateObjectCode (elab, /* opt_level= */ 3 , include_msan, &obs));
284
+ BlockJit::CreateObjectCode (elab, llvm_opt_level , include_msan, &obs));
281
285
}
282
286
AotPackageEntrypointsProto all_entrypoints;
283
287
if (output_object_path) {
@@ -340,6 +344,7 @@ int main(int argc, char** argv) {
340
344
bool include_msan = absl::GetFlag (FLAGS_include_msan);
341
345
absl::Status status = xls::RealMain (
342
346
input_ir_path, top, output_object_path, output_proto_path, include_msan,
347
+ absl::GetFlag (FLAGS_llvm_opt_level),
343
348
absl::GetFlag (FLAGS_output_textproto),
344
349
absl::GetFlag (FLAGS_output_llvm_ir),
345
350
absl::GetFlag (FLAGS_output_llvm_opt_ir), absl::GetFlag (FLAGS_output_asm));
0 commit comments