[compiler-rt] 666accf - [compiler-rt][profile] Enable profile tests for AIX

Jinsong Ji via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 12 20:00:43 PDT 2021


Author: Jinsong Ji
Date: 2021-10-13T03:00:32Z
New Revision: 666accf283311c5110ae4e2e5e4c4b99078eed15

URL: https://github.com/llvm/llvm-project/commit/666accf283311c5110ae4e2e5e4c4b99078eed15
DIFF: https://github.com/llvm/llvm-project/commit/666accf283311c5110ae4e2e5e4c4b99078eed15.diff

LOG: [compiler-rt][profile] Enable profile tests for AIX

This patch enable profile test for supported options on AIX.

Reviewed By: w2yehia

Differential Revision: https://reviews.llvm.org/D110945

Added: 
    

Modified: 
    compiler-rt/test/profile/instrprof-set-dir-mode.c
    compiler-rt/test/profile/instrprof-set-file-object-merging.c
    compiler-rt/test/profile/instrprof-set-file-object.c
    compiler-rt/test/profile/lit.cfg.py

Removed: 
    


################################################################################
diff  --git a/compiler-rt/test/profile/instrprof-set-dir-mode.c b/compiler-rt/test/profile/instrprof-set-dir-mode.c
index 6bb8847ccd3d3..07c714724b883 100644
--- a/compiler-rt/test/profile/instrprof-set-dir-mode.c
+++ b/compiler-rt/test/profile/instrprof-set-dir-mode.c
@@ -33,7 +33,8 @@ static int test(unsigned Mode, const char *TestDir) {
     struct stat DirSt;
     if (stat(Dir, &DirSt) == -1)
       Ret = -1;
-    else if ((DirSt.st_mode & ~S_ISGID) != Expected) {
+    // AIX has some extended definition of high order bits for st_mode, avoid trying to comparing those by masking them off.
+    else if (((DirSt.st_mode & ~S_ISGID) & 0xFFFF) != Expected) {
       printf("Modes do not match: Expected %o but found %o (%s)\n", Expected,
              DirSt.st_mode, Dir);
       Ret = -1;

diff  --git a/compiler-rt/test/profile/instrprof-set-file-object-merging.c b/compiler-rt/test/profile/instrprof-set-file-object-merging.c
index d9529e27eb59e..92f5f92e27720 100644
--- a/compiler-rt/test/profile/instrprof-set-file-object-merging.c
+++ b/compiler-rt/test/profile/instrprof-set-file-object-merging.c
@@ -1,6 +1,6 @@
 // Test that the specified output merges the profiling data.
 // Run the program twice so that the counters accumulate.
-// RUN: %clang -fprofile-instr-generate -fcoverage-mapping -o %t %s
+// RUN: %clang_profgen -fcoverage-mapping -o %t %s
 // RUN: rm -f %t.merging.profraw %t.merging.profdata
 // RUN: %run %t %t.merging.profraw
 // RUN: %run %t %t.merging.profraw

diff  --git a/compiler-rt/test/profile/instrprof-set-file-object.c b/compiler-rt/test/profile/instrprof-set-file-object.c
index d0b37facc19be..280374acb55d3 100644
--- a/compiler-rt/test/profile/instrprof-set-file-object.c
+++ b/compiler-rt/test/profile/instrprof-set-file-object.c
@@ -1,5 +1,5 @@
 // Test that the specified output has profiling data.
-// RUN: %clang -fprofile-instr-generate -fcoverage-mapping -o %t %s
+// RUN: %clang_profgen -fcoverage-mapping -o %t %s
 // RUN: %run %t %t.file.profraw
 // RUN: test -f %t.file.profraw
 // RUN: llvm-profdata merge -o %t.file.profdata %t.file.profraw

diff  --git a/compiler-rt/test/profile/lit.cfg.py b/compiler-rt/test/profile/lit.cfg.py
index d174cf12238af..2efdbacc948d6 100644
--- a/compiler-rt/test/profile/lit.cfg.py
+++ b/compiler-rt/test/profile/lit.cfg.py
@@ -50,6 +50,20 @@ def build_invocation(compile_flags, with_lto = False):
     lto_prefix += config.lto_launch
   return " " + " ".join(lto_prefix + [config.clang] + lto_flags + compile_flags) + " "
 
+def exclude_unsupported_files_for_aix(dirname):
+   for filename in os.listdir(dirname):
+       source_path = os.path.join( dirname, filename)
+       if os.path.isdir(source_path):
+           continue
+       f = open(source_path, 'r')
+       try:
+          data = f.read()
+          # -fprofile-instr-generate and rpath are not supported on AIX, exclude all tests with them.
+          if ("%clang_profgen" in data or "%clangxx_profgen" in data or "-rpath" in data):
+            config.excludes += [ filename ]
+       finally:
+          f.close()
+
 # Add clang substitutions.
 config.substitutions.append( ("%clang ", build_invocation(clang_cflags)) )
 config.substitutions.append( ("%clangxx ", build_invocation(clang_cxxflags)) )
@@ -71,9 +85,14 @@ def build_invocation(compile_flags, with_lto = False):
 
 config.substitutions.append( ("%clang_lto_profgen=", build_invocation(clang_cflags, True) + " -fprofile-instr-generate=") )
 
-if config.host_os not in ['Windows', 'Darwin', 'FreeBSD', 'Linux', 'NetBSD', 'SunOS']:
+if config.host_os not in ['Windows', 'Darwin', 'FreeBSD', 'Linux', 'NetBSD', 'SunOS', 'AIX']:
   config.unsupported = True
 
+if config.host_os in ['AIX']:
+  config.available_features.add('system-aix')
+  exclude_unsupported_files_for_aix(config.test_source_root)
+  exclude_unsupported_files_for_aix(config.test_source_root + "/Posix")
+
 if config.target_arch in ['armv7l']:
   config.unsupported = True
 


        


More information about the llvm-commits mailing list