From fd7ee479401b069bc14dd7b604fd6e1da31dc95e Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Fri, 25 Jan 2019 17:48:31 +0000 Subject: [PATCH] [opt-viewer] Add javascript to expand/hide full message for multiline remarks. This patch adds support for displaying remarks with multiple lines. For such remarks, it creates a hidden div containing the message's lines except the first one in a
tag. It also prepends a link (with '+' as text) to the regular remark
line. This link can be used to show/hide the div containing the
full remark.

In combination with D57159, this allows for better displaying of
multiline remarks in the html pages generated by opt-viewer.

The Javascript is very simple and should be supported by any recent
major browser.

Reviewers: hfinkel, anemet, thegameg, serge-sans-paille

Reviewed By: anemet

Differential Revision: https://reviews.llvm.org/D57167

llvm-svn: 352223
---
 .../tools/opt-viewer/Inputs/basic/or.yaml     | 11 +++
 .../opt-viewer/Outputs/basic/basic_or.c.html  | 31 +++++++
 .../opt-viewer/Outputs/basic/basic_or.h.html  | 17 ++++
 .../tools/opt-viewer/Outputs/basic/index.html | 87 ++++++++++---------
 .../opt-viewer/Outputs/suppress/s.swift.html  | 17 ++++
 .../unicode-function-name/s.swift.html        | 17 ++++
 llvm/tools/opt-viewer/opt-viewer.py           | 33 ++++++-
 llvm/tools/opt-viewer/style.css               | 10 +++
 8 files changed, 182 insertions(+), 41 deletions(-)

diff --git a/llvm/test/tools/opt-viewer/Inputs/basic/or.yaml b/llvm/test/tools/opt-viewer/Inputs/basic/or.yaml
index 11c5528b43fc..80de83455a53 100644
--- a/llvm/test/tools/opt-viewer/Inputs/basic/or.yaml
+++ b/llvm/test/tools/opt-viewer/Inputs/basic/or.yaml
@@ -225,3 +225,14 @@ Args:
   - InterleaveCount: '2'
   - String:          ')'
 ...
+--- !Passed
+Pass:            multiline
+Name:            ShowMultiLine
+DebugLoc:        { File: basic/or.c, Line: 10, Column: 3 }
+Function:        Test
+Args:
+  - String:   |
+      This is a remark with
+      multiple
+        lines
+...
diff --git a/llvm/test/tools/opt-viewer/Outputs/basic/basic_or.c.html b/llvm/test/tools/opt-viewer/Outputs/basic/basic_or.c.html
index 225ebabdbde3..2b0baf942b50 100644
--- a/llvm/test/tools/opt-viewer/Outputs/basic/basic_or.c.html
+++ b/llvm/test/tools/opt-viewer/Outputs/basic/basic_or.c.html
@@ -4,6 +4,23 @@
 
 
 
+
 
 
 
@@ -105,6 +122,20 @@ Test + + + +multiline +
  
