[PATCH] D36926: [Polly][WIP] Clear DependenceInfo after expansion

Bonfante Nicolas via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 19 09:48:51 PDT 2017


niosega created this revision.
Herald added a subscriber: fhahn.
Herald added a reviewer: bollu.

For expansion to have effect on the generated IR, the DependenceInfo need to be cleared after expansion.

To do that, I take inspiration from JSONImporter which basically do the same things as expansion : modifying scop.
Unfortunately, the generated IRs has no traces of any expansion.

To generate the optimised IR as I use the following command :

  clang-5.0 -O3 -mllvm -polly -mllvm -polly-enable-mse -mllvm -debug-pass=Structure -Rpass-analysis="polly-mse" <c_file> -o <output_ll_file>-S -emit-llvm

where <c_file> is the input c file and <output_ll_file> is the optimised IR.
With clang, the generated IR does not take into account the expansion.

I also try with opt alone with the following command :

  opt -pass-remarks-analysis="polly-*" -polly-process-unprofitable  -polly-remarks-minimal  -polly-use-llvm-names  -polly-import-jscop-dir=<local_path>  -polly-mse -S < <input_ll_file>

where <input_ll_file> is any working test case file.
With opt, I get exactly the same IR that is in the test case file.

Moreover, I tried to generate code after importing a jscop file (without doing expansion, only importing jscop file),  and I didn't succeed to have any effect on the newly created IR.

In both cases (JSONImporter and MaximalStaticExpansion), the scop is modified because the printings are correct. But the generated IR does not take into account these modifications.

Anyone have an idea why my implementation of DependenceInfo clearing doesn't work ?


https://reviews.llvm.org/D36926

Files:
  include/polly/MaximalStaticExpansion.h
  lib/Support/PollyPasses.def
  lib/Support/RegisterPasses.cpp
  lib/Transform/MaximalStaticExpansion.cpp


Index: lib/Transform/MaximalStaticExpansion.cpp
===================================================================
--- lib/Transform/MaximalStaticExpansion.cpp
+++ lib/Transform/MaximalStaticExpansion.cpp
@@ -12,6 +12,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "polly/MaximalStaticExpansion.h"
 #include "polly/DependenceInfo.h"
 #include "polly/FlattenAlgo.h"
 #include "polly/LinkAllPasses.h"
@@ -459,6 +460,19 @@
   return new MaximalStaticExpander();
 }
 
+PreservedAnalyses MaximalStaticExpandPass::run(Scop &S,
+                                               ScopAnalysisManager &SAM,
+                                               ScopStandardAnalysisResults &SAR,
+                                               SPMUpdater &) {
+
+  // Invalidate all analyses on Scop.
+  PreservedAnalyses PA;
+  PA.preserveSet<AllAnalysesOn<Module>>();
+  PA.preserveSet<AllAnalysesOn<Function>>();
+  PA.preserveSet<AllAnalysesOn<Loop>>();
+  return PA;
+}
+
 INITIALIZE_PASS_BEGIN(MaximalStaticExpander, "polly-mse",
                       "Polly - Maximal static expansion of SCoP", false, false);
 INITIALIZE_PASS_DEPENDENCY(DependenceInfo);
Index: lib/Support/RegisterPasses.cpp
===================================================================
--- lib/Support/RegisterPasses.cpp
+++ lib/Support/RegisterPasses.cpp
@@ -32,6 +32,7 @@
 #include "polly/ForwardOpTree.h"
 #include "polly/JSONExporter.h"
 #include "polly/LinkAllPasses.h"
+#include "polly/MaximalStaticExpansion.h"
 #include "polly/Options.h"
 #include "polly/PolyhedralInfo.h"
 #include "polly/ScopDetection.h"
@@ -479,6 +480,8 @@
   if (ImportJScop)
     SPM.addPass(JSONImportPass());
   assert(!DeadCodeElim && "This option is not implemented");
+  if (FullyIndexedStaticExpansion)
+    SPM.addPass(MaximalStaticExpandPass());
   assert(!EnablePruneUnprofitable && "This option is not implemented");
   if (Target == TARGET_CPU || Target == TARGET_HYBRID)
     switch (Optimizer) {
Index: lib/Support/PollyPasses.def
===================================================================
--- lib/Support/PollyPasses.def
+++ lib/Support/PollyPasses.def
@@ -25,6 +25,7 @@
 #endif
 SCOP_PASS("polly-export-jscop", JSONExportPass())
 SCOP_PASS("polly-import-jscop", JSONImportPass())
+SCOP_PASS("polly-mse", MaximalStaticExpandPass())
 SCOP_PASS("print<polly-ast>", IslAstPrinterPass(outs()))
 SCOP_PASS("print<polly-dependences>", DependenceInfoPrinterPass(outs()))
 SCOP_PASS("polly-codegen", CodeGenerationPass())
Index: include/polly/MaximalStaticExpansion.h
===================================================================
--- /dev/null
+++ include/polly/MaximalStaticExpansion.h
@@ -0,0 +1,24 @@
+//===- polly/MaximalStaticExpander.h - Expand fully all memory accesses.-*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===------------------------------------------------------------------------------===//
+
+#ifndef POLLY_MSE_H
+#define POLLY_MSE_H
+
+#include "polly/ScopPass.h"
+#include "llvm/IR/PassManager.h"
+
+namespace polly {
+struct MaximalStaticExpandPass
+    : public llvm::PassInfoMixin<MaximalStaticExpandPass> {
+  llvm::PreservedAnalyses run(Scop &, ScopAnalysisManager &,
+                              ScopStandardAnalysisResults &, SPMUpdater &);
+};
+} // namespace polly
+
+#endif /* POLLY_MSE_H */


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36926.111832.patch
Type: text/x-patch
Size: 3507 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170819/db7cdb54/attachment.bin>


More information about the llvm-commits mailing list