[llvm-commits] [polly] r130975 - in /polly/trunk: include/polly/ScopDetection.h lib/Analysis/ScopDetection.cpp lib/CodeGeneration.cpp test/CodeGen/OpenMP/invalidate_subfn_scops.ll

Hongbin Zheng etherzhhb at gmail.com
Thu May 5 19:38:20 PDT 2011


Author: ether
Date: Thu May  5 21:38:20 2011
New Revision: 130975

URL: http://llvm.org/viewvc/llvm-project?rev=130975&view=rev
Log:
ScopDetection: Remember the functions generated by backend in a pointer set, so we
  do not re-generate code for these functions.

Modified:
    polly/trunk/include/polly/ScopDetection.h
    polly/trunk/lib/Analysis/ScopDetection.cpp
    polly/trunk/lib/CodeGeneration.cpp
    polly/trunk/test/CodeGen/OpenMP/invalidate_subfn_scops.ll

Modified: polly/trunk/include/polly/ScopDetection.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopDetection.h?rev=130975&r1=130974&r2=130975&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopDetection.h (original)
+++ polly/trunk/include/polly/ScopDetection.h Thu May  5 21:38:20 2011
@@ -102,6 +102,10 @@
   typedef std::set<const Region*> RegionSet;
   RegionSet ValidRegions;
 
+  // Remember the invalid functions producted by backends;
+  typedef std::set<const Function*> FunctionSet;
+  FunctionSet InvalidFunctions;
+
   // Try to expand the region R. If R can be expanded return the expanded
   // region, NULL otherwise.
   Region *expandRegion(Region &R);
@@ -248,6 +252,14 @@
     ValidRegions.erase(&R);
   }
 
+  /// @brief Mark the function as invalid so we will not extract any scop from
+  ///        the function.
+  ///
+  /// @param F The function to mark as invalid.
+  void markFunctionAsInvalid(const Function *F) {
+    InvalidFunctions.insert(F);
+  }
+
   /// @brief Verify if all valid Regions in this Function are still valid
   /// after some transformations.
   void verifyAnalysis() const;

Modified: polly/trunk/lib/Analysis/ScopDetection.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopDetection.cpp?rev=130975&r1=130974&r2=130975&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopDetection.cpp (original)
+++ polly/trunk/lib/Analysis/ScopDetection.cpp Thu May  5 21:38:20 2011
@@ -594,12 +594,7 @@
 }
 
 bool ScopDetection::isValidFunction(llvm::Function &F) {
-  const std::string &Name = F.getNameStr();
-  size_t found = Name.find(".omp_subfn");
-  if (found != std::string::npos)
-    return false;
-  else
-    return true;
+  return !InvalidFunctions.count(&F);
 }
 
 bool ScopDetection::runOnFunction(llvm::Function &F) {
@@ -650,6 +645,7 @@
 
 void ScopDetection::releaseMemory() {
   ValidRegions.clear();
+  // Do not clear the invalid function set.
 }
 
 char ScopDetection::ID = 0;

Modified: polly/trunk/lib/CodeGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGeneration.cpp?rev=130975&r1=130974&r2=130975&view=diff
==============================================================================
--- polly/trunk/lib/CodeGeneration.cpp (original)
+++ polly/trunk/lib/CodeGeneration.cpp Thu May  5 21:38:20 2011
@@ -678,8 +678,8 @@
   // The Scop we code generate.
   Scop *S;
   ScalarEvolution &SE;
-
   DominatorTree *DT;
+  ScopDetection *SD;
   Dependences *DP;
   TargetData *TD;
 
@@ -834,6 +834,8 @@
     std::vector<const Type*> Arguments(1, Builder.getInt8PtrTy());
     FunctionType *FT = FunctionType::get(Builder.getVoidTy(), Arguments, false);
     Function *FN = Function::Create(FT, Function::InternalLinkage, Name, M);
+    // Do not run any polly pass on the new function.
+    SD->markFunctionAsInvalid(FN);
 
     Function::arg_iterator AI = FN->arg_begin();
     AI->setName("omp.userContext");
@@ -1251,8 +1253,10 @@
   }
 
   ClastStmtCodeGen(Scop *scop, ScalarEvolution &se, DominatorTree *dt,
-                   Dependences *dp, TargetData *td, IRBuilder<> &B) :
-    S(scop), SE(se), DT(dt), DP(dp), TD(td), Builder(B), ExpGen(Builder, NULL) {}
+                   ScopDetection *sd, Dependences *dp, TargetData *td,
+                   IRBuilder<> &B) :
+    S(scop), SE(se), DT(dt), SD(sd), DP(dp), TD(td), Builder(B),
+    ExpGen(Builder, NULL) {}
 
 };
 }
@@ -1369,7 +1373,7 @@
 
     const clast_root *clast = (const clast_root *) C->getClast();
 
-    ClastStmtCodeGen CodeGen(S, *SE, DT, DP, TD, Builder);
+    ClastStmtCodeGen CodeGen(S, *SE, DT, SD, DP, TD, Builder);
 
     if (OpenMP)
       addOpenMPDefinitions(Builder);

Modified: polly/trunk/test/CodeGen/OpenMP/invalidate_subfn_scops.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/CodeGen/OpenMP/invalidate_subfn_scops.ll?rev=130975&r1=130974&r2=130975&view=diff
==============================================================================
--- polly/trunk/test/CodeGen/OpenMP/invalidate_subfn_scops.ll (original)
+++ polly/trunk/test/CodeGen/OpenMP/invalidate_subfn_scops.ll Thu May  5 21:38:20 2011
@@ -1,5 +1,5 @@
 ; ModuleID = 'test.ll'
-; RUN: opt %loadPolly %defaultOpts -basicaa -polly-codegen -enable-polly-openmp  < %s | not FileCheck %s
+; RUN: opt %loadPolly %defaultOpts -polly-codegen -enable-polly-openmp -analyze %s -debug-only=polly-detect 2>&1 | not FileCheck %s
 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"
 target triple = "i386-pc-linux-gnu"
 
@@ -35,4 +35,4 @@
 }
 
 
-; CHECK: define internal void @main.omp_subfn.omp_subfn
+; CHECK: Checking region: omp.setup





More information about the llvm-commits mailing list