From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6992 invoked by alias); 31 Oct 2014 17:07:31 -0000 Mailing-List: contact jit-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Subscribe: Sender: jit-owner@gcc.gnu.org Received: (qmail 6667 invoked by uid 89); 31 Oct 2014 17:07:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.98.4 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=2.7 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPAM_URI1,SPF_HELO_PASS,SPF_PASS autolearn=no version=3.3.2 X-Spam-Status: No, score=2.7 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPAM_URI1,SPF_HELO_PASS,SPF_PASS autolearn=no version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: ** X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com From: David Malcolm To: gcc-patches@gcc.gnu.org, jit@gcc.gnu.org Cc: David Malcolm Subject: [PATCH 02/27] JIT-related changes outside of jit subdir Date: Wed, 01 Jan 2014 00:00:00 -0000 Message-Id: <1414774977-25605-3-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1414774977-25605-1-git-send-email-dmalcolm@redhat.com> References: <1414774977-25605-1-git-send-email-dmalcolm@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-SW-Source: 2014-q4/txt/msg00066.txt.bz2 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 allocation Vladimir Makarov gdbhooks.py David Malcolm SLSR Bill Schmidt +jit David 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 0000000..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 libgccjit.so. */ +DEFTIMEVAR (TV_JIT_REPLAY , "replay of JIT client activity") +DEFTIMEVAR (TV_ASSEMBLE , "assemble JIT code") +DEFTIMEVAR (TV_LINK , "link JIT code") +DEFTIMEVAR (TV_LOAD , "load JIT result") -- 1.8.5.3