Skip to content

Commit

Permalink
[opt-viewer] Make filter_=None by default in get_remarks and gather_r…
Browse files Browse the repository at this point in the history
…esults

Right now, if you try to use optdiff.py on any opt records, it will fail because
its calls to gather_results weren't updated to support filtering.

Since filters are supposed to be optional, this makes them None by default in
get_remarks and in gather_results. This allows other tools that don't support
filtering to still use the functions as is.

Differential Revision: https://reviews.llvm.org/D59894

llvm-svn: 357106
  • Loading branch information
Jessica Paquette committed Mar 27, 2019
1 parent 2e9ddcc commit beda859
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions llvm/tools/opt-viewer/optrecord.py
Expand Up @@ -265,22 +265,24 @@ def color(self):
return "red"


def get_remarks(input_file, filter_):
def get_remarks(input_file, filter_=None):
max_hotness = 0
all_remarks = dict()
file_remarks = defaultdict(functools.partial(defaultdict, list))

with open(input_file) as f:
docs = yaml.load_all(f, Loader=Loader)

filter_e = re.compile(filter_)
filter_e = None
if filter_:
filter_e = re.compile(filter_)
for remark in docs:
remark.canonicalize()
# Avoid remarks withoug debug location or if they are duplicated
if not hasattr(remark, 'DebugLoc') or remark.key in all_remarks:
continue

if filter_ and not filter_e.search(remark.Pass):
if filter_e and not filter_e.search(remark.Pass):
continue

all_remarks[remark.key] = remark
Expand All @@ -297,7 +299,7 @@ def get_remarks(input_file, filter_):
return max_hotness, all_remarks, file_remarks


def gather_results(filenames, num_jobs, should_print_progress, filter_):
def gather_results(filenames, num_jobs, should_print_progress, filter_=None):
if should_print_progress:
print('Reading YAML files...')
if not Remark.demangler_proc:
Expand Down

0 comments on commit beda859

Please sign in to comment.