llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Erich Keane (erichkeane) <details> <summary>Changes</summary> It was brought up on a different review that the cost of enabling ClangIR by default was a significant runtime cost, even without fclangir. From an instruction count, I found a ~8.5 million instruction increase caused by the loader having to see all these symbols. Reducing these gets us down to about a 300k overhead here, which reduces the time measured on my machine of around 0.11% increase on a file including std::vector, which feels reasonable. An empty TU overhead looks to be in the high-1% increase due to the ~300k additional instructions of loading. AI disclosure: I used it extensively here, but I think I understand what is going on, to the best of my ability to understand linking and CMake (which is minimal :/). --- Full diff: https://github.com/llvm/llvm-project/pull/232409.diff 3 Files Affected: - (modified) clang/tools/cir-opt/CMakeLists.txt (+4-8) - (modified) clang/tools/cir-translate/CMakeLists.txt (+6-10) - (modified) clang/tools/clang-shlib/simple_version_script.map.in (+16-1) ``````````diff diff --git a/clang/tools/cir-opt/CMakeLists.txt b/clang/tools/cir-opt/CMakeLists.txt index 40304dd4a114e4..e64f5c3dad69bd 100644 --- a/clang/tools/cir-opt/CMakeLists.txt +++ b/clang/tools/cir-opt/CMakeLists.txt @@ -13,19 +13,15 @@ if(CLANG_INCLUDE_TESTS) target_compile_definitions(cir-opt PRIVATE CLANG_INCLUDE_TESTS) endif() -clang_target_link_libraries(cir-opt +target_link_libraries(cir-opt PRIVATE + ${cir_opt_test_libs} + CIRRegisterAllDialects clangCIR clangCIRLoweringDirectToLLVM - CIRRegisterAllDialects + MLIRAnalysis MLIRCIR MLIRCIRTransforms -) - -target_link_libraries(cir-opt - PRIVATE - ${cir_opt_test_libs} - MLIRAnalysis MLIRDialect MLIRIR MLIRLLVMDialect diff --git a/clang/tools/cir-translate/CMakeLists.txt b/clang/tools/cir-translate/CMakeLists.txt index bdbfa3133cdcff..f3b7b8533a7bcf 100644 --- a/clang/tools/cir-translate/CMakeLists.txt +++ b/clang/tools/cir-translate/CMakeLists.txt @@ -5,19 +5,15 @@ add_clang_tool(cir-translate cir-translate.cpp ) -clang_target_link_libraries(cir-translate +target_link_libraries(cir-translate PRIVATE + CIRRegisterAllDialects clangCIR clangCIRLoweringDirectToLLVM - CIRRegisterAllDialects - MLIRCIR - MLIRCIRTransforms -) - -target_link_libraries(cir-translate - PRIVATE MLIRAnalysis MLIRBuiltinToLLVMIRTranslation + MLIRCIR + MLIRCIRTransforms MLIRDialect MLIRDLTIDialect MLIRFuncDialect @@ -25,12 +21,12 @@ target_link_libraries(cir-translate MLIRLLVMDialect MLIRLLVMToLLVMIRTranslation MLIROpenMPToLLVMIRTranslation - MLIRTargetLLVMIRExport MLIROptLib MLIRParser MLIRPass + MLIRSupport + MLIRTargetLLVMIRExport MLIRTransforms MLIRTransformUtils MLIRTranslateLib - MLIRSupport ) diff --git a/clang/tools/clang-shlib/simple_version_script.map.in b/clang/tools/clang-shlib/simple_version_script.map.in index cb2306d1f59682..b2cbc9760fe7af 100644 --- a/clang/tools/clang-shlib/simple_version_script.map.in +++ b/clang/tools/clang-shlib/simple_version_script.map.in @@ -1 +1,16 @@ -@LLVM_SHLIB_SYMBOL_VERSION@ { global: *; }; +@LLVM_SHLIB_SYMBOL_VERSION@ { + global: *; + + # ClangIR components are kept as an internal implementation detail, as + # otherwise the cost of loading/dynamically linking these symbols is onerous. + # This likely means that users of libclang-cpp.so won't be able to + # independently call ClangIR components, but that is not a supported feature. + # AS this script is used only on Itanium dylib builds, we can use the mangled + # names here, which saves multiple-percent in at link time, since the linker + # doesn't have to demangle every symbol. + # We exclude mlir::, cir::, and clang::CIRGen namespace symbols. + local: + *[NKVRO]4mlir*; + *[NKVRO]3cir*; + *[NKVRO]5clang6CIRGen*; +}; `````````` </details> https://github.com/llvm/llvm-project/pull/232409 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
