Files
TheRock/compiler/amd-llvm/compiler-rt/test/profile/Posix/gcov-shared-flush.c
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

120 lines
4.0 KiB
C

/// This test fails on Mac (https://bugs.llvm.org/show_bug.cgi?id=38134)
// XFAIL: darwin
// RUN: mkdir -p %t.d && cd %t.d
// RUN: %clang -E -DSHARED %s -o shared.c -dumpdir ./
// RUN: %clang --coverage -fPIC -shared shared.c -o libfunc.so -dumpdir ./
// RUN: test -f shared.gcno
/// Test the case where we exit abruptly after calling __gcov_dump, which means we don't write out the counters at exit.
// RUN: %clang -DEXIT_ABRUPTLY -DSHARED_CALL_BEFORE_FLUSH -DSHARED_CALL_AFTER_FLUSH --coverage %s -L%t.d -rpath %t.d -lfunc -o %t -dumpdir ./
// RUN: test -f gcov-shared-flush.gcno
// RUN: rm -f gcov-shared-flush.gcda shared.gcda
// RUN: %run %t
// RUN: llvm-cov gcov -t gcov-shared-flush.gcda | FileCheck %s --check-prefix=NO_WRITEOUT
// RUN: llvm-cov gcov -t shared.gcda | FileCheck %s --check-prefix=SHARED
// NO_WRITEOUT: -: [[#%u,L:]]:#ifdef EXIT_ABRUPTLY
// NO_WRITEOUT-NEXT: 1: [[#%u,L+1]]: _exit(0);
// SHARED: 1: {{[[0-9]+}}:void foo(int n)
/// Test the case where we exit normally and we have a call to the shared library function before __gcov_dump.
// RUN: %clang -DSHARED_CALL_BEFORE_FLUSH --coverage %s -L%t.d -rpath %t.d -lfunc -o %t -dumpdir ./
// RUN: test -f gcov-shared-flush.gcno
// RUN: rm -f gcov-shared-flush.gcda shared.gcda
// RUN: %run %t
// RUN: llvm-cov gcov -t gcov-shared-flush.gcda | FileCheck %s --check-prefix=BEFORE
// RUN: llvm-cov gcov -t shared.gcda | FileCheck %s --check-prefix=SHARED_ONCE
// BEFORE: -: {{[0-9]+}}:#ifdef SHARED_CALL_BEFORE_FLUSH
// BEFORE-NEXT: 1: {{[0-9]+}}: foo(1);
// BEFORE: 1: {{[0-9]+}}: __gcov_dump();
// BEFORE-NEXT: 1: {{[0-9]+}}: __gcov_reset();
// BEFORE: -: {{[0-9]+}}:#ifdef SHARED_CALL_AFTER_FLUSH
// BEFORE-NEXT: -: {{[0-9]+}}: foo(1);
// BEFORE: 1: {{[0-9]+}}: bar(5);
// SHARED_ONCE: 1: {{[0-9]+}}:void foo(int n)
// # Test the case where we exit normally and we have a call to the shared library function after __gcov_dump.
// RUN: %clang -DSHARED_CALL_AFTER_FLUSH --coverage %s -L%t.d -rpath %t.d -lfunc -o %t -dumpdir ./
// RUN: test -f gcov-shared-flush.gcno
// RUN: rm -f gcov-shared-flush.gcda shared.gcda
// RUN: %run %t
// RUN: llvm-cov gcov -t gcov-shared-flush.gcda | FileCheck %s --check-prefix=AFTER
// RUN: llvm-cov gcov -t shared.gcda > 2s.txt
// AFTER: -: {{[0-9]+}}:#ifdef SHARED_CALL_BEFORE_FLUSH
// AFTER-NEXT: -: {{[0-9]+}}: foo(1);
// AFTER: 1: {{[0-9]+}}: __gcov_dump();
// AFTER-NEXT: 1: {{[0-9]+}}: __gcov_reset();
// AFTER: -: {{[0-9]+}}:#ifdef SHARED_CALL_AFTER_FLUSH
// AFTER-NEXT: 1: {{[0-9]+}}: foo(1);
// AFTER: 1: {{[0-9]+}}: bar(5);
// # Test the case where we exit normally and we have calls to the shared library function before and after __gcov_dump.
// RUN: %clang -DSHARED_CALL_BEFORE_FLUSH -DSHARED_CALL_AFTER_FLUSH --coverage %s -L%t.d -rpath %t.d -lfunc -o %t -dumpdir ./
// RUN: test -f gcov-shared-flush.gcno
// RUN: rm -f gcov-shared-flush.gcda shared.gcda
// RUN: %run %t
// RUN: llvm-cov gcov -t gcov-shared-flush.gcda | FileCheck %s --check-prefix=BEFORE_AFTER
// RUN: llvm-cov gcov -t shared.gcda | FileCheck %s --check-prefix=SHARED_TWICE
// BEFORE_AFTER: -: {{[0-9]+}}:#ifdef SHARED_CALL_BEFORE_FLUSH
// BEFORE_AFTER-NEXT: 1: {{[0-9]+}}: foo(1);
// BEFORE_AFTER: 1: {{[0-9]+}}: __gcov_dump();
// BEFORE_AFTER-NEXT: 1: {{[0-9]+}}: __gcov_reset();
// BEFORE_AFTER: -: {{[0-9]+}}:#ifdef SHARED_CALL_AFTER_FLUSH
// BEFORE_AFTER-NEXT: 1: {{[0-9]+}}: foo(1);
// BEFORE_AFTER: 1: {{[0-9]+}}: bar(5);
// SHARED_TWICE: 2: {{[0-9]+}}:void foo(int n)
#ifdef SHARED
void foo(int n) {
}
#else
extern void foo(int n);
extern void __gcov_dump(void);
extern void __gcov_reset(void);
extern void _exit(int) __attribute__((noreturn));
int bar1 = 0;
int bar2 = 1;
void bar(int n) {
if (n % 5 == 0)
bar1++;
else
bar2++;
}
int main(int argc, char *argv[]) {
#ifdef SHARED_CALL_BEFORE_FLUSH
foo(1);
#endif
bar(5);
__gcov_dump();
__gcov_reset();
bar(5);
#ifdef SHARED_CALL_AFTER_FLUSH
foo(1);
#endif
#ifdef EXIT_ABRUPTLY
_exit(0);
#endif
bar(5);
return 0;
}
#endif