[PATCH] D35534: [opt-viewer] Reduce memory consumption
Adam Nemet via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 19 15:07:36 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL308536: [opt-viewer] Reduce memory consumption (authored by anemet).
Changed prior to commit:
https://reviews.llvm.org/D35534?vs=107028&id=107396#toc
Repository:
rL LLVM
https://reviews.llvm.org/D35534
Files:
llvm/trunk/tools/opt-viewer/optrecord.py
Index: llvm/trunk/tools/opt-viewer/optrecord.py
===================================================================
--- llvm/trunk/tools/opt-viewer/optrecord.py
+++ llvm/trunk/tools/opt-viewer/optrecord.py
@@ -60,11 +60,34 @@
# Work-around for http://pyyaml.org/ticket/154.
yaml_loader = Loader
- def initmissing(self):
+ def _intern_strings(self):
+ self.Pass = intern(self.Pass)
+ self.Name = intern(self.Name)
+ self.Function = intern(self.Function)
+
+ # Intern key and value if string and recurse if value is a dictionary.
+ # This handles [{'Caller': ..., 'DebugLoc': { 'File': ... }}]
+ def _intern_dict(old_dict):
+ new_dict = dict()
+ for (k, v) in old_dict.iteritems():
+ if type(k) is str:
+ k = intern(k)
+
+ if type(v) is str:
+ v = intern(v)
+ elif type(v) is dict:
+ v = _intern_dict(v)
+ new_dict[k] = v
+ return new_dict
+
+ self.Args = [_intern_dict(arg_dict) for arg_dict in self.Args]
+
+ def canonicalize(self):
if not hasattr(self, 'Hotness'):
self.Hotness = 0
if not hasattr(self, 'Args'):
self.Args = []
+ self._intern_strings()
@property
def File(self):
@@ -193,7 +216,7 @@
with open(input_file) as f:
docs = yaml.load_all(f, Loader=Loader)
for remark in docs:
- remark.initmissing()
+ remark.canonicalize()
# Avoid remarks withoug debug location or if they are duplicated
if not hasattr(remark, 'DebugLoc') or remark.key in all_remarks:
continue
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35534.107396.patch
Type: text/x-patch
Size: 1743 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170719/ad29e605/attachment.bin>
More information about the llvm-commits
mailing list