Skip to content

Commit

Permalink
Use module command line
Browse files Browse the repository at this point in the history
  • Loading branch information
boomanaiden154 committed Jul 8, 2024
1 parent 19c1e6f commit f667832
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions compiler_opt/rl/trace_data_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import subprocess
import json
import pathlib
import shutil


def compile_corpus(corpus_path, output_path, clang_path):
Expand All @@ -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'))

0 comments on commit f667832

Please sign in to comment.