[compiler-rt] 787fbad - [NFC][AIX][PGO] Create AIX specific compiler-rt profile file.
Wael Yehia via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 18 13:22:32 PDT 2023
Author: Wael Yehia
Date: 2023-03-18T20:22:22Z
New Revision: 787fbad57e05b5eb225b1b3881f7e84270a8a33f
URL: https://github.com/llvm/llvm-project/commit/787fbad57e05b5eb225b1b3881f7e84270a8a33f
DIFF: https://github.com/llvm/llvm-project/commit/787fbad57e05b5eb225b1b3881f7e84270a8a33f.diff
LOG: [NFC][AIX][PGO] Create AIX specific compiler-rt profile file.
Added:
compiler-rt/lib/profile/InstrProfilingPlatformAIX.c
Modified:
compiler-rt/lib/profile/CMakeLists.txt
compiler-rt/lib/profile/InstrProfilingPlatformLinux.c
Removed:
################################################################################
diff --git a/compiler-rt/lib/profile/CMakeLists.txt b/compiler-rt/lib/profile/CMakeLists.txt
index 5ddb7bc5add71..45e5164891751 100644
--- a/compiler-rt/lib/profile/CMakeLists.txt
+++ b/compiler-rt/lib/profile/CMakeLists.txt
@@ -60,6 +60,7 @@ set(PROFILE_SOURCES
InstrProfilingNameVar.c
InstrProfilingVersionVar.c
InstrProfilingWriter.c
+ InstrProfilingPlatformAIX.c
InstrProfilingPlatformDarwin.c
InstrProfilingPlatformFuchsia.c
InstrProfilingPlatformLinux.c
diff --git a/compiler-rt/lib/profile/InstrProfilingPlatformAIX.c b/compiler-rt/lib/profile/InstrProfilingPlatformAIX.c
new file mode 100644
index 0000000000000..1035894b8ed1c
--- /dev/null
+++ b/compiler-rt/lib/profile/InstrProfilingPlatformAIX.c
@@ -0,0 +1,48 @@
+/*===- InstrProfilingPlatformAIX.c - Profile data AIX platform ------------===*\
+|*
+|* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+|* See https://llvm.org/LICENSE.txt for license information.
+|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+|*
+\*===----------------------------------------------------------------------===*/
+
+#if defined(_AIX)
+
+#include "InstrProfiling.h"
+
+// Empty stubs to allow linking object files using the registration-based scheme
+COMPILER_RT_VISIBILITY
+void __llvm_profile_register_function(void *Data_) {}
+
+COMPILER_RT_VISIBILITY
+void __llvm_profile_register_names_function(void *NamesStart,
+ uint64_t NamesSize) {}
+
+// The __start_SECNAME and __stop_SECNAME symbols (for SECNAME \in
+// {"__llvm_prf_cnts", "__llvm_prf_data", "__llvm_prf_name", "__llvm_prf_vnds"})
+// are always live when linking on AIX, regardless if the .o's being linked
+// reference symbols from the profile library (for example when no files were
+// compiled with -fprofile-generate). That's because these symbols are kept
+// alive through references in constructor functions that are always live in the
+// default linking model on AIX (-bcdtors:all). The __start_SECNAME and
+// __stop_SECNAME symbols are only resolved by the linker when the SECNAME
+// section exists. So for the scenario where the user objects have no such
+// section (i.e. when they are compiled with -fno-profile-generate), we always
+// define these zero length variables in each of the above 4 sections.
+static int dummy_cnts[0] COMPILER_RT_SECTION(
+ COMPILER_RT_SEG INSTR_PROF_CNTS_SECT_NAME);
+static int dummy_data[0] COMPILER_RT_SECTION(
+ COMPILER_RT_SEG INSTR_PROF_DATA_SECT_NAME);
+static const int dummy_name[0] COMPILER_RT_SECTION(
+ COMPILER_RT_SEG INSTR_PROF_NAME_SECT_NAME);
+static int dummy_vnds[0] COMPILER_RT_SECTION(
+ COMPILER_RT_SEG INSTR_PROF_VNODES_SECT_NAME);
+
+// To avoid GC'ing of the dummy variables by the linker, reference them in an
+// array and reference the array in the runtime registration code
+// (InstrProfilingRuntime.cpp)
+COMPILER_RT_VISIBILITY
+void *__llvm_profile_keep[] = {(void *)&dummy_cnts, (void *)&dummy_data,
+ (void *)&dummy_name, (void *)&dummy_vnds};
+
+#endif
diff --git a/compiler-rt/lib/profile/InstrProfilingPlatformLinux.c b/compiler-rt/lib/profile/InstrProfilingPlatformLinux.c
index adf4132c6b4d6..f17e543ddb5d8 100644
--- a/compiler-rt/lib/profile/InstrProfilingPlatformLinux.c
+++ b/compiler-rt/lib/profile/InstrProfilingPlatformLinux.c
@@ -230,41 +230,4 @@ COMPILER_RT_VISIBILITY int __llvm_write_binary_ids(ProfDataWriter *Writer) {
}
#endif
-#if defined(_AIX)
-// Empty stubs to allow linking object files using the registration-based scheme
-COMPILER_RT_VISIBILITY
-void __llvm_profile_register_function(void *Data_) {}
-
-COMPILER_RT_VISIBILITY
-void __llvm_profile_register_names_function(void *NamesStart,
- uint64_t NamesSize) {}
-
-// The __start_SECNAME and __stop_SECNAME symbols (for SECNAME \in
-// {"__llvm_prf_cnts", "__llvm_prf_data", "__llvm_prf_name", "__llvm_prf_vnds"})
-// are always live when linking on AIX, regardless if the .o's being linked
-// reference symbols from the profile library (for example when no files were
-// compiled with -fprofile-generate). That's because these symbols are kept
-// alive through references in constructor functions that are always live in the
-// default linking model on AIX (-bcdtors:all). The __start_SECNAME and
-// __stop_SECNAME symbols are only resolved by the linker when the SECNAME
-// section exists. So for the scenario where the user objects have no such
-// section (i.e. when they are compiled with -fno-profile-generate), we always
-// define these zero length variables in each of the above 4 sections.
-static int dummy_cnts[0] COMPILER_RT_SECTION(
- COMPILER_RT_SEG INSTR_PROF_CNTS_SECT_NAME);
-static int dummy_data[0] COMPILER_RT_SECTION(
- COMPILER_RT_SEG INSTR_PROF_DATA_SECT_NAME);
-static const int dummy_name[0] COMPILER_RT_SECTION(
- COMPILER_RT_SEG INSTR_PROF_NAME_SECT_NAME);
-static int dummy_vnds[0] COMPILER_RT_SECTION(
- COMPILER_RT_SEG INSTR_PROF_VNODES_SECT_NAME);
-
-// To avoid GC'ing of the dummy variables by the linker, reference them in an
-// array and reference the array in the runtime registration code
-// (InstrProfilingRuntime.cpp)
-COMPILER_RT_VISIBILITY
-void *__llvm_profile_keep[] = {(void *)&dummy_cnts, (void *)&dummy_data,
- (void *)&dummy_name, (void *)&dummy_vnds};
-#endif
-
#endif
More information about the llvm-commits
mailing list