[PATCH] D29970: opt-viewer: abbreviate long function names

Brian Cain via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 14 15:41:09 PST 2017


bcain updated this revision to Diff 88460.
bcain added a comment.

Fixed reference to ABBREV_LENGTH_LIMIT


https://reviews.llvm.org/D29970

Files:
  utils/opt-viewer/opt-viewer.py
  utils/opt-viewer/style.css


Index: utils/opt-viewer/style.css
===================================================================
--- utils/opt-viewer/style.css
+++ utils/opt-viewer/style.css
@@ -88,11 +88,9 @@
 }
 .tooltip span.tooltip-content {
   position: absolute;
-  width: 100px;
   margin-left: -50px;
   color: #FFFFFF;
   background: #000000;
-  height: 30px;
   line-height: 30px;
   text-align: center;
   visibility: hidden;
Index: utils/opt-viewer/opt-viewer.py
===================================================================
--- utils/opt-viewer/opt-viewer.py
+++ utils/opt-viewer/opt-viewer.py
@@ -59,6 +59,7 @@
 class Remark(yaml.YAMLObject):
     # Work-around for http://pyyaml.org/ticket/154.
     yaml_loader = Loader
+    ABBREV_LENGTH_LIMIT = 70
 
     def __getattr__(self, name):
         # If hotness is missing, assume 0
@@ -83,6 +84,15 @@
         return "{}:{}:{}".format(self.File, self.Line, self.Column)
 
     @property
+    def AbbreviatedFunctionName(self):
+        demangled = self.DemangledFunctionName
+        if len(demangled) > Remark.ABBREV_LENGTH_LIMIT:
+            return '...' + demangled[-Remark.ABBREV_LENGTH_LIMIT:]
+
+        return demangled
+
+
+    @property
     def DemangledFunctionName(self):
         return demangle(self.Function)
 
@@ -197,12 +207,13 @@
 </tr>'''.format(**locals()), file=self.stream)
 
     def render_inline_remarks(self, r, line):
-        inlining_context = r.DemangledFunctionName
+        func_name = '<div class="tooltip">{r.AbbreviatedFunctionName}<span class="tooltip-content">{r.DemangledFunctionName}</span></div>'.format(**locals())
+        inlining_context = func_name
         print
         dl = context.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())
+            inlining_context = "<a href={link}>{func_name}</a>".format(**locals())
 
         # Column is the number of characters *including* tabs, keep those and
         # replace everything else with spaces.
@@ -256,12 +267,13 @@
         self.stream = open(os.path.join(output_dir, 'index.html'), 'w')
 
     def render_entry(self, r, odd):
-        escaped_name = cgi.escape(r.DemangledFunctionName)
+        escaped_abbrev_name = cgi.escape(r.AbbreviatedFunctionName)
+        escaped_full_name = cgi.escape(r.DemangledFunctionName)
         print('''
 <tr>
 <td class=\"column-entry-{odd}\"><a href={r.Link}>{r.DebugLocString}</a></td>
 <td class=\"column-entry-{odd}\">{r.RelativeHotness}</td>
-<td class=\"column-entry-{odd}\">{escaped_name}</td>
+<td class=\"column-entry-{odd}\"><div class="tooltip">{escaped_abbrev_name}<span class="tooltip-content">{escaped_full_name}</span></div></td>
 <td class=\"column-entry-{r.color}\">{r.Pass}</td>
 </tr>'''.format(**locals()), file=self.stream)
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29970.88460.patch
Type: text/x-patch
Size: 2884 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170214/6734d978/attachment.bin>


More information about the llvm-commits mailing list