Index: cmake/CMakeLists.txt =================================================================== --- cmake/CMakeLists.txt +++ cmake/CMakeLists.txt @@ -10,10 +10,6 @@ endif() set(POLLY_CONFIG_EXPORTED_TARGETS Polly ${ISL_TARGET}) -if (NOT MSVC) - # LLVMPolly is a dummy target on Win - list(APPEND POLLY_CONFIG_EXPORTED_TARGETS LLVMPolly) -endif() if (POLLY_ENABLE_GPGPU_CODEGEN) list(APPEND POLLY_CONFIG_EXPORTED_TARGETS PollyPPCG) endif() Index: lib/CMakeLists.txt =================================================================== --- lib/CMakeLists.txt +++ lib/CMakeLists.txt @@ -21,9 +21,44 @@ file(GLOB_RECURSE POLLY_HEADER_FILES "${POLLY_SOURCE_DIR}/include/polly/*.h") endif () +# Polly-ACC requires the NVPTX backend to work. Ask LLVM about its libraries. +set(nvptx_libs) +if (GPU_CODEGEN) + # This call emits an error if they NVPTX backend is not enable. + llvm_map_components_to_libnames(nvptx_libs NVPTX) +endif () + +set(LLVM_COMPONENTS + Support + Core + ScalarOpts + InstCombine + TransformUtils + Analysis + ipo + MC + Passes + Linker + IRReader + ${nvptx_libs} + # The libraries below are required for darwin: http://PR26392 + BitReader + MCParser + Object + ProfileData + Target + Vectorize + ) + +set(POLLY_LINK_LIBS ${ISL_TARGET}) +# Additional dependencies for Polly-ACC. +if (GPU_CODEGEN) + list(APPEND POLLY_LINK_LIBS PollyPPCG) +endif () + # Use an object-library to add the same files to multiple libs without requiring # the sources them to be recompiled for each of them. -add_library(PollyCore OBJECT +add_llvm_library(Polly Analysis/DependenceInfo.cpp Analysis/PolyhedralInfo.cpp Analysis/ScopDetection.cpp @@ -66,96 +101,28 @@ Transform/RewriteByReferenceParameters.cpp Transform/ScopInliner.cpp ${POLLY_HEADER_FILES} - ) -set_target_properties(PollyCore PROPERTIES FOLDER "Polly") -# Create the library that can be linked into LLVM's tools and Polly's unittests. -# It depends on all library it needs, such that with -# LLVM_POLLY_LINK_INTO_TOOLS=ON, its dependencies like PollyISL are linked as -# well. -add_polly_library(Polly $) -target_link_libraries(Polly PUBLIC - ${ISL_TARGET} -) - -# Additional dependencies for Polly-ACC. -if (GPU_CODEGEN) - target_link_libraries(Polly PUBLIC PollyPPCG) -endif () + OBJECT + STATIC + DEPENDS intrinsics_gen -# Polly-ACC requires the NVPTX backend to work. Ask LLVM about its libraries. -set(nvptx_libs) -if (GPU_CODEGEN) - # This call emits an error if they NVPTX backend is not enable. - llvm_map_components_to_libnames(nvptx_libs NVPTX) -endif () - -if (LLVM_LINK_LLVM_DYLIB) - # The shlib/dylib contains all the LLVM components - # (including NVPTX is enabled) already. Adding them to target_link_libraries - # would cause them being twice in the address space - # (their LLVM*.a/so and their copies in libLLVM.so) - # which results in errors when the two instances try to register the same - # command-line switches. - target_link_libraries(Polly PUBLIC LLVM) -else () - target_link_libraries(Polly PUBLIC - LLVMSupport - LLVMCore - LLVMScalarOpts - LLVMInstCombine - LLVMTransformUtils - LLVMAnalysis - LLVMipo - LLVMMC - LLVMPasses - LLVMLinker - LLVMIRReader - ${nvptx_libs} - # The libraries below are required for darwin: http://PR26392 - LLVMBitReader - LLVMMCParser - LLVMObject - LLVMProfileData - LLVMTarget - LLVMVectorize - ) -endif () - -# Create a loadable module Polly.so that can be loaded using -# LLVM's/clang's "-load" option. -if (MSVC) - # Add dummy target, because loadable modules are not supported on Windows - add_custom_target(LLVMPolly) - set_target_properties(LLVMPolly PROPERTIES FOLDER "Polly") -else () - add_polly_loadable_module(LLVMPolly - Polly.cpp - $ + LINK_COMPONENTS ${LLVM_COMPONENTS} + LINK_LIBS ${POLLY_LINK_LIBS} ) +set_target_properties(Polly PROPERTIES FOLDER "Polly") - # Only add the dependencies that are not part of LLVM. The latter are assumed - # to be already available in the address space the module is loaded into. - # Adding them once more would have the effect that both copies try to register - # the same command line options, to which LLVM reacts with an error. - # If Polly-ACC is enabled, the NVPTX target is also expected to reside in the - # hosts. This is not the case for bugpoint. Use LLVM_POLLY_LINK_INTO_TOOLS=ON - # instead which will automatically resolve the additional dependencies by - # Polly. - target_link_libraries(LLVMPolly PUBLIC ${ISL_TARGET}) - if (GPU_CODEGEN) - target_link_libraries(LLVMPolly PUBLIC PollyPPCG) - endif () +add_llvm_loadable_module(LLVMPolly + Polly/Polly.cpp + $ - set_target_properties(LLVMPolly - PROPERTIES - LINKER_LANGUAGE CXX - PREFIX "") -endif () - -if (TARGET intrinsics_gen) - # Check if we are building as part of an LLVM build - add_dependencies(PollyCore intrinsics_gen) -endif() + LINK_COMPONENTS ${LLVM_COMPONENTS} + LINK_LIBS ${POLLY_LINK_LIBS} + ) +set_target_properties(LLVMPolly + PROPERTIES + FOLDER "Polly" + LINKER_LANGUAGE CXX + PREFIX "" + ) Index: lib/Polly.cpp =================================================================== --- /dev/null +++ lib/Polly.cpp @@ -1,30 +0,0 @@ -//===---------- Polly.cpp - Initialize the Polly Module -------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -//===----------------------------------------------------------------------===// - -#include "polly/RegisterPasses.h" -#include "llvm/Transforms/IPO/PassManagerBuilder.h" - -namespace { - -/// Initialize Polly passes when library is loaded. -/// -/// We use the constructor of a statically declared object to initialize the -/// different Polly passes right after the Polly library is loaded. This ensures -/// that the Polly passes are available e.g. in the 'opt' tool. -class StaticInitializer { -public: - StaticInitializer() { - llvm::PassRegistry &Registry = *llvm::PassRegistry::getPassRegistry(); - polly::initializePollyPasses(Registry); - } -}; -static StaticInitializer InitializeEverything; -} // end of anonymous namespace.