Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add logging verbosity level flag to extract_ir.py #278

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions compiler_opt/tools/extract_ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
In a local ThinLTO case, the compilation is assumedto have been performed
specifying -Wl,--save-temps=import -Wl,--thinlto-emit-index-files
To change the logging verbosity, pass an integer representing the desired
verbosity to the --verbosity flag. Use 0 for all logs, status information,
and detailed debug information, -1 for solely warnings, and -2 to not produce
any output.
"""

import json
Expand Down
11 changes: 7 additions & 4 deletions compiler_opt/tools/extract_ir_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,10 @@ def _extract_clang_artifacts(self, llvm_objcopy_path: str, cmd_filter: str,
return None
os.makedirs(self.dest_dir(), exist_ok=True)
try:
subprocess.run(
subprocess.check_output(
self._get_extraction_cmd_command(llvm_objcopy_path, cmd_section_name),
check=True)
stderr=subprocess.STDOUT,
encoding='utf-8')
if cmd_filter is not None or is_thinlto:
with open(self.cmd_file(), encoding='utf-8') as f:
lines = f.readlines()
Expand All @@ -153,13 +154,15 @@ def _extract_clang_artifacts(self, llvm_objcopy_path: str, cmd_filter: str,
index_file = get_thinlto_index(cmdline, self.obj_base_dir())
shutil.copy(index_file, self.thinlto_index_file())

subprocess.run(
subprocess.check_output(
self._get_extraction_bc_command(llvm_objcopy_path,
bitcode_section_name),
check=True)
stderr=subprocess.STDOUT,
encoding='utf-8')
except subprocess.CalledProcessError as e:
# This may happen if .o file was build from asm (.S source).
logging.warning('%s was not processed: %s', self.input_obj(), e)
logging.info(e.output)
return None
assert (os.path.exists(self.cmd_file()) and
os.path.exists(self.bc_file()) and
Expand Down