Commit c43c5112 by Andi Kleen Committed by Andi Kleen

Make autofdo tests safer for parallel builds

There were some reports that the autofdo tests are non deterministic
with parallel builds. I wasn't able to reproduce this, but here are
two changes that may help:

- Always use unique file names for temporary files.
- Don't print file names in the test log because the directories
can vary (suggested by Jeff Law)

gcc/testsuite/:

2016-08-08  Andi Kleen  <ak@linux.intel.com>

	* lib/profopt.exp: (auto-profopt-execute): Don't include full
	test command line in failure log.
	(profopt-execute): dito. Make autofdo file names unique.

From-SVN: r239265
parent 5e1a1c97
2016-08-08 Andi Kleen <ak@linux.intel.com>
* lib/profopt.exp: (auto-profopt-execute): Don't include full
test command line in failure log.
(profopt-execute): dito. Make autofdo file names unique.
2016-08-08 David Malcolm <dmalcolm@redhat.com> 2016-08-08 David Malcolm <dmalcolm@redhat.com>
PR c/64955 PR c/64955
......
...@@ -283,7 +283,7 @@ proc auto-profopt-execute { src } { ...@@ -283,7 +283,7 @@ proc auto-profopt-execute { src } {
if { ! [check_profiling_available "-fauto-profile"] } { if { ! [check_profiling_available "-fauto-profile"] } {
regsub "(?q)$srcdir/" $src "" testcase regsub "(?q)$srcdir/" $src "" testcase
unsupported "$testcase" unsupported "$src -fauto-profile"
return return
} }
set profile_wrapper [profopt-perf-wrapper] set profile_wrapper [profopt-perf-wrapper]
...@@ -388,7 +388,7 @@ proc profopt-execute { src } { ...@@ -388,7 +388,7 @@ proc profopt-execute { src } {
# valid, by running it after dg-additional-files-options. # valid, by running it after dg-additional-files-options.
foreach ext $prof_ext { foreach ext $prof_ext {
profopt-target-cleanup $tmpdir $base $ext profopt-target-cleanup $tmpdir $base $ext
profopt-target-cleanup $tmpdir perf data profopt-target-cleanup $tmpdir $base "perf.data"
} }
# Tree profiling requires TLS runtime support, which may need # Tree profiling requires TLS runtime support, which may need
...@@ -417,8 +417,8 @@ proc profopt-execute { src } { ...@@ -417,8 +417,8 @@ proc profopt-execute { src } {
} }
set orig_ld_library_path "[getenv LD_LIBRARY_PATH]" set orig_ld_library_path "[getenv LD_LIBRARY_PATH]"
setenv LD_LIBRARY_PATH "$ld_library_path:$orig_ld_library_path" setenv LD_LIBRARY_PATH "$ld_library_path:$orig_ld_library_path"
verbose -log "Running $profile_wrapper $execname1" verbose -log "Running $profile_wrapper -o $tmpdir/$base.perf.data $execname1"
set id [remote_spawn "" "$profile_wrapper $execname1" "readonly"] set id [remote_spawn "" "$profile_wrapper -o $tmpdir/$base.perf.data $execname1" "readonly"]
setenv LD_LIBRARY_PATH $orig_ld_library_path setenv LD_LIBRARY_PATH $orig_ld_library_path
if { $id < 0 } { if { $id < 0 } {
warning "Failed to run profiler" warning "Failed to run profiler"
...@@ -439,15 +439,17 @@ proc profopt-execute { src } { ...@@ -439,15 +439,17 @@ proc profopt-execute { src } {
} }
set missing_file 0 set missing_file 0
set bprefix ""
# Make sure the profile data was generated, and fail if not. # Make sure the profile data was generated, and fail if not.
if { $status == "pass" } { if { $status == "pass" } {
# convert profile # convert profile
if { $run_autofdo == 1 } { if { $run_autofdo == 1 } {
set cmd "create_gcov --binary $execname1 --profile=perf.data -gcov_version=1 --gcov=$tmpdir/$base.$ext" set bprefix "afdo."
set cmd "create_gcov --binary $execname1 --profile=$tmpdir/$base.perf.data -gcov_version=1 --gcov=$tmpdir/$bprefix$base.$ext"
verbose "Running $cmd" verbose "Running $cmd"
set id [remote_spawn "" $cmd] set id [remote_spawn "" $cmd]
if { $id < 0 } { if { $id < 0 } {
unsupported "$testcase: Cannot run $cmd" unsupported "$src -fauto-profile: cannot run create_gcov"
set status "fail" set status "fail"
return return
} }
...@@ -456,12 +458,12 @@ proc profopt-execute { src } { ...@@ -456,12 +458,12 @@ proc profopt-execute { src } {
} }
foreach ext $prof_ext { foreach ext $prof_ext {
remote_upload target $tmpdir/$base.$ext remote_upload target $tmpdir/$bprefix$base.$ext
set files [glob -nocomplain $base.$ext] set files [glob -nocomplain $bprefix$base.$ext]
if { $files == "" } { if { $files == "" } {
set status "fail" set status "fail"
set missing_file 1 set missing_file 1
fail "$testcase execution: file $base.$ext does not exist, $option $profile_option" fail "$testcase execution: file $bprefix$base.$ext does not exist, $option $profile_option"
} }
} }
} }
...@@ -490,7 +492,7 @@ proc profopt-execute { src } { ...@@ -490,7 +492,7 @@ proc profopt-execute { src } {
lappend options "additional_flags=$option $extra_flags $feedback_option" lappend options "additional_flags=$option $extra_flags $feedback_option"
set optstr "$option $feedback_option" set optstr "$option $feedback_option"
if { [string first "-fauto-profile" $options] >= 0} { if { [string first "-fauto-profile" $options] >= 0} {
set options [regsub -- "-fauto-profile" $options "-fauto-profile=$tmpdir/$base.$ext"] set options [regsub -- "-fauto-profile" $options "-fauto-profile=$tmpdir/$bprefix$base.$ext"]
} }
set comp_output [${tool}_target_compile "$src" "$execname2" "executable" $options] set comp_output [${tool}_target_compile "$src" "$execname2" "executable" $options]
...@@ -516,8 +518,8 @@ proc profopt-execute { src } { ...@@ -516,8 +518,8 @@ proc profopt-execute { src } {
# Remove the profiling data files. # Remove the profiling data files.
foreach ext $prof_ext { foreach ext $prof_ext {
profopt-target-cleanup $tmpdir $base $ext profopt-target-cleanup $tmpdir "$bprefix$base" $ext
profopt-target-cleanup $tmpdir perf data profopt-target-cleanup $tmpdir $base "perf.data"
profopt-target-cleanup $tmpdir $base "gcda.imports" profopt-target-cleanup $tmpdir $base "gcda.imports"
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment