@@ -847,32 +847,40 @@ macro(add_llvm_executable name)
847847 llvm_codesign(${name} ENTITLEMENTS ${ARG_ENTITLEMENTS} BUNDLE_PATH ${ARG_BUNDLE_PATH} )
848848endmacro (add_llvm_executable name )
849849
850- # add_llvm_pass_plugin(name)
850+ # add_llvm_pass_plugin(name [NO_MODULE] ... )
851851# Add ${name} as an llvm plugin.
852852# If option LLVM_${name_upper}_LINK_INTO_TOOLS is set to ON, the plugin is registered statically.
853853# Otherwise a pluggable shared library is registered.
854+ #
855+ # If NO_MODULE is specified, when option LLVM_${name_upper}_LINK_INTO_TOOLS is set to OFF,
856+ # only an object library is built, and no module is built. This is specific to the Polly use case.
854857function (add_llvm_pass_plugin name )
858+ cmake_parse_arguments (ARG
859+ "NO_MODULE" "" ""
860+ ${ARGN} )
855861
856862 string (TOUPPER ${name} name_upper)
857863
858864 option (LLVM_${name_upper} _LINK_INTO_TOOLS "Statically link ${name} into tools (if available)" OFF )
859865
860- # process_llvm_pass_plugins takes care of the actual linking, just create an
861- # object library as of now
862- add_llvm_library(${name} OBJECT ${ARGN} )
863-
864- if (LLVM_${name_upper} _LINK_INTO_TOOLS)
865- target_compile_definitions (${name} PRIVATE LLVM_${name_upper} _LINK_INTO_TOOLS)
866- set_property (TARGET ${name} APPEND PROPERTY COMPILE_DEFINITIONS LLVM_LINK_INTO_TOOLS)
867- if (TARGET intrinsics_gen)
868- add_dependencies (obj.${name} intrinsics_gen)
869- endif ()
870- endif ()
871-
872- message (STATUS "Registering ${name} as a pass plugin (static build: ${LLVM_${name_upper} _LINK_INTO_TOOLS})" )
873866 if (LLVM_${name_upper} _LINK_INTO_TOOLS)
867+ list (REMOVE_ITEM ARG_UNPARSED_ARGUMENTS BUILDTREE_ONLY)
868+ # process_llvm_pass_plugins takes care of the actual linking, just create an
869+ # object library as of now
870+ add_llvm_library(${name} OBJECT ${ARG_UNPARSED_ARGUMENTS} )
871+ target_compile_definitions (${name} PRIVATE LLVM_${name_upper} _LINK_INTO_TOOLS)
872+ set_property (TARGET ${name} APPEND PROPERTY COMPILE_DEFINITIONS LLVM_LINK_INTO_TOOLS)
873+ if (TARGET intrinsics_gen)
874+ add_dependencies (obj.${name} intrinsics_gen)
875+ endif ()
876+ message (STATUS "Registering ${name} as a pass plugin (static build: ${LLVM_${name_upper} _LINK_INTO_TOOLS})" )
874877 set_property (GLOBAL APPEND PROPERTY LLVM_COMPILE_EXTENSIONS ${name} )
878+ elseif (NOT ARG_NO_MODULE)
879+ add_llvm_library(${name} MODULE ${ARG_UNPARSED_ARGUMENTS} )
880+ else ()
881+ add_llvm_library(${name} OBJECT ${ARG_UNPARSED_ARGUMENTS} )
875882 endif ()
883+
876884endfunction (add_llvm_pass_plugin)
877885
878886# Generate X Macro file for extension handling. It provides a
0 commit comments