cfgrtl: Fix MEM_EXPR update in duplicate_insn_chain [PR114924]
[official-gcc.git] / contrib / analyze_brprob_spec.py
blobb8af7b9e6a57db19adecbbb9c47ee97bc3780b4f
1 #!/usr/bin/env python3
3 # Copyright (C) 2016-2024 Free Software Foundation, Inc.
5 # This file is part of GCC.
7 # GCC is free software; you can redistribute it and/or modify it under
8 # the terms of the GNU General Public License as published by the Free
9 # Software Foundation; either version 3, or (at your option) any later
10 # version.
12 # GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 # for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with GCC; see the file COPYING3. If not see
19 # <http://www.gnu.org/licenses/>.
21 import sys
22 import os
23 import subprocess
24 import tempfile
25 import argparse
27 script_location = os.path.realpath(__file__)
29 parser = argparse.ArgumentParser()
30 parser.add_argument('location', metavar = 'dump_file',
31 help = 'Sub-folder with SPEC benchmarks (e.g. Programming/cpu2017/benchspec/CPU)')
32 parser.add_argument('-s', '--sorting', dest = 'sorting',
33 choices = ['branches', 'branch-hitrate', 'hitrate', 'coverage', 'name'],
34 default = 'branches')
35 parser.add_argument('-d', '--def-file', help = 'path to predict.def')
36 parser.add_argument('-v', '--verbose', action = 'store_true', help = 'Print verbose informations')
38 args = parser.parse_args()
40 benchmarks = os.listdir(args.location)
42 for b in sorted(benchmarks):
43 dumps = []
44 for root, dirs, files in os.walk(os.path.join(args.location, b)):
45 for x in files:
46 if x.endswith('.profile'):
47 dumps.append(os.path.join(root, x))
49 if len(dumps) == 0:
50 continue
52 temp = tempfile.NamedTemporaryFile(delete = False)
53 for d in dumps:
54 temp.write(open(d, 'rb').read())
56 temp.close()
58 print()
59 print(f' {b} '.center(160, '='))
60 sys.stdout.flush()
61 p = [os.path.join(os.path.dirname(script_location), 'analyze_brprob.py'),
62 temp.name, '--sorting', args.sorting]
63 if args.def_file:
64 p += ['-d', args.def_file]
65 if args.verbose:
66 p.append('-v')
68 p = subprocess.check_call(p)
69 sys.stdout.flush()
71 os.remove(temp.name)