[llvm] r293264 - [opt-viewer] Unique across the different jobs as well

Adam Nemet via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 26 22:39:06 PST 2017


Author: anemet
Date: Fri Jan 27 00:39:06 2017
New Revision: 293264

URL: http://llvm.org/viewvc/llvm-project?rev=293264&view=rev
Log:
[opt-viewer] Unique across the different jobs as well

Modified:
    llvm/trunk/utils/opt-viewer/opt-viewer.py

Modified: llvm/trunk/utils/opt-viewer/opt-viewer.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/opt-viewer/opt-viewer.py?rev=293264&r1=293263&r2=293264&view=diff
==============================================================================
--- llvm/trunk/utils/opt-viewer/opt-viewer.py (original)
+++ llvm/trunk/utils/opt-viewer/opt-viewer.py Fri Jan 27 00:39:06 2017
@@ -308,33 +308,20 @@ def _render_file(source_dir, output_dir,
 
 
 def gather_results(pool, filenames):
-    all_remarks = dict()
     remarks = pool.map(get_remarks, filenames)
 
-    def merge_dicts(dicts):
-        ''' Takes an iterable of dicts and merges them into
-            a single dict.  Nested dicts are merged as well.
-        >>> merge_dicts([ {'a': [3], }, {'a': [4], }, {'b': [6] }])
-        {'a': [3,4,], 'b': [6]}
-        >>> merge_dicts([ {'a': {'q': [6,3], 'f': [30],}, }, {'a': {'f': [4,10]}, }, {'b': [6] }])
-        {'a': [{'q': [6,3]}, {'f': [4,10,30]}], 'b': [6]}
-
-        '''
-        merged = defaultdict(functools.partial(defaultdict, list))
-
-        for k, v in itertools.chain(*[d.iteritems() for d in dicts]):
-            for k_, v_ in v.items():
-                merged[k][k_] += v_
-
-        return merged
-
-    file_remark_dicts = [entry[2] for entry in remarks]
-    # merge the list of remarks at each line of each file
-    file_remarks = merge_dicts(file_remark_dicts)
-
-    # merge individual 'all_remark' results:
-    for _, all_rem, _ in remarks:
-        all_remarks.update(all_rem)
+    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 remark in remarks:
+                    if remark.key not in all_remarks:
+                        merged[filename][line].append(remark)
+
+    all_remarks = dict()
+    file_remarks = defaultdict(functools.partial(defaultdict, list))
+    for _, all_remarks_job, file_remarks_job in remarks:
+        merge_file_remarks(file_remarks_job, all_remarks, file_remarks)
+        all_remarks.update(all_remarks_job)
 
     Remark.max_hotness = max(entry[0] for entry in remarks)
 




More information about the llvm-commits mailing list