[compiler-rt] [PGO][test] Enable continuous mode PGO tests on AIX (PR #115987)
Wael Yehia via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 13 09:57:29 PST 2024
https://github.com/w2yehia updated https://github.com/llvm/llvm-project/pull/115987
>From 96d041129dd184449a3c76085b700ccf4e862a0e Mon Sep 17 00:00:00 2001
From: Wael Yehia <wyehia at ca.ibm.com>
Date: Tue, 12 Nov 2024 16:03:30 -0500
Subject: [PATCH 1/2] [PGO][test] Enable continuous mode PGO tests on AIX
---
.../test/profile/ContinuousSyncMode/basic.c | 6 +++---
.../profile/ContinuousSyncMode/get-filename.c | 4 ++--
.../ContinuousSyncMode/image-with-mcdc.c | 4 ++--
.../ContinuousSyncMode/image-with-no-counters.c | 6 +++---
.../profile/ContinuousSyncMode/online-merging.c | 8 ++++----
.../ContinuousSyncMode/pid-substitution.c | 4 ++--
.../ContinuousSyncMode/reset-default-profile.c | 2 +-
.../profile/ContinuousSyncMode/set-filename.c | 4 ++--
compiler-rt/test/profile/lit.cfg.py | 17 +++++++++++++++++
9 files changed, 36 insertions(+), 19 deletions(-)
diff --git a/compiler-rt/test/profile/ContinuousSyncMode/basic.c b/compiler-rt/test/profile/ContinuousSyncMode/basic.c
index 142a47a71ad8ac..39ee15fcd0214c 100644
--- a/compiler-rt/test/profile/ContinuousSyncMode/basic.c
+++ b/compiler-rt/test/profile/ContinuousSyncMode/basic.c
@@ -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:
diff --git a/compiler-rt/test/profile/ContinuousSyncMode/get-filename.c b/compiler-rt/test/profile/ContinuousSyncMode/get-filename.c
index d70e11991e180a..40a0cc5ffd6886 100644
--- a/compiler-rt/test/profile/ContinuousSyncMode/get-filename.c
+++ b/compiler-rt/test/profile/ContinuousSyncMode/get-filename.c
@@ -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
diff --git a/compiler-rt/test/profile/ContinuousSyncMode/image-with-mcdc.c b/compiler-rt/test/profile/ContinuousSyncMode/image-with-mcdc.c
index d2afe7048f37f4..d171badbf4d332 100644
--- a/compiler-rt/test/profile/ContinuousSyncMode/image-with-mcdc.c
+++ b/compiler-rt/test/profile/ContinuousSyncMode/image-with-mcdc.c
@@ -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
diff --git a/compiler-rt/test/profile/ContinuousSyncMode/image-with-no-counters.c b/compiler-rt/test/profile/ContinuousSyncMode/image-with-no-counters.c
index f30e2255b2289b..4313ad30b7273f 100644
--- a/compiler-rt/test/profile/ContinuousSyncMode/image-with-no-counters.c
+++ b/compiler-rt/test/profile/ContinuousSyncMode/image-with-no-counters.c
@@ -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
// 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
diff --git a/compiler-rt/test/profile/ContinuousSyncMode/online-merging.c b/compiler-rt/test/profile/ContinuousSyncMode/online-merging.c
index b3c33f339713c2..35b0cd0b05d1f7 100644
--- a/compiler-rt/test/profile/ContinuousSyncMode/online-merging.c
+++ b/compiler-rt/test/profile/ContinuousSyncMode/online-merging.c
@@ -1,4 +1,4 @@
-// REQUIRES: darwin
+// REQUIRES: target={{.*(darwin|aix).*}}
// Test the online merging mode (%m) along with continuous mode (%c).
//
@@ -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.
diff --git a/compiler-rt/test/profile/ContinuousSyncMode/pid-substitution.c b/compiler-rt/test/profile/ContinuousSyncMode/pid-substitution.c
index b2b95f41f2bdf2..309b685a95c5bc 100644
--- a/compiler-rt/test/profile/ContinuousSyncMode/pid-substitution.c
+++ b/compiler-rt/test/profile/ContinuousSyncMode/pid-substitution.c
@@ -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
diff --git a/compiler-rt/test/profile/ContinuousSyncMode/reset-default-profile.c b/compiler-rt/test/profile/ContinuousSyncMode/reset-default-profile.c
index 75af7684161c9b..fb35d77c434280 100644
--- a/compiler-rt/test/profile/ContinuousSyncMode/reset-default-profile.c
+++ b/compiler-rt/test/profile/ContinuousSyncMode/reset-default-profile.c
@@ -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.
diff --git a/compiler-rt/test/profile/ContinuousSyncMode/set-filename.c b/compiler-rt/test/profile/ContinuousSyncMode/set-filename.c
index e6d5fd31ab1b60..106e12e4e3b6eb 100644
--- a/compiler-rt/test/profile/ContinuousSyncMode/set-filename.c
+++ b/compiler-rt/test/profile/ContinuousSyncMode/set-filename.c
@@ -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>
diff --git a/compiler-rt/test/profile/lit.cfg.py b/compiler-rt/test/profile/lit.cfg.py
index bb5e28d87bb0f9..d37a9f62fa32bf 100644
--- a/compiler-rt/test/profile/lit.cfg.py
+++ b/compiler-rt/test/profile/lit.cfg.py
@@ -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:
@@ -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",
@@ -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)
>From 185013d86477822607431dc5da67d450b5e2b0d4 Mon Sep 17 00:00:00 2001
From: Wael Yehia <wyehia at ca.ibm.com>
Date: Wed, 13 Nov 2024 18:07:47 +0000
Subject: [PATCH 2/2] code review
---
compiler-rt/test/profile/lit.cfg.py | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/compiler-rt/test/profile/lit.cfg.py b/compiler-rt/test/profile/lit.cfg.py
index d37a9f62fa32bf..92ca2644e030e2 100644
--- a/compiler-rt/test/profile/lit.cfg.py
+++ b/compiler-rt/test/profile/lit.cfg.py
@@ -97,6 +97,10 @@ def exclude_unsupported_files_for_aix(dirname):
config.substitutions.append(
("%clang_profgen=", build_invocation(clang_cflags) + " -fprofile-instr-generate=")
)
+config.substitutions.append(
+ ("%clang_profgen_cont ", build_invocation(clang_cflags) + " -fprofile-instr-generate " +
+ ("-mllvm -runtime-counter-relocation " if runtime_reloc else ""))
+)
config.substitutions.append(
(
"%clangxx_profgen ",
@@ -116,6 +120,10 @@ def exclude_unsupported_files_for_aix(dirname):
config.substitutions.append(
("%clang_pgogen=", build_invocation(clang_cflags) + " -fprofile-generate=")
)
+config.substitutions.append(
+ ("%clang_pgogen_cont ", build_invocation(clang_cflags) + " -fprofile-generate " +
+ ("-mllvm -runtime-counter-relocation " if runtime_reloc else ""))
+)
config.substitutions.append(
("%clangxx_pgogen ", build_invocation(clang_cxxflags) + " -fprofile-generate ")
)
@@ -157,16 +165,6 @@ 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",
More information about the llvm-commits
mailing list