+ This is a remark with  + +Test + + 11 diff --git a/llvm/test/tools/opt-viewer/Outputs/basic/basic_or.h.html b/llvm/test/tools/opt-viewer/Outputs/basic/basic_or.h.html index 7cbda8a66c76..b6cc2f37fab3 100644 --- a/llvm/test/tools/opt-viewer/Outputs/basic/basic_or.h.html +++ b/llvm/test/tools/opt-viewer/Outputs/basic/basic_or.h.html @@ -4,6 +4,23 @@ +
diff --git a/llvm/test/tools/opt-viewer/Outputs/basic/index.html b/llvm/test/tools/opt-viewer/Outputs/basic/index.html index 3424a9a1f0e6..9bdacd264157 100644 --- a/llvm/test/tools/opt-viewer/Outputs/basic/index.html +++ b/llvm/test/tools/opt-viewer/Outputs/basic/index.html @@ -29,121 +29,128 @@ -basic/or.c:14:3 +basic/or.c:10:3 Test -loop-unroll +multiline -basic/or.c:18:3 +basic/or.c:14:3 Test -inline +loop-unroll basic/or.c:18:3 Test -inline +inline -basic/or.c:20:3 +basic/or.c:18:3 Test -inline +inline basic/or.c:20:3 Test +inline + + + +basic/or.c:20:3 + +Test inline -basic/or.c:20:10 - -Test -inline - - - -basic/or.c:20:17 +basic/or.c:20:10 Test -inline +inline basic/or.c:20:17 Test +inline + + + +basic/or.c:20:17 + +Test inline -basic/or.h:5:3 - -TestH +basic/or.h:5:3 + +TestH loop-vectorize -basic/or.h:9:3 - -TestH -loop-unroll - - - -basic/or.h:13:3 +basic/or.h:9:3 TestH -inline +loop-unroll basic/or.h:13:3 TestH -inline +inline -basic/or.h:15:3 +basic/or.h:13:3 TestH -inline +inline basic/or.h:15:3 TestH +inline + + + +basic/or.h:15:3 + +TestH inline -basic/or.h:15:10 - -TestH -inline - - - -basic/or.h:15:17 +basic/or.h:15:10 TestH -inline +inline basic/or.h:15:17 TestH +inline + + + +basic/or.h:15:17 + +TestH inline diff --git a/llvm/test/tools/opt-viewer/Outputs/suppress/s.swift.html b/llvm/test/tools/opt-viewer/Outputs/suppress/s.swift.html index 813db9f98205..f67352079ed6 100644 --- a/llvm/test/tools/opt-viewer/Outputs/suppress/s.swift.html +++ b/llvm/test/tools/opt-viewer/Outputs/suppress/s.swift.html @@ -4,6 +4,23 @@ +
diff --git a/llvm/test/tools/opt-viewer/Outputs/unicode-function-name/s.swift.html b/llvm/test/tools/opt-viewer/Outputs/unicode-function-name/s.swift.html index 67514d556c38..744c5b7579e8 100644 --- a/llvm/test/tools/opt-viewer/Outputs/unicode-function-name/s.swift.html +++ b/llvm/test/tools/opt-viewer/Outputs/unicode-function-name/s.swift.html @@ -4,6 +4,23 @@ +
diff --git a/llvm/tools/opt-viewer/opt-viewer.py b/llvm/tools/opt-viewer/opt-viewer.py index f6582506311c..8aec321b9595 100755 --- a/llvm/tools/opt-viewer/opt-viewer.py +++ b/llvm/tools/opt-viewer/opt-viewer.py @@ -120,12 +120,26 @@ class SourceFileRenderer: indent = line[:max(r.Column, 1) - 1] indent = re.sub('\S', ' ', indent) + # Create expanded message and link if we have a multiline message. + lines = r.message.split('\n') + if len(lines) > 1: + expand_link = '+' + message = lines[0] + expand_message = u''' +'''.format(indent, '\n'.join(lines[1:])) + else: + expand_link = '' + expand_message = '' + message = r.message print(u''' {r.RelativeHotness} {r.PassWithDiffPrefix} -
{indent}
{r.message}  +
{indent}
{expand_link} {message} {expand_message} {inlining_context} '''.format(**locals()), file=self.stream) @@ -139,6 +153,23 @@ class SourceFileRenderer: +
diff --git a/llvm/tools/opt-viewer/style.css b/llvm/tools/opt-viewer/style.css index 0d3347c1578c..550c7e1cdff3 100644 --- a/llvm/tools/opt-viewer/style.css +++ b/llvm/tools/opt-viewer/style.css @@ -139,6 +139,16 @@ td:first-child { td:last-child { border-right: none; } +.expanded { + background-color: #f2f2f2; + padding-top: 5px; + padding-left: 5px; +} +.col-left { + float: left; + margin-bottom: -99999px; + padding-bottom: 99999px; +} /* Generated with pygmentize -S colorful -f html >> style.css */