Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 9 additions & 0 deletions compiler-rt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,15 @@ option(COMPILER_RT_USE_ATOMIC_LIBRARY "Use compiler-rt atomic instead of libatom

option(COMPILER_RT_PROFILE_BAREMETAL "Build minimal baremetal profile library" OFF)

set(DEFAULT_COMPILER_RT_BUILD_PROFILE_ROCM ON)
if(APPLE)
set(DEFAULT_COMPILER_RT_BUILD_PROFILE_ROCM OFF)
endif()
option(COMPILER_RT_BUILD_PROFILE_ROCM
"Build the host-side ROCm/HIP device profile collection runtime"
${DEFAULT_COMPILER_RT_BUILD_PROFILE_ROCM})
mark_as_advanced(COMPILER_RT_BUILD_PROFILE_ROCM)

include(config-ix)

#================================
Expand Down
10 changes: 9 additions & 1 deletion compiler-rt/lib/profile/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,13 @@ if (NOT COMPILER_RT_PROFILE_BAREMETAL)
list(APPEND PROFILE_SOURCES
GCDAProfiling.c
InstrProfilingFile.c
InstrProfilingPlatformROCm.cpp
InstrProfilingRuntime.cpp
InstrProfilingUtil.c
InstrProfilingValue.c
)
if(COMPILER_RT_BUILD_PROFILE_ROCM)
list(APPEND PROFILE_SOURCES InstrProfilingPlatformROCm.cpp)
endif()
endif()

set(PROFILE_HEADERS
Expand Down Expand Up @@ -156,6 +158,12 @@ if(COMPILER_RT_PROFILE_BAREMETAL)
-DCOMPILER_RT_PROFILE_BAREMETAL=1)
endif()

if(COMPILER_RT_BUILD_PROFILE_ROCM)
set(EXTRA_FLAGS
${EXTRA_FLAGS}
-DCOMPILER_RT_BUILD_PROFILE_ROCM=1)
endif()

set(PROFILE_OBJECT_LIBS)
if(COMPILER_RT_HAS_INTERCEPTION AND NOT COMPILER_RT_PROFILE_BAREMETAL)
# RTInterception references __sanitizer_internal_{memcpy,memset,memmove} and other
Expand Down
4 changes: 4 additions & 0 deletions compiler-rt/lib/profile/InstrProfilingFile.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@
* and the address test at the call site would fold to true.
* Windows: __declspec(selectany) is data-only, and the ROCm interceptor path
* is not used there, so keep the original strong extern. */
#if COMPILER_RT_BUILD_PROFILE_ROCM
#if defined(_WIN32)
extern int __llvm_profile_hip_collect_device_data(void);
#else
__attribute__((weak)) int __llvm_profile_hip_collect_device_data(void);
#endif
#endif

/* From where is profile name specified.
* The order the enumerators define their
Expand Down Expand Up @@ -1217,11 +1219,13 @@ int __llvm_profile_write_file(void) {
* InstrProfilingPlatformROCm.o is in the link, which happens when the program
* references other ROCm-runtime symbols (HIP-with-PGO). Warning on failure is
* handled inside the callee. */
#if COMPILER_RT_BUILD_PROFILE_ROCM
#if defined(_WIN32)
(void)__llvm_profile_hip_collect_device_data();
#else
if (&__llvm_profile_hip_collect_device_data)
(void)__llvm_profile_hip_collect_device_data();
#endif
#endif

// Restore SIGKILL.
Expand Down