From f6678324069cd253b8e7cd560961a07924516738 Mon Sep 17 00:00:00 2001 From: Aiden Grossman Date: Mon, 8 Jul 2024 23:16:48 +0000 Subject: [PATCH] Use module command line --- compiler_opt/rl/trace_data_collector.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/compiler_opt/rl/trace_data_collector.py b/compiler_opt/rl/trace_data_collector.py index 675a5018..c2614a26 100644 --- a/compiler_opt/rl/trace_data_collector.py +++ b/compiler_opt/rl/trace_data_collector.py @@ -19,6 +19,7 @@ import subprocess import json import pathlib +import shutil def compile_corpus(corpus_path, output_path, clang_path): @@ -33,14 +34,20 @@ def compile_corpus(corpus_path, output_path, clang_path): module_full_output_path = os.path.join(output_path, module_path) + '.bc.o' pathlib.Path(os.path.dirname(module_full_output_path)).mkdir( parents=True, exist_ok=True) + + module_command_full_path = os.path.join(corpus_path, module_path) + '.cmd' + with open(module_command_full_path) as module_command_handle: + module_command_line = tuple(module_command_handle.read().replace(r'{', r'{{').replace(r'}', + r'}}').split('\0')) command_vector = [ - clang_path, module_full_input_path, '-o', module_full_output_path, - '-fbasic-block-address-map', '-mllvm', - '-pgo-analysis-map=bb-freq,br-prob', '-O3', '-c' - ] + clang_path] + command_vector.extend(module_command_line) + command_vector.extend([module_full_input_path, '-o', module_full_output_path]) subprocess.run(command_vector) logging.info( f'Just finished compiling {module_full_output_path} ({module_index + 1}/{len(corpus_description["modules"])})' ) + + shutil.copy(os.path.join(corpus_path, 'corpus_description.json'), os.path.join(output_path, 'corpus_description.json'))