From 74cb51761022a926fdbfbb470a93baa413cb8682 Mon Sep 17 00:00:00 2001 From: oflatt Date: Thu, 14 Nov 2024 14:04:21 -0800 Subject: [PATCH] fix up llvm output file --- .../passing/bril/long/function_call.bril | 3 --- infra/nightly-resources/data.js | 2 +- infra/nightly-resources/llvm.js | 2 +- infra/profile.py | 6 +++-- src/main.rs | 6 ++--- src/util.rs | 27 +++++-------------- 6 files changed, 16 insertions(+), 30 deletions(-) diff --git a/benchmarks/passing/bril/long/function_call.bril b/benchmarks/passing/bril/long/function_call.bril index 8a06b98ad..33395fa3c 100644 --- a/benchmarks/passing/bril/long/function_call.bril +++ b/benchmarks/passing/bril/long/function_call.bril @@ -1,8 +1,5 @@ # ARGS: 25 -# failing due to brillvm bug: -# https://github.com/sampsyo/bril/issues/339 - @main(starting_m: int) { res: int = call @myrec starting_m; print res; diff --git a/infra/nightly-resources/data.js b/infra/nightly-resources/data.js index 8c92f6f3e..8b209ba75 100644 --- a/infra/nightly-resources/data.js +++ b/infra/nightly-resources/data.js @@ -46,7 +46,7 @@ function shouldHaveLlvm(runMethod) { "llvm-eggcc-O0-O0", "llvm-eggcc-sequential-O0-O0", "llvm-O3-O0", - "llvm-O3-O0", + "llvm-O3-O3", "llvm-eggcc-O3-O0", ].includes(runMethod); } diff --git a/infra/nightly-resources/llvm.js b/infra/nightly-resources/llvm.js index 1022491e2..e06f49e10 100644 --- a/infra/nightly-resources/llvm.js +++ b/infra/nightly-resources/llvm.js @@ -1,6 +1,6 @@ async function showIR(benchmark, runMode) { const llvm = await fetchText( - `./data/llvm/${benchmark}/${runMode}/${benchmark}-${runMode}.ll`, + `./data/llvm/${benchmark}/${runMode}/optimized.ll`, ); document.getElementById("llvm-ir").innerText = llvm; } diff --git a/infra/profile.py b/infra/profile.py index 32048320e..daa700d3f 100755 --- a/infra/profile.py +++ b/infra/profile.py @@ -87,10 +87,12 @@ def optimize(benchmark): # get the commands we need to run (eggcc_run_mode, llvm_args) = get_eggcc_options(benchmark) - llvm_out_dir = f"{DATA_DIR}/llvm/{benchmark.name}/{benchmark.treatment}" + # make the llvm output directory + os.makedirs(f"{DATA_DIR}/llvm/{benchmark.name}/{benchmark.treatment}", exist_ok=True) + llvm_out_file = f"{DATA_DIR}/llvm/{benchmark.name}/{benchmark.treatment}/optimized.ll" cmd1 = f'{EGGCC_BINARY} {benchmark.path} --run-mode {eggcc_run_mode}' - cmd2 = f'{EGGCC_BINARY} {optimized_bril_file} --add-timing {llvm_args} -o {profile_dir}/{benchmark.treatment} --llvm-output-dir {llvm_out_dir}' + cmd2 = f'{EGGCC_BINARY} {optimized_bril_file} --add-timing {llvm_args} -o {profile_dir}/{benchmark.treatment} --llvm-output-dir {llvm_out_file}' print(f'Running c1: {cmd1}', flush=True) start_eggcc = time.time() diff --git a/src/main.rs b/src/main.rs index bc7107ead..ed1c74b3b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -33,9 +33,9 @@ struct Args { /// Where to put the executable (only for the brillift and llvm modes) #[clap(short)] output_path: Option, - /// Where to put intermediary files (only for OptimizeBrilLLVM mode) + /// Where to put the optimized llvm file (for the llvm mode) #[clap(long)] - llvm_output_dir: Option, + llvm_output_dir: Option, /// For the LLVM run mode, choose whether to first run eggcc /// to optimize the bril program before going to LLVM. #[clap(long)] @@ -98,7 +98,7 @@ fn main() { }, profile_out: args.profile_out, output_path: args.output_path, - llvm_output_dir: args.llvm_output_dir, + optimized_llvm_out: args.llvm_output_dir, optimize_egglog: args.optimize_egglog, optimize_brilift: args.optimize_brilift, optimize_bril_llvm: args.optimize_bril_llvm, diff --git a/src/util.rs b/src/util.rs index 424b6ef9e..04a5940b5 100644 --- a/src/util.rs +++ b/src/util.rs @@ -384,7 +384,7 @@ pub struct Run { pub test_type: RunMode, pub interp: InterpMode, pub profile_out: Option, - pub llvm_output_dir: Option, + pub optimized_llvm_out: Option, pub output_path: Option, pub optimize_egglog: Option, pub optimize_brilift: Option, @@ -401,7 +401,7 @@ impl Run { interp: InterpMode::None, profile_out: None, output_path: None, - llvm_output_dir: None, + optimized_llvm_out: None, optimize_egglog: None, optimize_brilift: None, optimize_bril_llvm: None, @@ -472,7 +472,7 @@ impl Run { prog_with_args: test.read_program(), profile_out: None, output_path: None, - llvm_output_dir: None, + optimized_llvm_out: None, optimize_egglog: None, optimize_brilift: Some(optimize_brilift), optimize_bril_llvm: None, @@ -489,7 +489,7 @@ impl Run { prog_with_args: test.read_program(), profile_out: None, output_path: None, - llvm_output_dir: None, + optimized_llvm_out: None, // no need to set optimization flags, since all combinations are tested optimize_egglog: None, optimize_brilift: None, @@ -549,7 +549,7 @@ impl Run { prog_with_args: prog.clone(), profile_out: None, output_path: None, - llvm_output_dir: None, + optimized_llvm_out: None, optimize_egglog: Some(optimize_egglog), optimize_brilift: None, optimize_bril_llvm: Some(optimize_llvm), @@ -1070,17 +1070,6 @@ impl Run { .clone() .unwrap_or_else(|| format!("/tmp/{}", unique_name)); - // Copy init file to $output_dir - if let Some(output_dir) = &self.llvm_output_dir { - std::fs::create_dir_all(output_dir) - .unwrap_or_else(|_| panic!("could not create output dir {}", output_dir)); - std::process::Command::new("cp") - .arg(file_path.clone()) - .arg(output_dir) - .status() - .unwrap(); - } - let processed = dir.path().join("postprocessed.ll"); let optimized = dir.path().join("optimized.ll"); // HACK: check if opt-18 exists @@ -1145,12 +1134,10 @@ impl Run { "failed to compile llvm ir", ); - if let Some(output_dir) = &self.llvm_output_dir { + if let Some(output_llvm_file) = &self.optimized_llvm_out { // move optimized.ll to the output dir expect_command_success( - Command::new("mv") - .arg(optimized) - .arg(format!("{}/{}.ll", output_dir, self.name())), + Command::new("mv").arg(optimized).arg(output_llvm_file), "failed to move optimized llvm ir", ); }