[polly] r288160 - [DeLICM] Add pass boilerplate code.
Michael Kruse via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 29 08:41:21 PST 2016
Author: meinersbur
Date: Tue Nov 29 10:41:21 2016
New Revision: 288160
URL: http://llvm.org/viewvc/llvm-project?rev=288160&view=rev
Log:
[DeLICM] Add pass boilerplate code.
Add an empty DeLICM pass, without any functional parts.
Extracting the boilerplate from the the functional part reduces the size of the
code to review (https://reviews.llvm.org/D24716)
Suggested-by: Tobias Grosser <tobias at grosser.es>
Added:
polly/trunk/include/polly/DeLICM.h
polly/trunk/lib/Transform/DeLICM.cpp
polly/trunk/test/DeLICM/
polly/trunk/test/DeLICM/pass_existance.ll
Modified:
polly/trunk/include/polly/LinkAllPasses.h
polly/trunk/lib/CMakeLists.txt
polly/trunk/lib/Support/RegisterPasses.cpp
Added: polly/trunk/include/polly/DeLICM.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/DeLICM.h?rev=288160&view=auto
==============================================================================
--- polly/trunk/include/polly/DeLICM.h (added)
+++ polly/trunk/include/polly/DeLICM.h Tue Nov 29 10:41:21 2016
@@ -0,0 +1,35 @@
+//===------ DeLICM.h --------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// Undo the effect of Loop Invariant Code Motion (LICM) and
+// GVN Partial Redundancy Elimination (PRE) on SCoP-level.
+//
+// Namely, remove register/scalar dependencies by mapping them back to array
+// elements.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef POLLY_DELICM_H
+#define POLLY_DELICM_H
+
+namespace llvm {
+class PassRegistry;
+class Pass;
+} // anonymous namespace
+
+namespace polly {
+/// Create a new DeLICM pass instance.
+llvm::Pass *createDeLICMPass();
+} // namespace polly
+
+namespace llvm {
+void initializeDeLICMPass(llvm::PassRegistry &);
+} // namespace llvm
+
+#endif /* POLLY_DELICM_H */
Modified: polly/trunk/include/polly/LinkAllPasses.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/LinkAllPasses.h?rev=288160&r1=288159&r2=288160&view=diff
==============================================================================
--- polly/trunk/include/polly/LinkAllPasses.h (original)
+++ polly/trunk/include/polly/LinkAllPasses.h Tue Nov 29 10:41:21 2016
@@ -48,6 +48,7 @@ llvm::Pass *createPPCGCodeGenerationPass
#endif
llvm::Pass *createIslScheduleOptimizerPass();
llvm::Pass *createFlattenSchedulePass();
+llvm::Pass *createDeLICMPass();
extern char &CodePreparationID;
} // namespace polly
@@ -82,6 +83,7 @@ struct PollyForcePassLinking {
#endif
polly::createIslScheduleOptimizerPass();
polly::createFlattenSchedulePass();
+ polly::createDeLICMPass();
}
} PollyForcePassLinking; // Force link by creating a global definition.
} // namespace
@@ -100,6 +102,7 @@ void initializePPCGCodeGenerationPass(ll
void initializeIslScheduleOptimizerPass(llvm::PassRegistry &);
void initializePollyCanonicalizePass(llvm::PassRegistry &);
void initializeFlattenSchedulePass(llvm::PassRegistry &);
+void initializeDeLICMPass(llvm::PassRegistry &);
} // namespace llvm
#endif
Modified: polly/trunk/lib/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CMakeLists.txt?rev=288160&r1=288159&r2=288160&view=diff
==============================================================================
--- polly/trunk/lib/CMakeLists.txt (original)
+++ polly/trunk/lib/CMakeLists.txt Tue Nov 29 10:41:21 2016
@@ -57,6 +57,7 @@ add_polly_library(Polly
Transform/ScheduleOptimizer.cpp
Transform/FlattenSchedule.cpp
Transform/FlattenAlgo.cpp
+ Transform/DeLICM.cpp
${POLLY_HEADER_FILES}
)
Modified: polly/trunk/lib/Support/RegisterPasses.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Support/RegisterPasses.cpp?rev=288160&r1=288159&r2=288160&view=diff
==============================================================================
--- polly/trunk/lib/Support/RegisterPasses.cpp (original)
+++ polly/trunk/lib/Support/RegisterPasses.cpp Tue Nov 29 10:41:21 2016
@@ -23,6 +23,7 @@
#include "polly/Canonicalization.h"
#include "polly/CodeGen/CodeGeneration.h"
#include "polly/CodeGen/CodegenCleanup.h"
+#include "polly/DeLICM.h"
#include "polly/DependenceInfo.h"
#include "polly/FlattenSchedule.h"
#include "polly/LinkAllPasses.h"
@@ -159,6 +160,11 @@ static cl::opt<bool>
cl::desc("Enable polyhedral interface of Polly"),
cl::Hidden, cl::init(false), cl::cat(PollyCategory));
+static cl::opt<bool>
+ EnableDeLICM("polly-enable-delicm",
+ cl::desc("Eliminate scalar loop carried dependences"),
+ cl::Hidden, cl::init(false), cl::cat(PollyCategory));
+
namespace polly {
void initializePollyPasses(PassRegistry &Registry) {
initializeCodeGenerationPass(Registry);
@@ -181,6 +187,7 @@ void initializePollyPasses(PassRegistry
initializeScopInfoWrapperPassPass(Registry);
initializeCodegenCleanupPass(Registry);
initializeFlattenSchedulePass(Registry);
+ initializeDeLICMPass(Registry);
}
/// Register Polly passes such that they form a polyhedral optimizer.
@@ -228,6 +235,9 @@ void registerPollyPasses(llvm::legacy::P
if (EnablePolyhedralInfo)
PM.add(polly::createPolyhedralInfoPass());
+ if (EnableDeLICM)
+ PM.add(polly::createDeLICMPass());
+
if (ImportJScop)
PM.add(polly::createJSONImporterPass());
Added: polly/trunk/lib/Transform/DeLICM.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Transform/DeLICM.cpp?rev=288160&view=auto
==============================================================================
--- polly/trunk/lib/Transform/DeLICM.cpp (added)
+++ polly/trunk/lib/Transform/DeLICM.cpp Tue Nov 29 10:41:21 2016
@@ -0,0 +1,70 @@
+//===------ DeLICM.cpp -----------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// Undo the effect of Loop Invariant Code Motion (LICM) and
+// GVN Partial Redundancy Elimination (PRE) on SCoP-level.
+//
+// Namely, remove register/scalar dependencies by mapping them back to array
+// elements.
+//
+//===----------------------------------------------------------------------===//
+
+#include "polly/DeLICM.h"
+#include "polly/ScopInfo.h"
+#include "polly/ScopPass.h"
+#define DEBUG_TYPE "polly-delicm"
+
+using namespace polly;
+using namespace llvm;
+
+namespace {
+
+class DeLICM : public ScopPass {
+private:
+ DeLICM(const DeLICM &) = delete;
+ const DeLICM &operator=(const DeLICM &) = delete;
+
+public:
+ static char ID;
+ explicit DeLICM() : ScopPass(ID) {}
+
+ virtual void getAnalysisUsage(AnalysisUsage &AU) const override {
+ AU.addRequiredTransitive<ScopInfoRegionPass>();
+ AU.setPreservesAll();
+ }
+
+ virtual bool runOnScop(Scop &S) override {
+ // Free resources for previous scop's computation, if not yet done.
+ releaseMemory();
+
+ // TODO: Run DeLICM algorithm
+
+ return false;
+ }
+
+ virtual void printScop(raw_ostream &OS, Scop &S) const override {
+ OS << "DeLICM result:\n";
+ // TODO: Print analysis results and performed transformation details
+ }
+
+ virtual void releaseMemory() override {
+ // TODO: Release resources (eg. shared_ptr to isl_ctx)
+ }
+};
+
+char DeLICM::ID;
+} // anonymous namespace
+
+Pass *polly::createDeLICMPass() { return new DeLICM(); }
+
+INITIALIZE_PASS_BEGIN(DeLICM, "polly-delicm", "Polly - DeLICM/DePRE", false,
+ false)
+INITIALIZE_PASS_DEPENDENCY(ScopInfoWrapperPass)
+INITIALIZE_PASS_END(DeLICM, "polly-delicm", "Polly - DeLICM/DePRE", false,
+ false)
Added: polly/trunk/test/DeLICM/pass_existance.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/DeLICM/pass_existance.ll?rev=288160&view=auto
==============================================================================
--- polly/trunk/test/DeLICM/pass_existance.ll (added)
+++ polly/trunk/test/DeLICM/pass_existance.ll Tue Nov 29 10:41:21 2016
@@ -0,0 +1,36 @@
+; RUN: opt %loadPolly -polly-delicm -analyze < %s | FileCheck %s
+;
+; Simple test for the existence of the DeLICM pass.
+;
+; // Simplest detected SCoP to run DeLICM on.
+; for (int j = 0; j < n; j += 1) {
+; body: A[0] = 0.0;
+; }
+;
+define void @func(i32 %n, double* noalias nonnull %A) {
+entry:
+ br label %for
+
+for:
+ %j = phi i32 [0, %entry], [%j.inc, %inc]
+ %j.cmp = icmp slt i32 %j, %n
+ br i1 %j.cmp, label %body, label %exit
+
+ body:
+ store double 0.0, double* %A
+ br label %inc
+
+inc:
+ %j.inc = add nuw nsw i32 %j, 1
+ br label %for
+
+exit:
+ br label %return
+
+return:
+ ret void
+}
+
+
+; Verify that the DeLICM has a custom printScop() function.
+; CHECK: DeLICM result:
More information about the llvm-commits
mailing list