[PATCH] D53142: [VPlan] Script to extract VPlan digraphs from log

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 11 09:50:22 PDT 2018


fhahn added a comment.

Great, I think we should definitely make it easier to visualize the vplans. I left a few python comments with suggestions, but they are mostly personal preference. I think in the future we may want something like a `-dump-vplans` flag, to conveniently dump plans as they are transformed.



================
Comment at: utils/extract_vplan.py:24
+CurVPlan = ''
+for line in sys.stdin:
+    if not CurVPlan and re.match("digraph VPlan {", line):
----------------
My python regex knowledge is a bit rusty, but I think it might be possible to simplify this a bit by having a multi line regex, something like `pattern = re.compile(r"(digraph VPlan {.*})",re.DOTALL)`

I am curious now and will give that a try.




================
Comment at: utils/extract_vplan.py:43
+
+for i in range(len(VPlans)):
+    if args.png:
----------------
could this be something like `for (name, plan) in zip(Names, VPlans):`?


================
Comment at: utils/extract_vplan.py:56
+        print("No visualisation requested, saving to file: " + filename)
+        out = open(filename, 'w')
+        out.write(VPlans[i])
----------------
could be `with open(filename, 'w') as out: out.write(VPlans[i])`


https://reviews.llvm.org/D53142





More information about the llvm-commits mailing list