Skip to content

Commit

Permalink
Address reviewer feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
boomanaiden154 committed Jul 1, 2023
1 parent 4346e17 commit 5bf8776
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions compiler_opt/tools/make_corpus.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
PYTHONPATH=$PYTHONPATH:. python3 ./compiler_opt/tools/make_corpus.py \
--input_dir=<path to input directory> \
--output_dir=<path to output direcotry> \
--default_flags="<list of space separated flags>"
--output_dir=<path to output directory> \
--default_args="<list of space separated flags>"
"""

from absl import app
Expand All @@ -32,7 +32,7 @@
flags.DEFINE_string('input_dir', None, 'The input directory.')
flags.DEFINE_string('output_dir', None, 'The output directory.')
flags.DEFINE_string(
'default_flags', '',
'default_args', '',
'The compiler flags to compile with when using downstream tooling.')

flags.mark_flag_as_required('input_dir')
Expand All @@ -50,7 +50,7 @@ def main(_):
make_corpus_lib.copy_bitcode(relative_paths, FLAGS.input_dir,
FLAGS.output_dir)
make_corpus_lib.write_corpus_manifest(relative_paths, FLAGS.output_dir,
FLAGS.default_flags.split())
FLAGS.default_args.split())


if __name__ == '__main__':
Expand Down
14 changes: 7 additions & 7 deletions compiler_opt/tools/make_corpus_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from typing import List, Optional


def load_bitcode_from_directory(bitcode_base_dir: str):
def load_bitcode_from_directory(bitcode_base_dir: str) -> List[str]:
"""Finds bitcode files to extract from a given directory.
Args:
Expand All @@ -41,7 +41,7 @@ def load_bitcode_from_directory(bitcode_base_dir: str):


def copy_bitcode(relative_paths: List[str], bitcode_base_dir: str,
output_dir: str):
output_dir: str) -> None:
"""Copies bitcode files from the base directory to the output directory.
Args:
Expand All @@ -59,19 +59,19 @@ def copy_bitcode(relative_paths: List[str], bitcode_base_dir: str,

def write_corpus_manifest(relative_output_paths: List[str],
output_dir: str,
default_flags: Optional[List[str]] = None):
default_args: Optional[List[str]] = None) -> None:
"""Creates a corpus manifest describing the bitcode that has been found.
Args:
relative_output_paths: A list of paths to each bitcode file relative to the
output directory.
outout_dir: The output directory where the corpus is being created.
default_flags: An array of compiler flags that should be used to compile
default_args: An array of compiler flags that should be used to compile
the bitcode when using further downstream tooling."""
if default_flags is None:
default_flags = []
if default_args is None:
default_args = []
corpus_description = {
'global_command_override': default_flags,
'global_command_override': default_args,
'has_thinlto': False,
'modules': [path for path in relative_output_paths if path is not None]
}
Expand Down
6 changes: 3 additions & 3 deletions compiler_opt/tools/make_corpus_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ def test_copy_bitcode(self):
def test_write_corpus_manifest(self):
relative_output_paths = ['test/test1.bc', 'test/test2.bc']
output_dir = self.create_tempdir()
default_flags = ['-O3', '-c']
default_args = ['-O3', '-c']
make_corpus_lib.write_corpus_manifest(relative_output_paths, output_dir,
default_flags)
default_args)
with open(
os.path.join(output_dir, 'corpus_description.json'),
encoding='utf-8') as corpus_description_file:
corpus_description = json.load(corpus_description_file)
self.assertEqual(corpus_description['global_command_override'],
default_flags)
default_args)
self.assertEqual(corpus_description['has_thinlto'], False)
self.assertEqual(corpus_description['modules'], relative_output_paths)

Expand Down

0 comments on commit 5bf8776

Please sign in to comment.