Index: utils/opt-viewer/opt-stats.py =================================================================== --- utils/opt-viewer/opt-stats.py +++ utils/opt-viewer/opt-stats.py @@ -34,7 +34,7 @@ bypass = defaultdict(int) byname = defaultdict(int) - for r in all_remarks.itervalues(): + for r in optrecord.itervalues(all_remarks): bypass[r.Pass] += 1 byname[r.Pass + "/" + r.Name] += 1 Index: utils/opt-viewer/optrecord.py =================================================================== --- utils/opt-viewer/optrecord.py +++ utils/opt-viewer/optrecord.py @@ -24,14 +24,32 @@ p_lock = Lock() +try: + dict.iteritems +except AttributeError: + # Python 3 + def itervalues(d): + return iter(d.values()) + def iteritems(d): + return iter(d.items()) +else: + # Python 2 + def itervalues(d): + return d.itervalues() + def iteritems(d): + return d.iteritems() + + def demangle(name): with p_lock: p.stdin.write(name + '\n') return p.stdout.readline().rstrip() + def html_file_name(filename): return filename.replace('/', '_') + ".html" + def make_link(File, Line): return "\"{}#L{}\"".format(html_file_name(File), Line) @@ -117,7 +135,7 @@ def key(self): k = (self.__class__, self.PassWithDiffPrefix, self.Name, self.File, self.Line, self.Column, self.Function) for arg in self.Args: - for (key, value) in arg.iteritems(): + for (key, value) in iteritems(arg): if type(value) is dict: value = tuple(value.items()) k += (key, value) @@ -196,8 +214,8 @@ max_hotness = max(entry[0] for entry in remarks) def merge_file_remarks(file_remarks_job, all_remarks, merged): - for filename, d in file_remarks_job.iteritems(): - for line, remarks in d.iteritems(): + for filename, d in iteritems(file_remarks_job): + for line, remarks in iteritems(d): for remark in remarks: # Bring max_hotness into the remarks so that # RelativeHotness does not depend on an external global.