mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-01 15:40:53 +00:00
[opt-viewer] Make it work in the absence of hotness information
In this case the index page is sorted by the source location. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286572 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
36197284a5
commit
29e1623323
@ -32,10 +32,23 @@ def demangle(name):
|
||||
|
||||
|
||||
class Remark(yaml.YAMLObject):
|
||||
max_hotness = 1
|
||||
max_hotness = 0
|
||||
|
||||
@classmethod
|
||||
def should_display_hotness(cls):
|
||||
# If max_hotness is 0 at the end, we assume hotness information is
|
||||
# missing and no relative hotness information is displayed
|
||||
return cls.max_hotness != 0
|
||||
|
||||
# Map function names to their source location for function where inlining happened
|
||||
caller_loc = dict()
|
||||
|
||||
def __getattr__(self, name):
|
||||
# If hotness is missing, assume 0
|
||||
if name == 'Hotness':
|
||||
return 0
|
||||
raise AttributeError
|
||||
|
||||
@property
|
||||
def File(self):
|
||||
return self.DebugLoc['File']
|
||||
@ -90,7 +103,10 @@ class Remark(yaml.YAMLObject):
|
||||
|
||||
@property
|
||||
def RelativeHotness(self):
|
||||
return int(round(self.Hotness * 100 / Remark.max_hotness))
|
||||
if Remark.should_display_hotness():
|
||||
return "{}%".format(int(round(self.Hotness * 100 / Remark.max_hotness)))
|
||||
else:
|
||||
return ''
|
||||
|
||||
@property
|
||||
def key(self):
|
||||
@ -177,7 +193,7 @@ class SourceFileRenderer:
|
||||
print('''
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>{r.RelativeHotness}%</td>
|
||||
<td>{r.RelativeHotness}</td>
|
||||
<td class=\"column-entry-{r.color}\">{r.Pass}</td>
|
||||
<td><pre style="display:inline">{indent}</pre><span class=\"column-entry-yellow\"> {r.message} </span></td>
|
||||
<td class=\"column-entry-yellow\">{inlining_context}</td>
|
||||
@ -224,7 +240,7 @@ class IndexRenderer:
|
||||
print('''
|
||||
<tr>
|
||||
<td><a href={r.Link}>{r.DebugLocString}</a></td>
|
||||
<td>{r.RelativeHotness}%</td>
|
||||
<td>{r.RelativeHotness}</td>
|
||||
<td>{r.DemangledFunctionName}</td>
|
||||
<td class=\"column-entry-{r.color}\">{r.Pass}</td>
|
||||
</tr>'''.format(**locals()), file=self.stream)
|
||||
@ -259,15 +275,14 @@ for input_file in args.yaml_files:
|
||||
f = open(input_file)
|
||||
docs = yaml.load_all(f)
|
||||
for remark in docs:
|
||||
if hasattr(remark, 'Hotness'):
|
||||
# Avoid duplicated remarks
|
||||
if remark.key in all_remarks:
|
||||
continue
|
||||
all_remarks[remark.key] = remark
|
||||
# Avoid duplicated remarks
|
||||
if remark.key in all_remarks:
|
||||
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)
|
||||
Remark.max_hotness = max(Remark.max_hotness, remark.Hotness)
|
||||
|
||||
# Set up a map between function names and their source location for function where inlining happened
|
||||
for remark in all_remarks.itervalues():
|
||||
@ -277,7 +292,10 @@ for remark in all_remarks.itervalues():
|
||||
if caller:
|
||||
Remark.caller_loc[caller] = arg['DebugLoc']
|
||||
|
||||
sorted_remarks = sorted(all_remarks.itervalues(), key=lambda r: r.Hotness, reverse=True)
|
||||
if Remark.should_display_hotness():
|
||||
sorted_remarks = sorted(all_remarks.itervalues(), key=lambda r: r.Hotness, reverse=True)
|
||||
else:
|
||||
sorted_remarks = sorted(all_remarks.itervalues(), key=lambda r: (r.File, r.Line, r.Column))
|
||||
|
||||
if not os.path.exists(args.output_dir):
|
||||
os.mkdir(args.output_dir)
|
||||
|
Loading…
Reference in New Issue
Block a user