[Openmp-commits] [openmp] 908054d - [Libomptarget] Only export needed definitions in the BC library
Joseph Huber via Openmp-commits
openmp-commits at lists.llvm.org
Fri Jul 22 05:24:52 PDT 2022
Author: Joseph Huber
Date: 2022-07-22T08:24:35-04:00
New Revision: 908054df4f15d44a5e1e72d95aa2bcf92ddb6e1a
URL: https://github.com/llvm/llvm-project/commit/908054df4f15d44a5e1e72d95aa2bcf92ddb6e1a
DIFF: https://github.com/llvm/llvm-project/commit/908054df4f15d44a5e1e72d95aa2bcf92ddb6e1a.diff
LOG: [Libomptarget] Only export needed definitions in the BC library
This patch adds the use of the `-internalize-public-api-file` option in
the internalization pass to internalize any definition that isn't
explicitly needed for the interface. This will allow us to perform more
optimizations on the file that normally would not have been possible
with functions internal to the library not being internal.
Depends on D130293
Reviewed By: jdoerfert
Differential Revision: https://reviews.llvm.org/D130298
Added:
openmp/libomptarget/DeviceRTL/src/exports
Modified:
openmp/libomptarget/DeviceRTL/CMakeLists.txt
Removed:
################################################################################
diff --git a/openmp/libomptarget/DeviceRTL/CMakeLists.txt b/openmp/libomptarget/DeviceRTL/CMakeLists.txt
index 0c7400604df48..04ee959d5d6ab 100644
--- a/openmp/libomptarget/DeviceRTL/CMakeLists.txt
+++ b/openmp/libomptarget/DeviceRTL/CMakeLists.txt
@@ -108,6 +108,7 @@ set(src_files
set(clang_opt_flags -O3 -mllvm -openmp-opt-disable -DSHARED_SCRATCHPAD_SIZE=512)
set(link_opt_flags -O3 -openmp-opt-disable)
+set(link_export_flag -passes=internalize -internalize-public-api-file=${source_directory}/exports)
# Prepend -I to each list element
set (LIBOMPTARGET_LLVM_INCLUDE_DIRS_DEVICERTL "${LIBOMPTARGET_LLVM_INCLUDE_DIRS}")
@@ -173,10 +174,17 @@ function(compileDeviceRTLLibrary target_cpu target_name)
COMMENT "Linking LLVM bitcode ${bclib_name}"
)
+ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/internalized_${bclib_name}
+ COMMAND ${OPT_TOOL} ${link_export_flag} ${CMAKE_CURRENT_BINARY_DIR}/linked_${bclib_name}
+ -o ${CMAKE_CURRENT_BINARY_DIR}/internalized_${bclib_name}
+ DEPENDS ${source_directory}/exports ${CMAKE_CURRENT_BINARY_DIR}/linked_${bclib_name}
+ COMMENT "Internalizing LLVM bitcode ${bclib_name}"
+ )
+
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${bclib_name}
- COMMAND ${OPT_TOOL} ${link_opt_flags} ${CMAKE_CURRENT_BINARY_DIR}/linked_${bclib_name}
+ COMMAND ${OPT_TOOL} ${link_opt_flags} ${CMAKE_CURRENT_BINARY_DIR}/internalized_${bclib_name}
-o ${CMAKE_CURRENT_BINARY_DIR}/${bclib_name}
- DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/linked_${bclib_name}
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/internalized_${bclib_name}
COMMENT "Optimizing LLVM bitcode ${bclib_name}"
)
diff --git a/openmp/libomptarget/DeviceRTL/src/exports b/openmp/libomptarget/DeviceRTL/src/exports
new file mode 100644
index 0000000000000..58cbeb1316131
--- /dev/null
+++ b/openmp/libomptarget/DeviceRTL/src/exports
@@ -0,0 +1,3 @@
+omp_*
+*llvm_*
+__kmpc_*
More information about the Openmp-commits
mailing list