Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions compiler-rt/test/profile/ContinuousSyncMode/basic.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// REQUIRES: darwin
// REQUIRES: target={{.*(darwin|aix).*}}

// RUN: %clang -fprofile-instr-generate -fcoverage-mapping -o %t.exe %s
// RUN: %clang_profgen_cont -fcoverage-mapping -o %t.exe %s
// RUN: echo "garbage" > %t.profraw
// RUN: env LLVM_PROFILE_FILE="%c%t.profraw" %run %t.exe
// RUN: llvm-profdata show --counts --all-functions %t.profraw | FileCheck %s -check-prefix=CHECK-COUNTS
// RUN: llvm-profdata merge -o %t.profdata %t.profraw
// RUN: llvm-cov report %t.exe -instr-profile %t.profdata | FileCheck %s -check-prefix=CHECK-COVERAGE
// RUN: %if !target={{.*aix.*}} %{ llvm-cov report %t.exe -instr-profile %t.profdata | FileCheck %s -check-prefix=CHECK-COVERAGE %}

// CHECK-COUNTS: Counters:
// CHECK-COUNTS-NEXT: main:
Expand Down
4 changes: 2 additions & 2 deletions compiler-rt/test/profile/ContinuousSyncMode/get-filename.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// REQUIRES: darwin
// REQUIRES: target={{.*(darwin|aix).*}}

// RUN: %clang_pgogen -o %t.exe %s
// RUN: %clang_pgogen_cont -o %t.exe %s
// RUN: env LLVM_PROFILE_FILE="%c%t.profraw" %run %t.exe %t.profraw
// RUN: env LLVM_PROFILE_FILE="%t%c.profraw" %run %t.exe %t.profraw
// RUN: env LLVM_PROFILE_FILE="%t.profraw%c" %run %t.exe %t.profraw
Expand Down
4 changes: 2 additions & 2 deletions compiler-rt/test/profile/ContinuousSyncMode/image-with-mcdc.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// REQUIRES: darwin
// REQUIRES: target={{.*(darwin|aix).*}}

// RUN: %clang_profgen -fcoverage-mapping -fcoverage-mcdc -O3 -o %t.exe %s
// RUN: %clang_profgen_cont -fcoverage-mapping -fcoverage-mcdc -O3 -o %t.exe %s
// RUN: env LLVM_PROFILE_FILE="%c%t.profraw" %run %t.exe 3 3
// RUN: llvm-profdata show --text --all-functions %t.profraw | FileCheck %s

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// REQUIRES: darwin
// REQUIRES: target={{.*(darwin|aix).*}}

// RUN: echo "static void dead_code(void) {}" > %t.dso.c
// RUN: %clang_profgen -fcoverage-mapping -O3 -dynamiclib -o %t.dso.dylib %t.dso.c
// RUN: %clang_profgen -fcoverage-mapping -O3 -o %t.exe %s %t.dso.dylib
// RUN: %clang_profgen_cont -fcoverage-mapping -O3 %shared_lib_flag -o %t.dso.dylib %t.dso.c
// RUN: %clang_profgen_cont -fcoverage-mapping -O3 -o %t.exe %s %t.dso.dylib
Comment on lines +4 to +5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried enabling this on Linux but couldn't. As far as I investigated, looks like bias var has a few issues. Does this really work on AIX?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it passes on AIX according to the latest buildbot, (check-all output)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Let me know if you met any issues re. bias var.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what problem are you encountering on linux with this testcase?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bias is not emitted if no instrumentations are emitted. libprofile complains if no bias var is found with continuous mode at runtime.

d2f77eb#diff-71a5c7472b215c25675c554f2ee1f3bbc84f29aa47ba2d30543246ad79aeffc0R654-R657

Copy link
Contributor Author

@w2yehia w2yehia Dec 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Yes, the test is passing by accident on AIX: the dynamic library is not being linked in (because it has no reachable code).

If I add reachable code and compile without PGO but link in the PGO library, then I get, at runtime, the following
LLVM Profile Error: Neither __llvm_profile_counter_bias nor __llvm_profile_bitmap_bias is defined

// RUN: env LLVM_PROFILE_FILE="%c%t.profraw" %run %t.exe 2>&1 | count 0
// RUN: llvm-profdata show --counts --all-functions %t.profraw | FileCheck %s

