1#   Copyright (C) 2001-2021 Free Software Foundation, Inc.
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 3 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with GCC; see the file COPYING3.  If not see
15# <http://www.gnu.org/licenses/>.
16
17# Test the functionality of programs compiled with profile-directed block
18# ordering using -fprofile-arcs followed by -fbranch-probabilities.
19
20load_lib target-supports.exp
21
22# Some targets don't have any implementation of __bb_init_func or are
23# missing other needed machinery.
24if { ![check_profiling_available "-fprofile-arcs"] } {
25    return
26}
27
28# The procedures in profopt.exp need these parameters.
29set tool gcc
30set prof_ext "gcda"
31set perf_ext tim
32
33if $tracelevel then {
34    strace $tracelevel
35}
36
37# Load support procs.
38load_lib profopt.exp
39
40# Save and override the default list defined in profopt.exp.
41set bprob_save_profopt_options $PROFOPT_OPTIONS
42set PROFOPT_OPTIONS [list { -O2 } { -O3  }]
43
44set profile_wrapper ""
45set profile_options "-fprofile-arcs"
46set feedback_options "-fbranch-probabilities"
47
48foreach profile_option $profile_options feedback_option $feedback_options {
49    foreach src [lsort [glob -nocomplain $srcdir/$subdir/bprob-*.c]] {
50        # If we're only testing specific files and this isn't one of them, skip it.
51        if ![runtest_file_p $runtests $src] then {
52            continue
53        }
54        profopt-execute $src
55    }
56}
57
58foreach src [lsort [glob -nocomplain $srcdir/$subdir/bprob-*.c]] {
59    if ![runtest_file_p $runtests $src] then {
60        continue
61    }
62    auto-profopt-execute $src
63}
64set PROFOPT_OPTIONS $bprob_save_profopt_options
65