--- /dev/null
+--- !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: ')'
+...
--- /dev/null
+import Swift
+
+var s: [Int] = [1, 2, 3, 4]
+
+func f() {
+ for i in 0..<4 {
+ print(s[i])
+ }
+}
+
+f()
--- /dev/null
+
+<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>
--- /dev/null
+
+<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>
--- /dev/null
+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
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
</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
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>
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: