]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
feat: Add -fprofile-update support (#1408)
authorRaihaan Shouhell <raihaanhimself@gmail.com>
Sat, 2 Mar 2024 08:37:14 +0000 (16:37 +0800)
committerGitHub <noreply@github.com>
Sat, 2 Mar 2024 08:37:14 +0000 (09:37 +0100)
src/argprocessing.cpp
test/suites/profiling_clang.bash
test/suites/profiling_gcc.bash

index 3066ff37e1421dd836811284fa6e7f53204ae81a..0a156a6837b736f8b18a04b024eea02b2c1b462c 100644 (file)
@@ -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;
 
index a6ac5c972b9933a7838e1a9dac01bf9f96da73f9..1f848f7e371789750e809faa2e288c6e423e6feb 100644 (file)
@@ -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
 }
index f83aeaf1ab59f5f73a26e0c3eebbbcf48f30b404..89f901377f0f783c562a96d65f523e49eb0893ef 100644 (file)
@@ -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
+
+    # -------------------------------------------------------------------------
 }