From 49208a2dce8596dfdd1b3d3be86747a9524fa664 Mon Sep 17 00:00:00 2001 From: Sergey Semenov Date: Mon, 13 Oct 2025 06:58:29 -0700 Subject: [PATCH 1/2] [SYCL][CMake] Add an option to enable IPO for runtime builds --- sycl/CMakeLists.txt | 1 + sycl/source/CMakeLists.txt | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/sycl/CMakeLists.txt b/sycl/CMakeLists.txt index f123c457cdb79..a3b9ffbead17b 100644 --- a/sycl/CMakeLists.txt +++ b/sycl/CMakeLists.txt @@ -11,6 +11,7 @@ option(SYCL_ADD_DEV_VERSION_POSTFIX "Adds -V postfix to version string" ON) option(SYCL_ENABLE_COVERAGE "Enables code coverage for runtime and unit tests" OFF) option(SYCL_ENABLE_STACK_PRINTING "Enables stack printing on crashes of SYCL applications" OFF) option(SYCL_LIB_WITH_DEBUG_SYMBOLS "Builds SYCL runtime libraries with debug symbols" OFF) +option(SYCL_ENABLE_IPO "Builds SYCL runtime libraries with interprocedural optimization" OFF) if (NOT SYCL_COVERAGE_PATH) set(SYCL_COVERAGE_PATH "${CMAKE_CURRENT_BINARY_DIR}/profiles") diff --git a/sycl/source/CMakeLists.txt b/sycl/source/CMakeLists.txt index 4159303f87d19..3ec5c65ca6167 100644 --- a/sycl/source/CMakeLists.txt +++ b/sycl/source/CMakeLists.txt @@ -4,6 +4,7 @@ #cmake_policy(SET CMP0057 NEW) #include(AddLLVM) include(CheckLinkerFlag) +include(CheckIPOSupported) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/version.rc @@ -16,6 +17,13 @@ if (SYCL_ENABLE_XPTI_TRACING) include_directories(${LLVM_EXTERNAL_XPTI_SOURCE_DIR}/include) endif() +if(SYCL_ENABLE_IPO) +check_ipo_supported(RESULT SYCL_USE_IPO) +if (NOT SYCL_USE_IPO) + message(WARNING "Interprocedural optimization is not supported by the compiler, disabling") +endif() +endif() + function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME) # Add an optional argument so we can get the library name to # link with for Windows Debug version @@ -23,6 +31,10 @@ function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME) add_library(${LIB_OBJ_NAME} OBJECT ${ARG_SOURCES}) + if(SYCL_USE_IPO) + set_property(TARGET ${LIB_OBJ_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) + endif() + # Common compilation step setup check_cxx_compiler_flag(-Winstantiation-after-specialization @@ -79,6 +91,10 @@ function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME) $ ${CMAKE_CURRENT_BINARY_DIR}/version.rc) + if(SYCL_USE_IPO) + set_property(TARGET ${LIB_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) + endif() + find_package(Threads REQUIRED) target_link_libraries(${LIB_NAME} From b5ee4bef3c762f326a78247f9c19c4f0e7d2b93b Mon Sep 17 00:00:00 2001 From: Sergey Semenov Date: Tue, 4 Nov 2025 09:58:47 -0800 Subject: [PATCH 2/2] Formatting --- sycl/source/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sycl/source/CMakeLists.txt b/sycl/source/CMakeLists.txt index 3ec5c65ca6167..be262a28d8093 100644 --- a/sycl/source/CMakeLists.txt +++ b/sycl/source/CMakeLists.txt @@ -18,10 +18,10 @@ if (SYCL_ENABLE_XPTI_TRACING) endif() if(SYCL_ENABLE_IPO) -check_ipo_supported(RESULT SYCL_USE_IPO) -if (NOT SYCL_USE_IPO) - message(WARNING "Interprocedural optimization is not supported by the compiler, disabling") -endif() + check_ipo_supported(RESULT SYCL_USE_IPO) + if (NOT SYCL_USE_IPO) + message(WARNING "Interprocedural optimization is not supported by the compiler, disabling") + endif() endif() function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME)