Update prebuilt Clang to match Android kernel.
Bug: 132428451
Change-Id: I8f6e2cb23f381fc0c02ddea99b867e58e925e5be
diff --git a/linux-x64/clang/share/opt-viewer/opt-diff.py b/linux-x64/clang/share/opt-viewer/opt-diff.py
index f3bfd18..36e81a5 100755
--- a/linux-x64/clang/share/opt-viewer/opt-diff.py
+++ b/linux-x64/clang/share/opt-viewer/opt-diff.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2.7
+#!/usr/bin/env python
from __future__ import print_function
diff --git a/linux-x64/clang/share/opt-viewer/opt-stats.py b/linux-x64/clang/share/opt-viewer/opt-stats.py
index 03de23b..f4ee3a7 100755
--- a/linux-x64/clang/share/opt-viewer/opt-stats.py
+++ b/linux-x64/clang/share/opt-viewer/opt-stats.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2.7
+#!/usr/bin/env python
from __future__ import print_function
diff --git a/linux-x64/clang/share/opt-viewer/opt-viewer.py b/linux-x64/clang/share/opt-viewer/opt-viewer.py
index 4887043..4c10588 100755
--- a/linux-x64/clang/share/opt-viewer/opt-viewer.py
+++ b/linux-x64/clang/share/opt-viewer/opt-viewer.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2.7
+#!/usr/bin/env python
from __future__ import print_function
@@ -72,7 +72,10 @@
file_text = stream.read()
if self.no_highlight:
- html_highlighted = file_text.decode('utf-8')
+ if sys.version_info.major >= 3:
+ html_highlighted = file_text
+ else:
+ html_highlighted = file_text.decode('utf-8')
else:
html_highlighted = highlight(
file_text,
@@ -117,12 +120,26 @@
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 = '<a style="text-decoration: none;" href="" onclick="toggleExpandedMessage(this); return false;">+</a>'
+ message = lines[0]
+ expand_message = u'''
+<div class="full-info" style="display:none;">
+ <div class="col-left"><pre style="display:inline">{}</pre></div>
+ <div class="expanded col-left"><pre>{}</pre></div>
+</div>'''.format(indent, '\n'.join(lines[1:]))
+ else:
+ expand_link = ''
+ expand_message = ''
+ message = r.message
print(u'''
<tr>
<td></td>
<td>{r.RelativeHotness}</td>
<td class=\"column-entry-{r.color}\">{r.PassWithDiffPrefix}</td>
-<td><pre style="display:inline">{indent}</pre><span class=\"column-entry-yellow\"> {r.message} </span></td>
+<td><pre style="display:inline">{indent}</pre><span class=\"column-entry-yellow\">{expand_link} {message} </span>{expand_message}</td>
<td class=\"column-entry-yellow\">{inlining_context}</td>
</tr>'''.format(**locals()), file=self.stream)
@@ -136,6 +153,23 @@
<meta charset="utf-8" />
<head>
<link rel='stylesheet' type='text/css' href='style.css'>
+<script type="text/javascript">
+/* Simple helper to show/hide the expanded message of a remark. */
+function toggleExpandedMessage(e) {{
+ var FullTextElems = e.parentElement.parentElement.getElementsByClassName("full-info");
+ if (!FullTextElems || FullTextElems.length < 1) {{
+ return false;
+ }}
+ var FullText = FullTextElems[0];
+ if (FullText.style.display == 'none') {{
+ e.innerHTML = '-';
+ FullText.style.display = 'block';
+ }} else {{
+ e.innerHTML = '+';
+ FullText.style.display = 'none';
+ }}
+}}
+</script>
</head>
<body>
<div class="centered">
@@ -205,7 +239,7 @@
</html>''', file=self.stream)
-def _render_file(source_dir, output_dir, ctx, no_highlight, entry):
+def _render_file(source_dir, output_dir, ctx, no_highlight, entry, filter_):
global context
context = ctx
filename, remarks = entry
@@ -310,6 +344,11 @@
'--demangler',
help='Set the demangler to be used (defaults to %s)' % optrecord.Remark.default_demangler)
+ parser.add_argument(
+ '--filter',
+ default='',
+ help='Only display remarks from passes matching filter expression')
+
# Do not make this a global variable. Values needed to be propagated through
# to individual classes and functions to be portable with multiprocessing across
# Windows and non-Windows.
@@ -325,7 +364,7 @@
sys.exit(1)
all_remarks, file_remarks, should_display_hotness = \
- optrecord.gather_results(files, args.jobs, print_progress)
+ optrecord.gather_results(files, args.jobs, print_progress, args.filter)
map_remarks(all_remarks)
diff --git a/linux-x64/clang/share/opt-viewer/optpmap.py b/linux-x64/clang/share/opt-viewer/optpmap.py
index db6b079..8124c8c 100755
--- a/linux-x64/clang/share/opt-viewer/optpmap.py
+++ b/linux-x64/clang/share/opt-viewer/optpmap.py
@@ -14,7 +14,7 @@
def _wrapped_func(func_and_args):
- func, argument, should_print_progress = func_and_args
+ func, argument, should_print_progress, filter_ = func_and_args
if should_print_progress:
with _current.get_lock():
@@ -22,10 +22,10 @@
sys.stdout.write('\r\t{} of {}'.format(_current.value, _total.value))
sys.stdout.flush()
- return func(argument)
+ return func(argument, filter_)
-def pmap(func, iterable, processes, should_print_progress, *args, **kwargs):
+def pmap(func, iterable, processes, should_print_progress, filter_=None, *args, **kwargs):
"""
A parallel map function that reports on its progress.
@@ -40,9 +40,9 @@
_current = multiprocessing.Value('i', 0)
_total = multiprocessing.Value('i', len(iterable))
- func_and_args = [(func, arg, should_print_progress,) for arg in iterable]
+ func_and_args = [(func, arg, should_print_progress, filter_) for arg in iterable]
if processes == 1:
- result = map(_wrapped_func, func_and_args, *args, **kwargs)
+ result = list(map(_wrapped_func, func_and_args, *args, **kwargs))
else:
pool = multiprocessing.Pool(initializer=_init,
initargs=(_current, _total,),
diff --git a/linux-x64/clang/share/opt-viewer/optrecord.py b/linux-x64/clang/share/opt-viewer/optrecord.py
index 8cf22ee..e952d1b 100755
--- a/linux-x64/clang/share/opt-viewer/optrecord.py
+++ b/linux-x64/clang/share/opt-viewer/optrecord.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2.7
+#!/usr/bin/env python
from __future__ import print_function
@@ -24,6 +24,8 @@
except:
pass
+import re
+
import optpmap
try:
@@ -263,18 +265,24 @@
return "red"
-def get_remarks(input_file):
+def get_remarks(input_file, filter_):
max_hotness = 0
all_remarks = dict()
file_remarks = defaultdict(functools.partial(defaultdict, list))
with open(input_file) as f:
docs = yaml.load_all(f, Loader=Loader)
+
+ filter_e = re.compile(filter_)
for remark in docs:
remark.canonicalize()
# Avoid remarks withoug debug location or if they are duplicated
if not hasattr(remark, 'DebugLoc') or remark.key in all_remarks:
continue
+
+ if filter_ and not filter_e.search(remark.Pass):
+ continue
+
all_remarks[remark.key] = remark
file_remarks[remark.File][remark.Line].append(remark)
@@ -289,13 +297,13 @@
return max_hotness, all_remarks, file_remarks
-def gather_results(filenames, num_jobs, should_print_progress):
+def gather_results(filenames, num_jobs, should_print_progress, filter_):
if should_print_progress:
print('Reading YAML files...')
if not Remark.demangler_proc:
Remark.set_demangler(Remark.default_demangler)
remarks = optpmap.pmap(
- get_remarks, filenames, num_jobs, should_print_progress)
+ get_remarks, filenames, num_jobs, should_print_progress, filter_)
max_hotness = max(entry[0] for entry in remarks)
def merge_file_remarks(file_remarks_job, all_remarks, merged):
diff --git a/linux-x64/clang/share/opt-viewer/style.css b/linux-x64/clang/share/opt-viewer/style.css
index 0d3347c..550c7e1 100755
--- a/linux-x64/clang/share/opt-viewer/style.css
+++ b/linux-x64/clang/share/opt-viewer/style.css
@@ -139,6 +139,16 @@
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 */