From: Raihaan Shouhell Date: Sat, 2 Mar 2024 08:37:14 +0000 (+0800) Subject: feat: Add -fprofile-update support (#1408) X-Git-Tag: v4.10~84 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4cb66a6a355e07d9ecf5322f048b934ceaae898f;p=thirdparty%2Fccache.git feat: Add -fprofile-update support (#1408) --- diff --git a/src/argprocessing.cpp b/src/argprocessing.cpp index 3066ff37..0a156a68 100644 --- a/src/argprocessing.cpp +++ b/src/argprocessing.cpp @@ -238,6 +238,10 @@ process_profiling_option(const Context& ctx, return true; } + if (util::starts_with(arg, "-fprofile-update")) { + return true; + } + std::string new_profile_path; bool new_profile_use = false; diff --git a/test/suites/profiling_clang.bash b/test/suites/profiling_clang.bash index a6ac5c97..1f848f7e 100644 --- a/test/suites/profiling_clang.bash +++ b/test/suites/profiling_clang.bash @@ -131,4 +131,50 @@ SUITE_profiling_clang() { $CCACHE_COMPILE -fprofile-sample-use=sample.prof -c test.c expect_stat direct_cache_hit 3 expect_stat cache_miss 3 + + # ------------------------------------------------------------------------- + TEST "-fprofile-update=single" + + if $COMPILER -fprofile-update=single -fprofile-generate -c test.c 2>/dev/null; then + + $CCACHE_COMPILE -fprofile-update=single -fprofile-generate -c test.c + expect_stat direct_cache_hit 0 + expect_stat cache_miss 1 + + $COMPILER -fprofile-generate -fprofile-update=single test.o -o test + + ./test + + $CCACHE_COMPILE -fprofile-update=single -fprofile-generate -c test.c + expect_stat direct_cache_hit 1 + expect_stat cache_miss 1 + + $CCACHE_COMPILE -fprofile-use -c test.c + expect_stat direct_cache_hit 1 + expect_stat cache_miss 2 + fi + + # ------------------------------------------------------------------------- + TEST "-fprofile-update=atomic" + + if $COMPILER -fprofile-update=atomic -fprofile-generate -c test.c 2>/dev/null; then + + $CCACHE_COMPILE -fprofile-update=atomic -fprofile-generate -c test.c + expect_stat direct_cache_hit 0 + expect_stat cache_miss 1 + + $COMPILER -fprofile-generate -fprofile-update=atomic test.o -o test + + ./test + + $CCACHE_COMPILE -fprofile-update=atomic -fprofile-generate -c test.c + expect_stat direct_cache_hit 1 + expect_stat cache_miss 1 + + $CCACHE_COMPILE -fprofile-use -c test.c + expect_stat direct_cache_hit 1 + expect_stat cache_miss 2 + + # ------------------------------------------------------------------------- + fi } diff --git a/test/suites/profiling_gcc.bash b/test/suites/profiling_gcc.bash index f83aeaf1..89f90137 100644 --- a/test/suites/profiling_gcc.bash +++ b/test/suites/profiling_gcc.bash @@ -163,4 +163,45 @@ SUITE_profiling_gcc() { expect_stat direct_cache_hit 4 expect_stat cache_miss 3 fi + + # ------------------------------------------------------------------------- + TEST "-fprofile-update=single" + + $CCACHE_COMPILE -fprofile-update=single -fprofile-generate -c test.c + expect_stat direct_cache_hit 0 + expect_stat cache_miss 1 + + $COMPILER -fprofile-generate -fprofile-update=single test.o -o test + + ./test + + $CCACHE_COMPILE -fprofile-update=single -fprofile-generate -c test.c + expect_stat direct_cache_hit 1 + expect_stat cache_miss 1 + + $CCACHE_COMPILE -fprofile-use -c test.c + expect_stat direct_cache_hit 1 + expect_stat cache_miss 2 + + # ------------------------------------------------------------------------- + + TEST "-fprofile-update=atomic" + + $CCACHE_COMPILE -fprofile-update=atomic -fprofile-generate -c test.c + expect_stat direct_cache_hit 0 + expect_stat cache_miss 1 + + $COMPILER -fprofile-generate -fprofile-update=atomic test.o -o test + + ./test + + $CCACHE_COMPILE -fprofile-update=atomic -fprofile-generate -c test.c + expect_stat direct_cache_hit 1 + expect_stat cache_miss 1 + + $CCACHE_COMPILE -fprofile-use -c test.c + expect_stat direct_cache_hit 1 + expect_stat cache_miss 2 + + # ------------------------------------------------------------------------- }