Expand Down
8 changes: 4 additions & 4 deletions compiler-rt/test/profile/ContinuousSyncMode/online-merging.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// REQUIRES: darwin
// REQUIRES: target={{.*(darwin|aix).*}}

// Test the online merging mode (%m) along with continuous mode (%c).
//
Expand All @@ -8,9 +8,9 @@
// Create two DSOs and a driver program that uses them.
// RUN: echo "void dso1(void) {}" > dso1.c
// RUN: echo "void dso2(void) {}" > dso2.c
// RUN: %clang_pgogen -dynamiclib -o %t.dir/dso1.dylib dso1.c -mllvm -instrprof-atomic-counter-update-all=1
// RUN: %clang_pgogen -dynamiclib -o %t.dir/dso2.dylib dso2.c -mllvm -instrprof-atomic-counter-update-all=1
// RUN: %clang_pgogen -o main.exe %s %t.dir/dso1.dylib %t.dir/dso2.dylib -mllvm -instrprof-atomic-counter-update-all=1
// RUN: %clang_pgogen_cont %shared_lib_flag -o %t.dir/dso1.dylib dso1.c -mllvm -instrprof-atomic-counter-update-all=1
// RUN: %clang_pgogen_cont %shared_lib_flag -o %t.dir/dso2.dylib dso2.c -mllvm -instrprof-atomic-counter-update-all=1
// RUN: %clang_pgogen_cont -o main.exe %s %t.dir/dso1.dylib %t.dir/dso2.dylib -mllvm -instrprof-atomic-counter-update-all=1
//
// === Round 1 ===
// Test merging+continuous mode without any file contention.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// REQUIRES: darwin
// REQUIRES: target={{.*(darwin|aix).*}}

// RUN: rm -rf %t.dir && mkdir -p %t.dir
// RUN: %clang_pgogen -o %t.exe %s
// RUN: %clang_pgogen_cont -o %t.exe %s
//
// Note: %%p is needed here, not %p, because of lit's path substitution.
// RUN: env LLVM_PROFILE_FILE="%t.dir/%c-%%p" %run %t.exe
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// REQUIRES: darwin || linux
// REQUIRES: target={{.*(darwin|linux|aix).*}}

// Test when LLVM_PROFILE_FILE is set incorrectly, it should fall backs to use default.profraw without runtime error.

Expand Down
4 changes: 2 additions & 2 deletions compiler-rt/test/profile/ContinuousSyncMode/set-filename.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// REQUIRES: darwin
// REQUIRES: target={{.*(darwin|aix).*}}

// RUN: %clang_pgogen -o %t.exe %s
// RUN: %clang_pgogen_cont -o %t.exe %s
// RUN: env LLVM_PROFILE_FILE="%c%t.profraw" %run %t.exe %t.profraw %t.bad

#include <string.h>
Expand Down
17 changes: 17 additions & 0 deletions compiler-rt/test/profile/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ def get_required_attr(config, attr_name):

target_is_msvc = bool(re.match(r".*-windows-msvc$", config.target_triple))

# Whether continous profile collection (%c) requires runtime counter relocation on this platform
runtime_reloc = bool(config.host_os in ["AIX"])

if config.host_os in ["Linux"]:
extra_link_flags = ["-ldl"]
elif target_is_msvc:
Expand Down Expand Up @@ -154,6 +157,16 @@ def exclude_unsupported_files_for_aix(dirname):
)
)

config.substitutions.append(
("%clang_profgen_cont", build_invocation(clang_cflags) + " -fprofile-instr-generate " +
("-mllvm -runtime-counter-relocation" if runtime_reloc else ""))
)

config.substitutions.append(
("%clang_pgogen_cont", build_invocation(clang_cflags) + " -fprofile-generate " +
("-mllvm -runtime-counter-relocation" if runtime_reloc else ""))
)

if config.host_os not in [
"Windows",
"Darwin",
Expand All @@ -166,6 +179,10 @@ def exclude_unsupported_files_for_aix(dirname):
]:
config.unsupported = True

config.substitutions.append(
("%shared_lib_flag", "-dynamiclib" if (config.host_os == "Darwin") else "-shared")
)

if config.host_os in ["AIX"]:
config.available_features.add("system-aix")
exclude_unsupported_files_for_aix(config.test_source_root)
Expand Down
Loading