diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2019-07-03 23:13:09 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2019-07-03 23:13:09 +0000 |
commit | 0baa9d1d59bf17177e80838ebe66df10a7a909c0 (patch) | |
tree | a1b956eacf43ba6ac1d052faad8a2df8f4f6ef5a /contrib | |
parent | 133d3bd8362f0c438017ca18adb51afb7288f78b (diff) | |
parent | 651c754cfbd1928abd8ac6b3121fc37c85907dcb (diff) | |
download | gcc-0baa9d1d59bf17177e80838ebe66df10a7a909c0.zip gcc-0baa9d1d59bf17177e80838ebe66df10a7a909c0.tar.gz gcc-0baa9d1d59bf17177e80838ebe66df10a7a909c0.tar.bz2 |
Merge from trunk revision 273026.
From-SVN: r273027
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/ChangeLog | 17 | ||||
-rwxr-xr-x | contrib/bench-stringop | 158 | ||||
-rwxr-xr-x | contrib/filter-clang-warnings.py (renamed from contrib/filter-rtags-warnings.py) | 47 | ||||
-rwxr-xr-x | contrib/mklog | 30 |
4 files changed, 214 insertions, 38 deletions
diff --git a/contrib/ChangeLog b/contrib/ChangeLog index 09174eb..aff6b13 100644 --- a/contrib/ChangeLog +++ b/contrib/ChangeLog @@ -1,3 +1,20 @@ +2019-07-02 Janne Blomqvist <jb@gcc.gnu.org> + + PR other/91048 + * mklog (read_user_info): Open ~/.mklog in string mode. + +2019-06-19 Martin Liska <mliska@suse.cz> + + * bench-stringop: New file. + +2019-05-21 Janne Blomqvist <jb@gcc.gnu.org> + + * mklog: Open files in text mode. + +2019-05-21 Janne Blomqvist <jb@gcc.gnu.org> + + * mklog: Convert to Python 3. + 2019-05-03 Jakub Jelinek <jakub@redhat.com> * gennews (files): Add files for GCC 9. diff --git a/contrib/bench-stringop b/contrib/bench-stringop new file mode 100755 index 0000000..7af8bfd --- /dev/null +++ b/contrib/bench-stringop @@ -0,0 +1,158 @@ +#!/bin/bash + +# Script to measure memset and memcpy for different sizes and strategies. +# +# Contributed by Jan Hubicka <jh@suse.cz> +# +# Copyright (C) 2019 Free Software Foundation, Inc. +# +# This file is part of GCC. +# +# GCC is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GCC is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING. If not, write to +# the Free Software Foundation, 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. + +# This script will search a line starting with 'spawn' that includes the +# pattern you are looking for (typically a source file name). +# +# Once it finds that pattern, it re-executes the whole command +# in the spawn line. If the pattern matches more than one spawn +# command, it asks which one you want. + +test() +{ +rm -f a.out +cat <<END | $1 -x c -O3 $3 -DAVG_SIZE=$2 $STRINGOP -DMEMORY_COPIES=$memsize - +#define BUFFER_SIZE (16*1024*1024 + AVG_SIZE*2) +/*#define MEMORY_COPIES (1024*1024*64*(long long)10)*/ +$type t[BUFFER_SIZE]; +int main() +{ + unsigned int i; + for (i=0;i<((long long)MEMORY_COPIES + AVG_SIZE * 2 - 1)/AVG_SIZE*2;i++) +#ifdef test_memset + __builtin_memset (t+(i*1024*1024+i*1)%(BUFFER_SIZE - AVG_SIZE*2), i, (AVG_SIZE + i) % (AVG_SIZE * 2 + 0)); +#else + __builtin_memcpy (t+(i*1024*1024+i*1)%(BUFFER_SIZE - AVG_SIZE*2), t+((i+1)*1024*1024*4+i*1)%(BUFFER_SIZE - AVG_SIZE *2), (AVG_SIZE + i) % (AVG_SIZE * 2 + 0)); +#endif + return 0; +} +END +TIME=`/usr/bin/time -f "%E" ./a.out 2>&1` +echo -n " "$TIME +echo $TIME $4 >>/tmp/accum +} + +test2() +{ +rm -f a.out +cat <<END | clang -x c -O3 $3 -DAVG_SIZE=$2 $STRINGOP -DMEMORY_COPIES=$memsize 2>/dev/null - +#define BUFFER_SIZE (16*1024*1024 + AVG_SIZE*2) +/*#define MEMORY_COPIES (1024*1024*64*(long long)10)*/ +$type t[BUFFER_SIZE]; +int main() +{ + unsigned int i; + for (i=0;i<((long long)MEMORY_COPIES + AVG_SIZE * 2 - 1)/AVG_SIZE*2;i++) +#ifdef test_memset + __builtin_memset (t+(i*1024*1024+i*1)%(BUFFER_SIZE - AVG_SIZE*2), i, (AVG_SIZE + i) % (AVG_SIZE * 2 + 0)); +#else + __builtin_memcpy (t+(i*1024*1024+i*1)%(BUFFER_SIZE - AVG_SIZE*2), t+((i+1)*1024*1024*4+i*1)%(BUFFER_SIZE - AVG_SIZE *2), (AVG_SIZE + i) % (AVG_SIZE * 2 + 0)); +#endif + return 0; +} +END +TIME=`/usr/bin/time -f "%E" ./a.out 2>&1` +echo -n " "$TIME +echo $TIME $4 >>/tmp/accum +} + +testrow() +{ +echo -n "" >/tmp/accum +printf "%12i " $3 +test "$2" "$3" "-mstringop-strategy=libcall" libcall +test "$2" "$3" "-mstringop-strategy=rep_byte -malign-stringops" rep1 +test "$2" "$3" "-mstringop-strategy=rep_byte -mno-align-stringops" rep1noalign +test "$2" "$3" "-mstringop-strategy=rep_4byte -malign-stringops" rep4 +test "$2" "$3" "-mstringop-strategy=rep_4byte -mno-align-stringops" rep4noalign +if [ "$mode" == 64 ] +then +test "$2" "$3" "-mstringop-strategy=rep_8byte -malign-stringops" rep8 +test "$2" "$3" "-mstringop-strategy=rep_8byte -mno-align-stringops" rep8noalign +fi +test "$2" "$3" "-mstringop-strategy=loop -malign-stringops" loop +test "$2" "$3" "-mstringop-strategy=loop -mno-align-stringops" loopnoalign +test "$2" "$3" "-mstringop-strategy=unrolled_loop -malign-stringops" unrl +test "$2" "$3" "-mstringop-strategy=unrolled_loop -mno-align-stringops" unrlnoalign +test "$2" "$3" "-mstringop-strategy=vector_loop -malign-stringops" sse +test "$2" "$3" "-mstringop-strategy=vector_loop -mno-align-stringops -msse2" ssenoalign +#test2 "$2" "$3" "" +test "$2" "$3" "-mstringop-strategy=byte_loop" byte +best=`cat /tmp/accum | sort | head -1` +test "$2" "$3" " -fprofile-generate" >/dev/null 2>&1 +test "$2" "$3" " -fprofile-use" +test "$2" "$3" " -minline-stringops-dynamically" +echo " $best" +} + +test_all_sizes() +{ +if [ "$mode" == 64 ] +then +echo " block size libcall rep1 noalg rep4 noalg rep8 noalg loop noalg unrl noalg sse noalg byte PGO dynamic BEST" +else +echo " block size libcall rep1 noalg rep4 noalg loop noalg unrl noalg sse noalg byte PGO dynamic BEST" +fi +#for size in 1 2 3 4 6 8 10 12 14 16 24 32 48 64 128 256 512 1024 4096 8192 81920 819200 8192000 +#for size in 8192000 819200 81920 8192 4096 2048 1024 512 256 128 64 48 32 24 16 14 12 10 8 6 5 4 3 2 1 +for size in 8192000 819200 81920 20480 8192 4096 2048 1024 512 256 128 64 48 32 24 16 14 12 10 8 6 4 1 +#for size in 128 256 1024 4096 8192 81920 819200 +do +testrow "$1" "$2" $size +done +} + +mode=$1 +shift +export memsize=$1 +shift +cmdline=$* +if [ "$mode" != 32 ] +then + if [ "$mode" != 64 ] + then + echo "Usage:" + echo "test_stringop mode size cmdline" + echo "mode is either 32 or 64" + echo "size is amount of memory copied in each test. Should be chosed small enough so runtime is less than minute for each test and sorting works" + echo "Example: test_stringop 32 640000000 ./xgcc -B ./ -march=pentium3" + exit + fi +fi + +echo "memcpy" +export STRINGOP="" +type=char +test_all_sizes $mode "$cmdline -m$mode" +echo "Aligned" +type=long +test_all_sizes $mode "$cmdline -m$mode" +echo "memset" +export STRINGOP="-Dtest_memset=1" +type=char +test_all_sizes $mode "$cmdline -m$mode" +echo "Aligned" +type=long +test_all_sizes $mode "$cmdline -m$mode" diff --git a/contrib/filter-rtags-warnings.py b/contrib/filter-clang-warnings.py index ee27e7c..15cca5f 100755 --- a/contrib/filter-rtags-warnings.py +++ b/contrib/filter-clang-warnings.py @@ -1,7 +1,6 @@ #!/usr/bin/env python3 # -# Script to analyze warnings produced by rtags command (using LLVM): -# rc --diagnose-all --synchronous-diagnostics --json +# Script to analyze warnings produced by clang. # # This file is part of GCC. # @@ -23,26 +22,26 @@ # import sys -import json import argparse -def skip_warning(filename, warning): +def skip_warning(filename, message): ignores = { '': ['-Warray-bounds', '-Wmismatched-tags', 'gcc_gfc: -Wignored-attributes', '-Wchar-subscripts', 'string literal (potentially insecure): -Wformat-security', '-Wdeprecated-register', '-Wvarargs', 'keyword is hidden by macro definition', "but the argument has type 'char *': -Wformat-pedantic", - '-Wnested-anon-types', 'qualifier in explicit instantiation of', 'attribute argument not supported: asm_fprintf'], + '-Wnested-anon-types', 'qualifier in explicit instantiation of', 'attribute argument not supported: asm_fprintf', + 'when in C++ mode, this behavior is deprecated', '-Wignored-attributes', '-Wgnu-zero-variadic-macro-arguments', + '-Wformat-security'], 'insn-modes.c': ['-Wshift-count-overflow'], 'insn-emit.c': ['-Wtautological-compare'], 'insn-attrtab.c': ['-Wparentheses-equality'], 'gimple-match.c': ['-Wunused-', '-Wtautological-compare'], 'generic-match.c': ['-Wunused-', '-Wtautological-compare'], - } - - message = warning['message'] + 'i386.md': ['-Wparentheses-equality', '-Wtautological-compare'], + 'sse.md': ['-Wparentheses-equality', '-Wtautological-compare'], + 'genautomata.c': ['-Wstring-plus-int'] - if warning['type'] == 'fixit': - return True + } for name, ignores in ignores.items(): for i in ignores: @@ -52,20 +51,22 @@ def skip_warning(filename, warning): return False parser = argparse.ArgumentParser() -parser.add_argument('json_file', help = 'Rtags JSON file with diagnostics') -parser.add_argument('-n', '--no-filter', action = 'store_true', help = 'No filter') - +parser.add_argument('log', help = 'Log file with clang warnings') args = parser.parse_args() -data = json.load(open(args.json_file)) -file_warnings = data['checkStyle'] - +lines = [l.strip() for l in open(args.log)] total = 0 -for filename, warnings in file_warnings.items(): - if warnings: - for w in warnings: - if args.no_filter or not skip_warning(filename, w): - total += 1 - print('%s:%d:%d:%s' % (filename, w['line'], w['column'], w['message'])) +messages = [] +for l in lines: + token = ': warning: ' + i = l.find(token) + if i != -1: + location = l[:i] + message = l[i + len(token):] + if not skip_warning(location, message): + total += 1 + messages.append(l) -print('Total: %d' % total) +for l in sorted(messages): + print(l) +print('\nTotal warnings: %d' % total) diff --git a/contrib/mklog b/contrib/mklog index eb765ed..15558cf 100755 --- a/contrib/mklog +++ b/contrib/mklog @@ -1,6 +1,6 @@ -#!/usr/bin/python +#!/usr/bin/env python3 -# Copyright (C) 2017 Free Software Foundation, Inc. +# Copyright (C) 2017-2019 Free Software Foundation, Inc. # # This file is part of GCC. # @@ -67,7 +67,7 @@ class RegexCache(object): cache = RegexCache() def print_help_and_exit(): - print """\ + print("""\ Usage: %s [-i | --inline] [PATCH] Generate ChangeLog template for PATCH. PATCH must be generated using diff(1)'s -up or -cp options @@ -78,7 +78,7 @@ When PATCH is - or missing, read standard input. When -i is used, prepends ChangeLog to PATCH. If PATCH is not stdin, modifies PATCH in-place, otherwise writes to stdout. -""" % me +""" % me) sys.exit(1) def run(cmd, die_on_error): @@ -87,7 +87,7 @@ def run(cmd, die_on_error): (out, err) = proc.communicate() if die_on_error and proc.returncode != 0: error("`%s` failed:\n" % (cmd, proc.stderr)) - return proc.returncode, out, err + return proc.returncode, out.decode(), err def read_user_info(): dot_mklog_format_msg = """\ @@ -100,7 +100,7 @@ EMAIL = ... mklog_conf = os.path.expanduser('~/.mklog') if os.path.exists(mklog_conf): attrs = {} - f = open(mklog_conf, 'rb') + f = open(mklog_conf) for s in f: if cache.match(r'^\s*([a-zA-Z0-9_]+)\s*=\s*(.*?)\s*$', s): attrs[cache.group(1)] = cache.group(2) @@ -153,9 +153,9 @@ class FileDiff: self.clname, self.relname = get_parent_changelog(filename); def dump(self): - print "Diff for %s:\n ChangeLog = %s\n rel name = %s\n" % (self.filename, self.clname, self.relname) + print("Diff for %s:\n ChangeLog = %s\n rel name = %s\n" % (self.filename, self.clname, self.relname)) for i, h in enumerate(self.hunks): - print "Next hunk %d:" % i + print("Next hunk %d:" % i) h.dump() class Hunk: @@ -167,8 +167,8 @@ class Hunk: self.ctx_diff = is_ctx_hunk_start(hdr) def dump(self): - print '%s' % self.hdr - print '%s' % '\n'.join(self.lines) + print('%s' % self.hdr) + print('%s' % '\n'.join(self.lines)) def is_file_addition(self): """Does hunk describe addition of file?""" @@ -358,7 +358,7 @@ def main(): try: opts, args = getopt.getopt(sys.argv[1:], 'hiv', ['help', 'verbose', 'inline']) - except getopt.GetoptError, err: + except getopt.GetoptError as err: error(str(err)) inline = False @@ -380,7 +380,7 @@ def main(): if len(args) == 1 and args[0] == '-': input = sys.stdin elif len(args) == 1: - input = open(args[0], 'rb') + input = open(args[0]) else: error("too many arguments; for more details run with -h") @@ -388,7 +388,7 @@ def main(): diffs = parse_patch(contents) if verbose: - print "Parse results:" + print("Parse results:") for d in diffs: d.dump() @@ -442,14 +442,14 @@ def main(): shutil.copymode(args[0], tmp) # Open the temp file, clearing contents. - out = open(tmp, 'wb') + out = open(tmp, 'w') else: tmp = None out = sys.stdout # Print log date = time.strftime('%Y-%m-%d') - for log_name, msg in sorted(logs.iteritems()): + for log_name, msg in sorted(logs.items()): out.write("""\ %s: |