diff options
-rw-r--r-- | llvm/test/tools/opt-viewer/Inputs/suppress/s.opt.yaml | 186 | ||||
-rw-r--r-- | llvm/test/tools/opt-viewer/Inputs/suppress/s.swift | 11 | ||||
-rw-r--r-- | llvm/test/tools/opt-viewer/Outputs/suppress/index.html | 25 | ||||
-rw-r--r-- | llvm/test/tools/opt-viewer/Outputs/suppress/s.swift.html | 115 | ||||
-rw-r--r-- | llvm/test/tools/opt-viewer/suppress.test | 3 | ||||
-rwxr-xr-x | llvm/tools/opt-viewer/opt-viewer.py | 13 | ||||
-rw-r--r-- | llvm/tools/opt-viewer/optrecord.py | 26 |
7 files changed, 377 insertions, 2 deletions
diff --git a/llvm/test/tools/opt-viewer/Inputs/suppress/s.opt.yaml b/llvm/test/tools/opt-viewer/Inputs/suppress/s.opt.yaml new file mode 100644 index 00000000000..de161bf95f8 --- /dev/null +++ b/llvm/test/tools/opt-viewer/Inputs/suppress/s.opt.yaml @@ -0,0 +1,186 @@ +--- !Passed +Pass: sil-generic-specializer +Name: sil.Specialized +DebugLoc: + File: s.swift + Line: 7 + Column: 13 +Function: 'f()' +Args: + - String: 'Specialized function ' + - Function: '"Swift.CountableRange.init(uncheckedBounds:)"' + - String: ' with type ' + - FuncType: '(Int, Int, @thin CountableRange<Int>.Type) -> CountableRange<Int>' +... +--- !Passed +Pass: sil-generic-specializer +Name: sil.Specialized +DebugLoc: + File: s.swift + Line: 7 + Column: 12 +Function: 'f()' +Args: + - String: 'Specialized function ' + - Function: '"Swift.Collection<>.makeIterator()"' + - String: ' with type ' + - FuncType: '(@in_guaranteed CountableRange<Int>) -> IndexingIterator<CountableRange<Int>>' +... +--- !Passed +Pass: sil-generic-specializer +Name: sil.Specialized +DebugLoc: + File: s.swift + Line: 7 + Column: 9 +Function: 'f()' +Args: + - String: 'Specialized function ' + - Function: '"Swift.IndexingIterator.next()"' + - String: ' with type ' + - FuncType: '(@inout IndexingIterator<CountableRange<Int>>) -> Optional<Int>' +... +--- !Passed +Pass: sil-generic-specializer +Name: sil.Specialized +DebugLoc: + File: s.swift + Line: 8 + Column: 12 +Function: 'f()' +Args: + - String: 'Specialized function ' + - Function: '"Swift._allocateUninitializedArray<A>(_:)"' + - String: ' with type ' + - FuncType: '(Builtin.Word) -> (@owned Array<Any>, Builtin.RawPointer)' +... +--- !Passed +Pass: sil-generic-specializer +Name: sil.Specialized +DebugLoc: + File: s.swift + Line: 8 + Column: 12 +Function: 'f()' +Args: + - String: 'Specialized function ' + - Function: '"Swift.Array.subscript.getter"' + - String: ' with type ' + - FuncType: '(Int, @guaranteed Array<Int>) -> Int' +... +--- !Passed +Pass: sil-inliner +Name: sil.Inlined +DebugLoc: + File: s.swift + Line: 7 + Column: 13 +Function: 'f()' +Args: + - Callee: '"specialized Swift.CountableRange.init(uncheckedBounds:)"' + DebugLoc: + File: blah.swift + Line: 6 + Column: 6 + - String: ' inlined into ' + - Caller: '"s.f()"' + DebugLoc: + File: s.swift + Line: 6 + Column: 6 + - String: ' (cost = ' + - Cost: '0' + - String: ', benefit = ' + - Benefit: '20' + - String: ')' +... +--- !Passed +Pass: sil-inliner +Name: sil.Inlined +DebugLoc: + File: s.swift + Line: 8 + Column: 12 +Function: 'f()' +Args: + - Callee: '"specialized Swift.Array.subscript.getter"' + - String: ' inlined into ' + - Caller: '"s.f()"' + DebugLoc: + File: s.swift + Line: 6 + Column: 6 + - String: ' (cost = ' + - Cost: '3' + - String: ', benefit = ' + - Benefit: '52' + - String: ')' +... +--- !Passed +Pass: sil-generic-specializer +Name: sil.Specialized +DebugLoc: + File: s.swift + Line: 4 + Column: 17 +Function: main +Args: + - String: 'Specialized function ' + - Function: '"Swift._allocateUninitializedArray<A>(_:)"' + - String: ' with type ' + - FuncType: '(Builtin.Word) -> (@owned Array<Int>, Builtin.RawPointer)' +... +--- !Passed +Pass: sil-generic-specializer +Name: sil.Specialized +DebugLoc: + File: s.swift + Line: 4 + Column: 16 +Function: main +Args: + - String: 'Specialized function ' + - Function: '"Swift.Array.init(arrayLiteral:)"' + - String: ' with type ' + - FuncType: '(@owned Array<Int>, @thin Array<Int>.Type) -> @owned Array<Int>' +... +--- !Passed +Pass: sil-inliner +Name: sil.Inlined +DebugLoc: + File: s.swift + Line: 4 + Column: 16 +Function: main +Args: + - Callee: '"specialized Swift.Array.init(arrayLiteral:)"' + - String: ' inlined into ' + - Caller: '"main"' + - String: ' (cost = ' + - Cost: '0' + - String: ', benefit = ' + - Benefit: '20' + - String: ')' +... +--- !Passed +Pass: sil-inliner +Name: sil.Inlined +DebugLoc: + File: s.swift + Line: 12 + Column: 1 +Function: main +Args: + - Callee: '"s.f()"' + DebugLoc: + File: s.swift + Line: 6 + Column: 6 + - String: ' inlined into ' + - Caller: '"main"' + - String: ' (cost = ' + - Cost: '20' + - String: ', benefit = ' + - Benefit: '20' + - String: ')' +... diff --git a/llvm/test/tools/opt-viewer/Inputs/suppress/s.swift b/llvm/test/tools/opt-viewer/Inputs/suppress/s.swift new file mode 100644 index 00000000000..a1b17a97945 --- /dev/null +++ b/llvm/test/tools/opt-viewer/Inputs/suppress/s.swift @@ -0,0 +1,11 @@ +import Swift + +var s: [Int] = [1, 2, 3, 4] + +func f() { + for i in 0..<4 { + print(s[i]) + } +} + +f() diff --git a/llvm/test/tools/opt-viewer/Outputs/suppress/index.html b/llvm/test/tools/opt-viewer/Outputs/suppress/index.html new file mode 100644 index 00000000000..5648b4b2d4e --- /dev/null +++ b/llvm/test/tools/opt-viewer/Outputs/suppress/index.html @@ -0,0 +1,25 @@ + +<html> +<head> +<link rel='stylesheet' type='text/css' href='style.css'> +</head> +<body> +<div class="centered"> +<table> +<tr> +<td>Source Location</td> +<td>Hotness</td> +<td>Function</td> +<td>Pass</td> +</tr> + +<tr> +<td class="column-entry-0"><a href="s.swift.html#L12">s.swift:12:1</a></td> +<td class="column-entry-0"></td> +<td class="column-entry-0">main</td> +<td class="column-entry-green">sil-inliner</td> +</tr> + +</table> +</body> +</html> diff --git a/llvm/test/tools/opt-viewer/Outputs/suppress/s.swift.html b/llvm/test/tools/opt-viewer/Outputs/suppress/s.swift.html new file mode 100644 index 00000000000..f3d43c82b59 --- /dev/null +++ b/llvm/test/tools/opt-viewer/Outputs/suppress/s.swift.html @@ -0,0 +1,115 @@ + +<html> +<head> +<link rel='stylesheet' type='text/css' href='style.css'> +</head> +<body> +<div class="centered"> +<table class="source"> +<thead> +<tr> +<th style="width: 2%">Line</td> +<th style="width: 3%">Hotness</td> +<th style="width: 10%">Optimization</td> +<th style="width: 70%">Source</td> +<th style="width: 15%">Inline Context</td> +</tr> +</thead> +<tbody> + +<tr> +<td><a name="L1">1</a></td> +<td></td> +<td></td> +<td><div class="highlight"><pre>import Swift</pre></div></td> +</tr> + +<tr> +<td><a name="L2">2</a></td> +<td></td> +<td></td> +<td><div class="highlight"><pre></pre></div></td> +</tr> + +<tr> +<td><a name="L3">3</a></td> +<td></td> +<td></td> +<td><div class="highlight"><pre>var s: [Int] = [1, 2, 3, 4]</pre></div></td> +</tr> + +<tr> +<td><a name="L4">4</a></td> +<td></td> +<td></td> +<td><div class="highlight"><pre></pre></div></td> +</tr> + +<tr> +<td><a name="L5">5</a></td> +<td></td> +<td></td> +<td><div class="highlight"><pre>func f() {</pre></div></td> +</tr> + +<tr> +<td><a name="L6">6</a></td> +<td></td> +<td></td> +<td><div class="highlight"><pre> for i in 0..<4 {</pre></div></td> +</tr> + +<tr> +<td><a name="L7">7</a></td> +<td></td> +<td></td> +<td><div class="highlight"><pre> print(s[i])</pre></div></td> +</tr> + +<tr> +<td><a name="L8">8</a></td> +<td></td> +<td></td> +<td><div class="highlight"><pre> }</pre></div></td> +</tr> + +<tr> +<td><a name="L9">9</a></td> +<td></td> +<td></td> +<td><div class="highlight"><pre>}</pre></div></td> +</tr> + +<tr> +<td><a name="L10">10</a></td> +<td></td> +<td></td> +<td><div class="highlight"><pre></pre></div></td> +</tr> + +<tr> +<td><a name="L11">11</a></td> +<td></td> +<td></td> +<td><div class="highlight"><pre>f()</pre></div></td> +</tr> + +<tr> +<td><a name="L12">12</a></td> +<td></td> +<td></td> +<td><div class="highlight"><pre></pre></div></td> +</tr> + +<tr> +<td></td> +<td></td> +<td class="column-entry-green">sil-inliner</td> +<td><pre style="display:inline"></pre><span class="column-entry-yellow"> <a href="s.swift.html#L6">"s.f()"</a> inlined into "main" (cost = 20, benefit = 20) </span></td> +<td class="column-entry-yellow">main</td> +</tr> + +</tbody> +</table> +</body> +</html> diff --git a/llvm/test/tools/opt-viewer/suppress.test b/llvm/test/tools/opt-viewer/suppress.test new file mode 100644 index 00000000000..33226e53953 --- /dev/null +++ b/llvm/test/tools/opt-viewer/suppress.test @@ -0,0 +1,3 @@ +RUN: %opt-viewer -s %p/Inputs/suppress -o %t %p/Inputs/suppress/s.opt.yaml --no-highlight --demangler=llvm-cxxfilt +RUN: diff %p/Outputs/suppress/index.html %t/index.html +RUN: diff %p/Outputs/suppress/s.swift.html %t/s.swift.html diff --git a/llvm/tools/opt-viewer/opt-viewer.py b/llvm/tools/opt-viewer/opt-viewer.py index 3000fb12f0b..4c09ef86869 100755 --- a/llvm/tools/opt-viewer/opt-viewer.py +++ b/llvm/tools/opt-viewer/opt-viewer.py @@ -34,6 +34,13 @@ class Context: context = Context() +def suppress(remark): + if remark.Name == 'sil.Specialized': + return remark.getArgDict()['Function'][0].startswith('\"Swift.') + elif remark.Name == 'sil.Inlined': + return remark.getArgDict()['Callee'][0].startswith(('\"Swift.', '\"specialized Swift.')) + return False + class SourceFileRenderer: def __init__(self, source_dir, output_dir, filename): existing_filename = None @@ -88,7 +95,8 @@ class SourceFileRenderer: </tr>'''.format(**locals()), file=self.stream) for remark in line_remarks.get(linenum, []): - self.render_inline_remarks(remark, html_line) + if not suppress(remark): + self.render_inline_remarks(remark, html_line) def render_inline_remarks(self, r, line): inlining_context = r.DemangledFunctionName @@ -179,7 +187,8 @@ class IndexRenderer: max_entries = args.max_hottest_remarks_on_index for i, remark in enumerate(all_remarks[:max_entries]): - self.render_entry(remark, i % 2) + if not suppress(remark): + self.render_entry(remark, i % 2) print(''' </table> </body> diff --git a/llvm/tools/opt-viewer/optrecord.py b/llvm/tools/opt-viewer/optrecord.py index ce665299e17..2256b4dd243 100644 --- a/llvm/tools/opt-viewer/optrecord.py +++ b/llvm/tools/opt-viewer/optrecord.py @@ -161,6 +161,32 @@ class Remark(yaml.YAMLObject): else: return value + # Return a cached dictionary for the arguments. The key for each entry is + # the argument key (e.g. 'Callee' for inlining remarks. The value is a + # list containing the value (e.g. for 'Callee' the function) and + # optionally a DebugLoc. + def getArgDict(self): + if hasattr(self, 'ArgDict'): + return self.ArgDict + self.ArgDict = {} + for arg in self.Args: + if len(arg) == 2: + if arg[0][0] == 'DebugLoc': + dbgidx = 0 + else: + assert(arg[1][0] == 'DebugLoc') + dbgidx = 1 + + key = arg[1 - dbgidx][0] + entry = (arg[1 - dbgidx][1], arg[dbgidx][1]) + else: + arg = arg[0] + key = arg[0] + entry = (arg[1], ) + + self.ArgDict[key] = entry + return self.ArgDict + def getDiffPrefix(self): if hasattr(self, 'Added'): if self.Added: |