https://github.com/wenju-he created https://github.com/llvm/llvm-project/pull/130882
When the flag is empty, the opt command won't modify the bitcode; however, the command is slow for large bitcode files in debug mode. >From 1727cb49ebbee324ecad0a766ec341eb1aed082b Mon Sep 17 00:00:00 2001 From: Wenju He <wenju...@intel.com> Date: Tue, 11 Mar 2025 19:05:25 -0700 Subject: [PATCH] [libclc] Skip opt command if opt_flags is empty When the flag is empty, the opt command won't modify the bitcode; however, the command is slow for large bitcode files in debug mode. --- libclc/cmake/modules/AddLibclc.cmake | 42 +++++++++++++++++----------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake index 911559ff4bfa9..de24848256d72 100644 --- a/libclc/cmake/modules/AddLibclc.cmake +++ b/libclc/cmake/modules/AddLibclc.cmake @@ -340,29 +340,37 @@ function(add_libclc_builtin_set) return() endif() - set( builtins_opt_lib_tgt builtins.opt.${ARG_ARCH_SUFFIX} ) + if( ${ARG_OPT_FLAGS} ) + set( builtins_opt_lib_tgt builtins.opt.${ARG_ARCH_SUFFIX} ) + + # Add opt target + add_custom_command( OUTPUT ${builtins_opt_lib_tgt}.bc + COMMAND ${opt_exe} ${ARG_OPT_FLAGS} -o ${builtins_opt_lib_tgt}.bc + ${builtins_link_lib} + DEPENDS ${opt_target} ${builtins_link_lib} ${builtins_link_lib_tgt} + ) + add_custom_target( ${builtins_opt_lib_tgt} + ALL DEPENDS ${builtins_opt_lib_tgt}.bc + ) + set_target_properties( ${builtins_opt_lib_tgt} PROPERTIES + TARGET_FILE ${CMAKE_CURRENT_BINARY_DIR}/${builtins_opt_lib_tgt}.bc + FOLDER "libclc/Device IR/Opt" + ) - # Add opt target - add_custom_command( OUTPUT ${builtins_opt_lib_tgt}.bc - COMMAND ${opt_exe} ${ARG_OPT_FLAGS} -o ${builtins_opt_lib_tgt}.bc - ${builtins_link_lib} - DEPENDS ${opt_target} ${builtins_link_lib} ${builtins_link_lib_tgt} - ) - add_custom_target( ${builtins_opt_lib_tgt} - ALL DEPENDS ${builtins_opt_lib_tgt}.bc - ) - set_target_properties( ${builtins_opt_lib_tgt} PROPERTIES - TARGET_FILE ${CMAKE_CURRENT_BINARY_DIR}/${builtins_opt_lib_tgt}.bc - FOLDER "libclc/Device IR/Opt" - ) + set( builtins_opt_lib $<TARGET_PROPERTY:${builtins_opt_lib_tgt},TARGET_FILE> ) - set( builtins_opt_lib $<TARGET_PROPERTY:${builtins_opt_lib_tgt},TARGET_FILE> ) + set( builtins_link_opt_lib ${builtins_opt_lib} ) + set( builtins_link_opt_lib_tgt ${builtins_opt_lib_tgt} ) + else() + set( builtins_link_opt_lib ${builtins_link_lib} ) + set( builtins_link_opt_lib_tgt ${builtins_link_lib_tgt} ) + endif() # Add prepare target set( obj_suffix ${ARG_ARCH_SUFFIX}.bc ) add_custom_command( OUTPUT ${obj_suffix} - COMMAND ${prepare_builtins_exe} -o ${obj_suffix} ${builtins_opt_lib} - DEPENDS ${builtins_opt_lib} ${builtins_opt_lib_tgt} ${prepare_builtins_target} ) + COMMAND ${prepare_builtins_exe} -o ${obj_suffix} ${builtins_link_opt_lib} + DEPENDS ${builtins_link_opt_lib} ${builtins_link_opt_lib_tgt} ${prepare_builtins_target} ) add_custom_target( prepare-${obj_suffix} ALL DEPENDS ${obj_suffix} ) set_target_properties( "prepare-${obj_suffix}" PROPERTIES FOLDER "libclc/Device IR/Prepare" ) _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits