forked from OSchip/llvm-project
cmake: Split off functionality for LLVM loadable module
This fixes the buildbots who failed, because the linker eliminated most of the Polly functionality when building without BUILD_SHARED_LIBS=ON. Besides fixing the build, this change also brings additional functionality. With the new separation between the general polly libraries and the functionality for the polly module, it is now possible to link polly directly into a tool instead of using requiring users to load a shared library. llvm-svn: 202762
This commit is contained in:
parent
1d5c1fad68
commit
2c1a81aefd
|
@ -13,9 +13,18 @@
|
|||
|
||||
#ifndef POLLY_REGISTER_PASSES_H
|
||||
#define POLLY_REGISTER_PASSES_H
|
||||
|
||||
#include "llvm/PassManager.h"
|
||||
|
||||
namespace llvm {
|
||||
namespace legacy {
|
||||
class PassManagerBase;
|
||||
}
|
||||
}
|
||||
|
||||
namespace polly {
|
||||
void initializePollyPasses(llvm::PassRegistry &Registry);
|
||||
void registerPollyPasses(llvm::PassManagerBase &PM);
|
||||
bool shouldEnablePolly();
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -73,15 +73,10 @@ add_polly_library(LLVMPollyLib
|
|||
${POLLY_PLUTO_FILES}
|
||||
)
|
||||
|
||||
target_link_libraries(LLVMPollyLib
|
||||
LLVMSupport
|
||||
LLVMScalarOpts
|
||||
LLVMTransformUtils
|
||||
LLVMipo
|
||||
add_polly_loadable_module(LLVMPolly
|
||||
PollyModule.cpp
|
||||
)
|
||||
|
||||
add_polly_loadable_module(LLVMPolly)
|
||||
|
||||
if (TARGET intrinsics_gen)
|
||||
# Check if we are building as part of an LLVM build
|
||||
add_dependencies(LLVMPolly intrinsics_gen)
|
||||
|
|
|
@ -37,7 +37,8 @@
|
|||
#include "llvm/Transforms/Vectorize.h"
|
||||
|
||||
using namespace llvm;
|
||||
cl::OptionCategory PollyCategory("Polly Options",
|
||||
|
||||
cl::OptionCategory PollyCategory("Polly Optionsa",
|
||||
"Configure the polly loop optimizer");
|
||||
|
||||
static cl::opt<bool>
|
||||
|
@ -154,8 +155,8 @@ CFGPrinter("polly-view-cfg",
|
|||
cl::desc("Show the Polly CFG right after code generation"),
|
||||
cl::Hidden, cl::init(false), cl::cat(PollyCategory));
|
||||
|
||||
namespace {
|
||||
static void initializePollyPasses(PassRegistry &Registry) {
|
||||
namespace polly {
|
||||
void initializePollyPasses(PassRegistry &Registry) {
|
||||
#ifdef CLOOG_FOUND
|
||||
initializeCloogInfoPass(Registry);
|
||||
initializeCodeGenerationPass(Registry);
|
||||
|
@ -179,20 +180,6 @@ static void initializePollyPasses(PassRegistry &Registry) {
|
|||
initializeTempScopInfoPass(Registry);
|
||||
}
|
||||
|
||||
/// @brief 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() {
|
||||
PassRegistry &Registry = *PassRegistry::getPassRegistry();
|
||||
initializePollyPasses(Registry);
|
||||
}
|
||||
};
|
||||
static StaticInitializer InitializeEverything;
|
||||
|
||||
/// @brief Register Polly passes such that they form a polyhedral optimizer.
|
||||
///
|
||||
/// The individual Polly passes are registered in the pass manager such that
|
||||
|
@ -223,7 +210,7 @@ static StaticInitializer InitializeEverything;
|
|||
/// Polly supports both CLooG (http://www.cloog.org) as well as the isl internal
|
||||
/// code generator. For the moment, the CLooG code generator is enabled by
|
||||
/// default.
|
||||
static void registerPollyPasses(llvm::PassManagerBase &PM) {
|
||||
void registerPollyPasses(llvm::PassManagerBase &PM) {
|
||||
registerCanonicalicationPasses(PM, SCEVCodegen);
|
||||
|
||||
PM.add(polly::createScopInfoPass());
|
||||
|
@ -289,7 +276,7 @@ static void registerPollyPasses(llvm::PassManagerBase &PM) {
|
|||
PM.add(llvm::createCFGPrinterPass());
|
||||
}
|
||||
|
||||
static bool shouldEnablePolly() {
|
||||
bool shouldEnablePolly() {
|
||||
if (PollyOnlyPrinter || PollyPrinter || PollyOnlyViewer || PollyViewer)
|
||||
PollyTrackFailures = true;
|
||||
|
||||
|
@ -299,45 +286,4 @@ static bool shouldEnablePolly() {
|
|||
|
||||
return PollyEnabled;
|
||||
}
|
||||
|
||||
static void
|
||||
registerPollyEarlyAsPossiblePasses(const llvm::PassManagerBuilder &Builder,
|
||||
llvm::PassManagerBase &PM) {
|
||||
|
||||
if (!shouldEnablePolly())
|
||||
return;
|
||||
|
||||
registerPollyPasses(PM);
|
||||
}
|
||||
|
||||
/// @brief Register Polly to be available as an optimizer
|
||||
///
|
||||
/// We currently register Polly such that it runs as early as possible. This has
|
||||
/// several implications:
|
||||
///
|
||||
/// 1) We need to schedule more canonicalization passes
|
||||
///
|
||||
/// As nothing is run before Polly, it is necessary to run a set of preparing
|
||||
/// transformations before Polly to canonicalize the LLVM-IR and to allow
|
||||
/// Polly to detect and understand the code.
|
||||
///
|
||||
/// 2) LICM and LoopIdiom pass have not yet been run
|
||||
///
|
||||
/// Loop invariant code motion as well as the loop idiom recognition pass make
|
||||
/// it more difficult for Polly to transform code. LICM may introduce
|
||||
/// additional data dependences that are hard to eliminate and the loop idiom
|
||||
/// recognition pass may introduce calls to memset that we currently do not
|
||||
/// understand. By running Polly early enough (meaning before these passes) we
|
||||
/// avoid difficulties that may be introduced by these passes.
|
||||
///
|
||||
/// 3) We get the full -O3 optimization sequence after Polly
|
||||
///
|
||||
/// The LLVM-IR that is generated by Polly has been optimized on a high level,
|
||||
/// but it may be rather inefficient on the lower/scalar level. By scheduling
|
||||
/// Polly before all other passes, we have the full sequence of -O3
|
||||
/// optimizations behind us, such that inefficiencies on the low level can
|
||||
/// be optimized away.
|
||||
static llvm::RegisterStandardPasses
|
||||
RegisterPollyOptimizer(llvm::PassManagerBuilder::EP_EarlyAsPossible,
|
||||
registerPollyEarlyAsPossiblePasses);
|
||||
} // end of anonymous namespace.
|
||||
|
|
Loading…
Reference in New Issue