llvm.org GIT mirror llvm / af12c3e
[opt-viewer] Suppress noisy Swift remarks Most likely, this is not how we want to handle this in the long term. This code should probably be in the Swift repo and somehow plugged into the opt-viewer. This is still however very experimental at this point so I don't want to over-engineer it at this point. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319902 91177308-0d34-0410-b5e6-96231b3b80d8 Adam Nemet 1 year, 8 months ago
7 changed file(s) with 377 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
0 --- !Passed
1 Pass: sil-generic-specializer
2 Name: sil.Specialized
3 DebugLoc:
4 File: s.swift
5 Line: 7
6 Column: 13
7 Function: 'f()'
8 Args:
9 - String: 'Specialized function '
10 - Function: '"Swift.CountableRange.init(uncheckedBounds:)"'
11 - String: ' with type '
12 - FuncType: '(Int, Int, @thin CountableRange.Type) -> CountableRange'
13 ...
14 --- !Passed
15 Pass: sil-generic-specializer
16 Name: sil.Specialized
17 DebugLoc:
18 File: s.swift
19 Line: 7
20 Column: 12
21 Function: 'f()'
22 Args:
23 - String: 'Specialized function '
24 - Function: '"Swift.Collection<>.makeIterator()"'
25 - String: ' with type '
26 - FuncType: '(@in_guaranteed CountableRange) -> IndexingIterator>'
27 ...
28 --- !Passed
29 Pass: sil-generic-specializer
30 Name: sil.Specialized
31 DebugLoc:
32 File: s.swift
33 Line: 7
34 Column: 9
35 Function: 'f()'
36 Args:
37 - String: 'Specialized function '
38 - Function: '"Swift.IndexingIterator.next()"'
39 - String: ' with type '
40 - FuncType: '(@inout IndexingIterator>) -> Optional'
41 ...
42 --- !Passed
43 Pass: sil-generic-specializer
44 Name: sil.Specialized
45 DebugLoc:
46 File: s.swift
47 Line: 8
48 Column: 12
49 Function: 'f()'
50 Args:
51 - String: 'Specialized function '
52 - Function: '"Swift._allocateUninitializedArray(_:)"'
53 - String: ' with type '
54 - FuncType: '(Builtin.Word) -> (@owned Array, Builtin.RawPointer)'
55 ...
56 --- !Passed
57 Pass: sil-generic-specializer
58 Name: sil.Specialized
59 DebugLoc:
60 File: s.swift
61 Line: 8
62 Column: 12
63 Function: 'f()'
64 Args:
65 - String: 'Specialized function '
66 - Function: '"Swift.Array.subscript.getter"'
67 - String: ' with type '
68 - FuncType: '(Int, @guaranteed Array) -> Int'
69 ...
70 --- !Passed
71 Pass: sil-inliner
72 Name: sil.Inlined
73 DebugLoc:
74 File: s.swift
75 Line: 7
76 Column: 13
77 Function: 'f()'
78 Args:
79 - Callee: '"specialized Swift.CountableRange.init(uncheckedBounds:)"'
80 DebugLoc:
81 File: blah.swift
82 Line: 6
83 Column: 6
84 - String: ' inlined into '
85 - Caller: '"s.f()"'
86 DebugLoc:
87 File: s.swift
88 Line: 6
89 Column: 6
90 - String: ' (cost = '
91 - Cost: '0'
92 - String: ', benefit = '
93 - Benefit: '20'
94 - String: ')'
95 ...
96 --- !Passed
97 Pass: sil-inliner
98 Name: sil.Inlined
99 DebugLoc:
100 File: s.swift
101 Line: 8
102 Column: 12
103 Function: 'f()'
104 Args:
105 - Callee: '"specialized Swift.Array.subscript.getter"'
106 - String: ' inlined into '
107 - Caller: '"s.f()"'
108 DebugLoc:
109 File: s.swift
110 Line: 6
111 Column: 6
112 - String: ' (cost = '
113 - Cost: '3'
114 - String: ', benefit = '
115 - Benefit: '52'
116 - String: ')'
117 ...
118 --- !Passed
119 Pass: sil-generic-specializer
120 Name: sil.Specialized
121 DebugLoc:
122 File: s.swift
123 Line: 4
124 Column: 17
125 Function: main
126 Args:
127 - String: 'Specialized function '
128 - Function: '"Swift._allocateUninitializedArray(_:)"'
129 - String: ' with type '
130 - FuncType: '(Builtin.Word) -> (@owned Array, Builtin.RawPointer)'
131 ...
132 --- !Passed
133 Pass: sil-generic-specializer
134 Name: sil.Specialized
135 DebugLoc:
136 File: s.swift
137 Line: 4
138 Column: 16
139 Function: main
140 Args:
141 - String: 'Specialized function '
142 - Function: '"Swift.Array.init(arrayLiteral:)"'
143 - String: ' with type '
144 - FuncType: '(@owned Array, @thin Array.Type) -> @owned Array'
145 ...
146 --- !Passed
147 Pass: sil-inliner
148 Name: sil.Inlined
149 DebugLoc:
150 File: s.swift
151 Line: 4
152 Column: 16
153 Function: main
154 Args:
155 - Callee: '"specialized Swift.Array.init(arrayLiteral:)"'
156 - String: ' inlined into '
157 - Caller: '"main"'
158 - String: ' (cost = '
159 - Cost: '0'
160 - String: ', benefit = '
161 - Benefit: '20'
162 - String: ')'
163 ...
164 --- !Passed
165 Pass: sil-inliner
166 Name: sil.Inlined
167 DebugLoc:
168 File: s.swift
169 Line: 12
170 Column: 1
171 Function: main
172 Args:
173 - Callee: '"s.f()"'
174 DebugLoc:
175 File: s.swift
176 Line: 6
177 Column: 6
178 - String: ' inlined into '
179 - Caller: '"main"'
180 - String: ' (cost = '
181 - Cost: '20'
182 - String: ', benefit = '
183 - Benefit: '20'
184 - String: ')'
185 ...
0 import Swift
1
2 var s: [Int] = [1, 2, 3, 4]
3
4 func f() {
5 for i in 0..<4 {
6 print(s[i])
7 }
8 }
9
10 f()
0
1
2
3
4
5
6
7
8
9 Source Location
10 Hotness
11 Function
12 Pass
13
14
15
16 s.swift:12:1
17
18 main
19 sil-inliner
20
21
22
23
24
0
1
2
3
4
5
6
7
8
9
10 Line
11 Hotness
12 Optimization
13 Source
14 Inline Context
15
16
17
18
19
20 1
21
22
23
import Swift
24
25
26
27 2
28
29
30
31
32
33
34 3
35
36
37
var s: [Int] = [1, 2, 3, 4]
38
39
40
41 4
42
43
44
45
46
47
48 5
49
50
51
func f() {
52
53
54
55 6
56
57
58
  for i in 0..<4 {
59
60
61
62 7
63
64
65
    print(s[i])
66
67
68
69 8
70
71
72
  }
73
74
75
76 9
77
78
79
}
80
81
82
83 10
84
85
86
87
88
89
90 11
91
92
93
f()
94
95
96
97 12
98
99
100
101
102
103
104
105
106 sil-inliner
107
 "s.f()" inlined into "main" (cost = 20, benefit = 20) 
