summaryrefslogtreecommitdiffstats
path: root/llvm/utils/opt-viewer/opt-viewer.py
diff options
context:
space:
mode:
authorAdam Nemet <anemet@apple.com>2016-11-11 01:25:04 +0000
committerAdam Nemet <anemet@apple.com>2016-11-11 01:25:04 +0000
commit5bf012baba4edb844664958dcd0209896ef61bb2 (patch)
tree81d14f31c296f307125e2bafb7cbec1b903093eb /llvm/utils/opt-viewer/opt-viewer.py
parent01823ea2de56227f90f0471b478acd46fe496b9b (diff)
downloadbcm5719-llvm-5bf012baba4edb844664958dcd0209896ef61bb2.tar.gz
bcm5719-llvm-5bf012baba4edb844664958dcd0209896ef61bb2.zip
[opt-viewer] Display inlining context
When a function is inlined, each instance is optimized in their own inlining context. This can produce different remarks all pointing to the same source line. This adds a new column on the source view to display the inlining context. llvm-svn: 286537
Diffstat (limited to 'llvm/utils/opt-viewer/opt-viewer.py')
-rwxr-xr-xllvm/utils/opt-viewer/opt-viewer.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/utils/opt-viewer/opt-viewer.py b/llvm/utils/opt-viewer/opt-viewer.py
index 5c23ba1d265..510302b0c22 100755
--- a/llvm/utils/opt-viewer/opt-viewer.py
+++ b/llvm/utils/opt-viewer/opt-viewer.py
@@ -29,6 +29,8 @@ def demangle(name):
class Remark(yaml.YAMLObject):
max_hotness = 1
+ # Map function names to their source location for function where inlining happened
+ caller_loc = dict()
@property
def File(self):
@@ -149,12 +151,19 @@ class SourceFileRenderer:
</tr>'''.format(**locals()), file=self.stream)
def render_inline_remarks(self, r):
+ inlining_context = r.DemangledFunctionName
+ dl = Remark.caller_loc.get(r.Function)
+ if dl:
+ link = Remark.make_link(dl['File'], dl['Line'] - 2)
+ inlining_context = "<a href={link}>{r.DemangledFunctionName}</a>".format(**locals())
+
print('''
<tr>
<td></td>
<td>{r.RelativeHotness}%</td>
<td class=\"column-entry-{r.color}\">{r.Pass}</td>
<td class=\"column-entry-yellow\">{r.message}</td>
+<td class=\"column-entry-yellow\">{inlining_context}</td>
</tr>'''.format(**locals()), file=self.stream)
def render(self, line_remarks):
@@ -174,6 +183,7 @@ class SourceFileRenderer:
<td>Hotness</td>
<td>Optimization</td>
<td>Source</td>
+<td>Inline Context</td>
</tr>''', file=self.stream)
for (linenum, line) in enumerate(self.source_stream.readlines(), start=1):
self.render_source_line(linenum, line)
@@ -241,6 +251,14 @@ for input_file in args.yaml_files:
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():
+ if type(remark) == Passed and remark.Pass == "inline" and remark.Name == "Inlined":
+ for arg in remark.Args:
+ caller = arg.get('Caller')
+ if caller:
+ Remark.caller_loc[caller] = arg['DebugLoc']
+
sorted_remarks = sorted(all_remarks.itervalues(), key=lambda r: r.Hotness, reverse=True)
if not os.path.exists(args.output_dir):
OpenPOWER on IntegriCloud