This was previously posted as:
"[PATCH 05/10] JIT-related changes outside of jit subdir"
https://gcc.gnu.org/ml/gcc-patches/2014-10/msg01246.html
and approved by Jeff in
https://gcc.gnu.org/ml/gcc-patches/2014-10/msg01410.html
> OK if/when rest of JIT bits are approved.
Joseph pointed out that I should add a note about sphinx
as a dependency to install.texi:
https://gcc.gnu.org/ml/gcc-patches/2014-10/msg01793.html
I do that in the next patch.
ChangeLog:
* MAINTAINERS (Various Maintainers): Add myself as jit maintainer.
contrib/ChangeLog:
* jit-coverage-report.py: New file: a script to print crude
code-coverage information for the libgccjit API.
gcc/ChangeLog:
* doc/install.texi (--enable-host-shared): Specify that this is
required when building libgccjit.
* timevar.def (TV_JIT_REPLAY): New.
(TV_ASSEMBLE): New.
(TV_LINK): New.
(TV_LOAD): New.
---
MAINTAINERS| 1 +
contrib/jit-coverage-report.py | 67 ++
gcc/doc/install.texi | 2 +-
gcc/timevar.def| 6
4 files changed, 75 insertions(+), 1 deletion(-)
create mode 100644 contrib/jit-coverage-report.py
diff --git a/MAINTAINERS b/MAINTAINERS
index 11a28ef..3a7cf6f8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -260,6 +260,7 @@ testsuite Janis Johnson
register allocationVladimir Makarov
gdbhooks.pyDavid Malcolm
SLSR Bill Schmidt
+jitDavid Malcolm
Note that individuals who maintain parts of the compiler need approval to
check in changes outside of the parts of the compiler they maintain.
diff --git a/contrib/jit-coverage-report.py b/contrib/jit-coverage-report.py
new file mode 100644
index 000..529336f
--- /dev/null
+++ b/contrib/jit-coverage-report.py
@@ -0,0 +1,67 @@
+#! /usr/bin/python
+#
+# Print a report on which libgccjit.so symbols are used in which test
+# cases, and which lack test coverage. Tested with Python 2.7 and 3.2
+# To be run from the root directory of the source tree.
+#
+# Copyright (C) 2014 Free Software Foundation, Inc.
+# Written by David Malcolm .
+#
+# This script is Free Software, and it can be copied, distributed and
+# modified as defined in the GNU General Public License. A copy of
+# its license can be downloaded from http://www.gnu.org/copyleft/gpl.html
+
+from collections import Counter
+import glob
+import re
+import sys
+
+def parse_map_file(path):
+"""
+Parse libgccjit.map, returning the symbols in the API as a list of str.
+"""
+syms = []
+with open(path) as f:
+for line in f:
+m = re.match('^\s+([a-z_]+);$', line)
+if m:
+syms.append(m.group(1))
+return syms
+
+def parse_test_case(path):
+"""
+Locate all symbol-like things in a C test case, yielding
+them as a sequence of str.
+"""
+with open(path) as f:
+for line in f:
+for m in re.finditer('([_A-Za-z][_A-Za-z0-9]*)', line):
+yield m.group(1)
+
+def find_test_cases():
+for path in glob.glob('gcc/testsuite/jit.dg/*.[ch]'):
+yield path
+
+api_syms = parse_map_file('gcc/jit/libgccjit.map')
+
+syms_in_test_cases = {}
+for path in find_test_cases():
+syms_in_test_cases[path] = list(parse_test_case(path))
+
+uses = Counter()
+for sym in sorted(api_syms):
+print('symbol: %s' % sym)
+uses[sym] = 0
+for path in syms_in_test_cases:
+count = syms_in_test_cases[path].count(sym)
+uses[sym] += count
+if count:
+print(' uses in %s: %i' % (path, count))
+if uses[sym] == 0:
+print(' NEVER USED')
+sys.stdout.write('\n')
+
+layout = '%40s %5s %s'
+print(layout % ('SYMBOL', 'USES', 'HISTOGRAM'))
+for sym, count in uses.most_common():
+print(layout % (sym, count, '*' * count if count else 'UNUSED'))
diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
index 3df78ff..06fcd8a 100644
--- a/gcc/doc/install.texi
+++ b/gcc/doc/install.texi
@@ -954,7 +954,7 @@ Specify that the @emph{host} code should be built into
position-independent
machine code (with -fPIC), allowing it to be used within shared libraries,
but yielding a slightly slower compiler.
-Currently this option is only of use to people developing GCC itself.
+This option is required when building the libgccjit.so library.
Contrast with @option{--enable-shared}, which affects @emph{target}
libraries.
diff --git a/gcc/timevar.def b/gcc/timevar.def
index 96b6069..6968a06 100644
--- a/gcc/timevar.def
+++ b/gcc/timevar.def
@@ -279,3 +279,9 @@ DEFTIMEVAR (TV_VERIFY_LOOP_CLOSED, "verify loop closed")
DEFTIMEVAR (TV_VERIFY_RTL_SHARING, "verify RTL sharing")
DEFTIMEVAR (TV_REBUILD_FREQUENCIES , "rebuild frequencies")
DEFTIMEVAR (TV_REPAIR_LOOPS , "repair loop structures")
+
+/* Stuff used by libgccj