108 main
109
110
111
112
113
114
0 RUN: %opt-viewer -s %p/Inputs/suppress -o %t %p/Inputs/suppress/s.opt.yaml --no-highlight --demangler=llvm-cxxfilt
1 RUN: diff %p/Outputs/suppress/index.html %t/index.html
2 RUN: diff %p/Outputs/suppress/s.swift.html %t/s.swift.html
'''.format(**locals()), file=self.stream)
3232 self.caller_loc = caller_loc
3333
3434 context = Context()
35
36 def suppress(remark):
37 if remark.Name == 'sil.Specialized':
38 return remark.getArgDict()['Function'][0].startswith('\"Swift.')
39 elif remark.Name == 'sil.Inlined':
40 return remark.getArgDict()['Callee'][0].startswith(('\"Swift.', '\"specialized Swift.'))
41 return False
3542
3643 class SourceFileRenderer:
3744 def __init__(self, source_dir, output_dir, filename):
8794
8895
8996 for remark in line_remarks.get(linenum, []):
90 self.render_inline_remarks(remark, html_line)
97 if not suppress(remark):
98 self.render_inline_remarks(remark, html_line)
9199
92100 def render_inline_remarks(self, r, line):
93101 inlining_context = r.DemangledFunctionName
178186 max_entries = args.max_hottest_remarks_on_index
179187
180188 for i, remark in enumerate(all_remarks[:max_entries]):
181 self.render_entry(remark, i % 2)
189 if not suppress(remark):
190 self.render_entry(remark, i % 2)
182191 print('''
183192
184193
160160 else:
161161 return value
162162
163 # Return a cached dictionary for the arguments. The key for each entry is
164 # the argument key (e.g. 'Callee' for inlining remarks. The value is a
165 # list containing the value (e.g. for 'Callee' the function) and
166 # optionally a DebugLoc.
167 def getArgDict(self):
168 if hasattr(self, 'ArgDict'):
169 return self.ArgDict
170 self.ArgDict = {}
171 for arg in self.Args:
172 if len(arg) == 2:
173 if arg[0][0] == 'DebugLoc':
174 dbgidx = 0
175 else:
176 assert(arg[1][0] == 'DebugLoc')
177 dbgidx = 1
178
179 key = arg[1 - dbgidx][0]
180 entry = (arg[1 - dbgidx][1], arg[dbgidx][1])
181 else:
182 arg = arg[0]
183 key = arg[0]
184 entry = (arg[1], )
185
186 self.ArgDict[key] = entry
187 return self.ArgDict
188
163189 def getDiffPrefix(self):
164190 if hasattr(self, 'Added'):
165191 if self.Added: