diff --git a/polly/lib/Support/PollyPasses.def b/polly/lib/Support/PollyPasses.def --- a/polly/lib/Support/PollyPasses.def +++ b/polly/lib/Support/PollyPasses.def @@ -9,14 +9,14 @@ #define FUNCTION_PASS(NAME, CREATE_PASS) #endif FUNCTION_PASS("polly-prepare", CodePreparationPass()) -FUNCTION_PASS("print", ScopAnalysisPrinterPass(errs())) -FUNCTION_PASS("print", ScopInfoPrinterPass(errs())) +FUNCTION_PASS("print", ScopAnalysisPrinterPass(llvm::errs())) +FUNCTION_PASS("print", ScopInfoPrinterPass(llvm::errs())) #undef FUNCTION_PASS #ifndef SCOP_ANALYSIS #define SCOP_ANALYSIS(NAME, CREATE_PASS) #endif -SCOP_ANALYSIS("pass-instrumentation", PassInstrumentationAnalysis(PIC)) +SCOP_ANALYSIS("pass-instrumentation", llvm::PassInstrumentationAnalysis(PIC)) SCOP_ANALYSIS("polly-ast", IslAstAnalysis()) SCOP_ANALYSIS("polly-dependences", DependenceAnalysis()) #undef SCOP_ANALYSIS @@ -26,17 +26,17 @@ #endif SCOP_PASS("polly-export-jscop", JSONExportPass()) SCOP_PASS("polly-import-jscop", JSONImportPass()) -SCOP_PASS("print", IslAstPrinterPass(outs())) -SCOP_PASS("print", DependenceInfoPrinterPass(outs())) +SCOP_PASS("print", IslAstPrinterPass(llvm::outs())) +SCOP_PASS("print", DependenceInfoPrinterPass(llvm::outs())) SCOP_PASS("polly-codegen", CodeGenerationPass()) SCOP_PASS("polly-simplify", SimplifyPass()) -SCOP_PASS("print", SimplifyPrinterPass(outs())) +SCOP_PASS("print", SimplifyPrinterPass(llvm::outs())) SCOP_PASS("polly-optree", ForwardOpTreePass()) -SCOP_PASS("print", ForwardOpTreePrinterPass(outs())) +SCOP_PASS("print", ForwardOpTreePrinterPass(llvm::outs())) SCOP_PASS("polly-delicm", DeLICMPass()) -SCOP_PASS("print", DeLICMPrinterPass(outs())) +SCOP_PASS("print", DeLICMPrinterPass(llvm::outs())) SCOP_PASS("polly-prune-unprofitable", PruneUnprofitablePass()) SCOP_PASS("polly-opt-isl", IslScheduleOptimizerPass()) -SCOP_PASS("print", IslScheduleOptimizerPrinterPass(outs())) +SCOP_PASS("print", IslScheduleOptimizerPrinterPass(llvm::outs())) SCOP_PASS("polly-dce", DeadCodeElimPass()) #undef SCOP_PASS diff --git a/polly/lib/Support/RegisterPasses.cpp b/polly/lib/Support/RegisterPasses.cpp --- a/polly/lib/Support/RegisterPasses.cpp +++ b/polly/lib/Support/RegisterPasses.cpp @@ -40,6 +40,7 @@ #include "polly/Support/DumpModulePass.h" #include "llvm/Analysis/CFGPrinter.h" #include "llvm/IR/LegacyPassManager.h" +#include "llvm/IR/PassManager.h" #include "llvm/IR/Verifier.h" #include "llvm/Passes/PassBuilder.h" #include "llvm/Passes/PassPlugin.h" @@ -48,12 +49,17 @@ #include "llvm/Transforms/IPO.h" #include "llvm/Transforms/IPO/PassManagerBuilder.h" -using namespace llvm; -using namespace polly; +namespace cl = llvm::cl; + +using llvm::FunctionPassManager; +using llvm::OptimizationLevel; +using llvm::PassBuilder; +using llvm::PassInstrumentationCallbacks; cl::OptionCategory PollyCategory("Polly Options", "Configure the polly loop optimizer"); +namespace polly { static cl::opt PollyEnabled("polly", cl::desc("Enable the polly optimizer (with -O1, -O2 or -O3)"), @@ -112,17 +118,17 @@ ), cl::init(TARGET_CPU), cl::ZeroOrMore, cl::cat(PollyCategory)); -VectorizerChoice polly::PollyVectorizerChoice; -static cl::opt Vectorizer( +VectorizerChoice PollyVectorizerChoice; + +static cl::opt Vectorizer( "polly-vectorizer", cl::desc("Select the vectorization strategy"), cl::values( - clEnumValN(polly::VECTORIZER_NONE, "none", "No Vectorization"), - clEnumValN(polly::VECTORIZER_POLLY, "polly", - "Polly internal vectorizer"), + clEnumValN(VECTORIZER_NONE, "none", "No Vectorization"), + clEnumValN(VECTORIZER_POLLY, "polly", "Polly internal vectorizer"), clEnumValN( - polly::VECTORIZER_STRIPMINE, "stripmine", + VECTORIZER_STRIPMINE, "stripmine", "Strip-mine outer loops for the loop-vectorizer to trigger")), - cl::location(PollyVectorizerChoice), cl::init(polly::VECTORIZER_NONE), + cl::location(PollyVectorizerChoice), cl::init(VECTORIZER_NONE), cl::ZeroOrMore, cl::cat(PollyCategory)); static cl::opt ImportJScop( @@ -237,8 +243,7 @@ static StaticInitializer InitializeEverything; } // end of anonymous namespace. -namespace polly { -void initializePollyPasses(PassRegistry &Registry) { +void initializePollyPasses(llvm::PassRegistry &Registry) { initializeCodeGenerationPass(Registry); #ifdef GPU_CODEGEN @@ -395,7 +400,7 @@ // FIXME: This dummy ModulePass keeps some programs from miscompiling, // probably some not correctly preserved analyses. It acts as a barrier to // force all analysis results to be recomputed. - PM.add(createBarrierNoopPass()); + PM.add(llvm::createBarrierNoopPass()); if (DumpAfter) PM.add(polly::createDumpModuleWrapperPass("-after", true)); @@ -491,15 +496,18 @@ } if (PollyViewer) - report_fatal_error("Option -polly-show not supported with NPM", false); + llvm::report_fatal_error("Option -polly-show not supported with NPM", + false); if (PollyOnlyViewer) - report_fatal_error("Option -polly-show-only not supported with NPM", false); + llvm::report_fatal_error("Option -polly-show-only not supported with NPM", + false); if (PollyPrinter) - report_fatal_error("Option -polly-dot not supported with NPM", false); + llvm::report_fatal_error("Option -polly-dot not supported with NPM", false); if (PollyOnlyPrinter) - report_fatal_error("Option -polly-dot-only not supported with NPM", false); + llvm::report_fatal_error("Option -polly-dot-only not supported with NPM", + false); if (EnablePolyhedralInfo) - report_fatal_error( + llvm::report_fatal_error( "Option -polly-enable-polyhedralinfo not supported with NPM", false); if (EnableSimplify) @@ -518,8 +526,8 @@ SPM.addPass(DeadCodeElimPass()); if (FullyIndexedStaticExpansion) - report_fatal_error("Option -polly-enable-mse not supported with NPM", - false); + llvm::report_fatal_error("Option -polly-enable-mse not supported with NPM", + false); if (EnablePruneUnprofitable) SPM.addPass(PruneUnprofitablePass()); @@ -535,7 +543,8 @@ } if (ExportJScop) - report_fatal_error("Option -polly-export not supported with NPM", false); + llvm::report_fatal_error("Option -polly-export not supported with NPM", + false); if (!EnableForOpt) return; @@ -544,8 +553,9 @@ switch (CodeGeneration) { case CODEGEN_AST: SPM.addPass( - RequireAnalysisPass()); + llvm::RequireAnalysisPass()); break; case CODEGEN_FULL: SPM.addPass(CodeGenerationPass()); @@ -556,25 +566,26 @@ } #ifdef GPU_CODEGEN else - report_fatal_error("Option -polly-target=gpu not supported for NPM", false); + llvm::report_fatal_error("Option -polly-target=gpu not supported for NPM", + false); #endif #ifdef GPU_CODEGEN if (Target == TARGET_HYBRID) - report_fatal_error("Option -polly-target=hybrid not supported for NPM", - false); + llvm::report_fatal_error( + "Option -polly-target=hybrid not supported for NPM", false); #endif PM.addPass(createFunctionToScopPassAdaptor(std::move(SPM))); PM.addPass(PB.buildFunctionSimplificationPipeline( - Level, ThinOrFullLTOPhase::None)); // Cleanup + Level, llvm::ThinOrFullLTOPhase::None)); // Cleanup if (CFGPrinter) PM.addPass(llvm::CFGPrinterPass()); } -static void buildEarlyPollyPipeline(ModulePassManager &MPM, - OptimizationLevel Level) { +static void buildEarlyPollyPipeline(llvm::ModulePassManager &MPM, + llvm::OptimizationLevel Level) { bool EnableForOpt = shouldEnablePollyForOptimization() && Level.isOptimizingForSpeed(); if (!shouldEnablePollyForDiagnostic() && !EnableForOpt) @@ -603,7 +614,7 @@ } static void buildLatePollyPipeline(FunctionPassManager &PM, - OptimizationLevel Level) { + llvm::OptimizationLevel Level) { bool EnableForOpt = shouldEnablePollyForOptimization() && Level.isOptimizingForSpeed(); if (!shouldEnablePollyForDiagnostic() && !EnableForOpt) @@ -612,18 +623,20 @@ if (DumpBefore) PM.addPass(DumpFunctionPass("-before")); if (!DumpBeforeFile.empty()) - report_fatal_error("Option -polly-dump-before-file at -polly-position=late " - "not supported with NPM", - false); + llvm::report_fatal_error( + "Option -polly-dump-before-file at -polly-position=late " + "not supported with NPM", + false); buildCommonPollyPipeline(PM, Level, EnableForOpt); if (DumpAfter) PM.addPass(DumpFunctionPass("-after")); if (!DumpAfterFile.empty()) - report_fatal_error("Option -polly-dump-after-file at -polly-position=late " - "not supported with NPM", - false); + llvm::report_fatal_error( + "Option -polly-dump-after-file at -polly-position=late " + "not supported with NPM", + false); } /// Register Polly to be available as an optimizer @@ -705,12 +718,12 @@ static bool parseFunctionPipeline(StringRef Name, FunctionPassManager &FPM, ArrayRef Pipeline) { - if (parseAnalysisUtilityPasses( + if (llvm::parseAnalysisUtilityPasses( "polly-scop-analyses", Name, FPM)) return true; #define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \ - if (parseAnalysisUtilityPasses< \ + if (llvm::parseAnalysisUtilityPasses< \ std::remove_reference::type>(NAME, Name, \ FPM)) \ return true; @@ -728,7 +741,7 @@ static bool parseScopPass(StringRef Name, ScopPassManager &SPM, PassInstrumentationCallbacks *PIC) { #define SCOP_ANALYSIS(NAME, CREATE_PASS) \ - if (parseAnalysisUtilityPasses< \ + if (llvm::parseAnalysisUtilityPasses< \ std::remove_reference::type>(NAME, Name, \ SPM)) \ return true; @@ -776,7 +789,8 @@ } static bool -parseTopLevelPipeline(ModulePassManager &MPM, PassInstrumentationCallbacks *PIC, +parseTopLevelPipeline(llvm::ModulePassManager &MPM, + PassInstrumentationCallbacks *PIC, ArrayRef Pipeline) { std::vector FullPipeline; StringRef FirstName = Pipeline.front().Name; @@ -814,7 +828,7 @@ return parseScopPipeline(Name, FPM, PIC, Pipeline); }); PB.registerParseTopLevelPipelineCallback( - [PIC](ModulePassManager &MPM, + [PIC](llvm::ModulePassManager &MPM, ArrayRef Pipeline) -> bool { return parseTopLevelPipeline(MPM, PIC, Pipeline); }); @@ -824,7 +838,7 @@ PB.registerPipelineStartEPCallback(buildEarlyPollyPipeline); break; case POSITION_AFTER_LOOPOPT: - report_fatal_error( + llvm::report_fatal_error( "Option -polly-position=after-loopopt not supported with NPM", false); break; case POSITION_BEFORE_VECTORIZER: