[llvm] r286564 - [opt-viewer] PEPify opt-viewer.py
Mandeep Singh Grang via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 10 20:51:28 PST 2016
Author: mgrang
Date: Thu Nov 10 22:51:27 2016
New Revision: 286564
URL: http://llvm.org/viewvc/llvm-project?rev=286564&view=rev
Log:
[opt-viewer] PEPify opt-viewer.py
Reviewers: anemet
Subscribers: fhahn
Differential Revision: https://reviews.llvm.org/D26535
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=286564&r1=286563&r2=286564&view=diff
==============================================================================
--- llvm/trunk/utils/opt-viewer/opt-viewer.py (original)
+++ llvm/trunk/utils/opt-viewer/opt-viewer.py Thu Nov 10 22:51:27 2016
@@ -24,10 +24,13 @@ parser.add_argument('-source-dir', '-s',
args = parser.parse_args()
p = subprocess.Popen(['c++filt', '-n'], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+
+
def demangle(name):
p.stdin.write(name + '\n')
return p.stdout.readline().rstrip()
+
class Remark(yaml.YAMLObject):
max_hotness = 1
# Map function names to their source location for function where inlining happened
@@ -93,29 +96,38 @@ class Remark(yaml.YAMLObject):
def key(self):
return (self.__class__, self.Pass, self.Name, self.File, self.Line, self.Column, self.message)
+
class Analysis(Remark):
yaml_tag = '!Analysis'
@property
- def color(self): return "white"
+ def color(self):
+ return "white"
+
class AnalysisFPCommute(Analysis):
yaml_tag = '!AnalysisFPCommute'
+
class AnalysisAliasing(Analysis):
yaml_tag = '!AnalysisAliasing'
+
class Passed(Remark):
yaml_tag = '!Passed'
@property
- def color(self): return "green"
+ def color(self):
+ return "green"
+
class Missed(Remark):
yaml_tag = '!Missed'
@property
- def color(self): return "red"
+ def color(self):
+ return "red"
+
class SourceFileRenderer:
def __init__(self, filename):
@@ -203,6 +215,7 @@ class SourceFileRenderer:
def html_file_name(cls, filename):
return filename.replace('/', '_') + ".html"
+
class IndexRenderer:
def __init__(self):
self.stream = open(os.path.join(args.output_dir, 'index.html'), 'w')
@@ -240,7 +253,7 @@ class IndexRenderer:
all_remarks = dict()
-file_remarks = dict()
+file_remarks = dict()
for input_file in args.yaml_files:
f = open(input_file)
@@ -252,7 +265,7 @@ for input_file in args.yaml_files:
continue
all_remarks[remark.key] = remark
- file_remarks.setdefault(remark.File, dict()).setdefault(remark.Line, []).append(remark);
+ file_remarks.setdefault(remark.File, dict()).setdefault(remark.Line, []).append(remark)
Remark.max_hotness = max(Remark.max_hotness, remark.Hotness)
More information about the llvm-commits
mailing list