[polly] r303420 - [ScopDetection] Allow detection of full functions

Tobias Grosser via llvm-commits llvm-commits at lists.llvm.org
Fri May 19 05:13:03 PDT 2017


Author: grosser
Date: Fri May 19 07:13:02 2017
New Revision: 303420

URL: http://llvm.org/viewvc/llvm-project?rev=303420&view=rev
Log:
[ScopDetection] Allow detection of full functions

This is useful when only analyzing functions.

Added:
    polly/trunk/test/ScopInfo/full-function.ll
Modified:
    polly/trunk/lib/Analysis/ScopDetection.cpp

Modified: polly/trunk/lib/Analysis/ScopDetection.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopDetection.cpp?rev=303420&r1=303419&r2=303420&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopDetection.cpp (original)
+++ polly/trunk/lib/Analysis/ScopDetection.cpp Fri May 19 07:13:02 2017
@@ -96,6 +96,11 @@ static cl::opt<std::string> OnlyFunction
     cl::value_desc("string"), cl::ValueRequired, cl::init(""),
     cl::cat(PollyCategory));
 
+static cl::opt<bool>
+    AllowFullFunction("polly-detect-full-functions",
+                      cl::desc("Allow the detection of full functions"),
+                      cl::init(false), cl::cat(PollyCategory));
+
 static cl::opt<std::string> OnlyRegion(
     "polly-only-region",
     cl::desc("Only run on certain regions (The provided identifier must "
@@ -1502,8 +1507,9 @@ bool ScopDetection::isValidRegion(Detect
 
   // SCoP cannot contain the entry block of the function, because we need
   // to insert alloca instruction there when translate scalar to array.
-  if (CurRegion.getEntry() ==
-      &(CurRegion.getEntry()->getParent()->getEntryBlock()))
+  if (!AllowFullFunction &&
+      CurRegion.getEntry() ==
+          &(CurRegion.getEntry()->getParent()->getEntryBlock()))
     return invalid<ReportEntry>(Context, /*Assert=*/true, CurRegion.getEntry());
 
   if (!allBlocksValid(Context))

Added: polly/trunk/test/ScopInfo/full-function.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/full-function.ll?rev=303420&view=auto
==============================================================================
--- polly/trunk/test/ScopInfo/full-function.ll (added)
+++ polly/trunk/test/ScopInfo/full-function.ll Fri May 19 07:13:02 2017
@@ -0,0 +1,64 @@
+; RUN: opt %loadPolly -polly-scops -analyze -polly-detect-full-functions < %s \
+; RUN: | FileCheck %s -check-prefix=FULL
+; RUN: opt %loadPolly -polly-scops -analyze < %s \
+; RUN: | FileCheck %s -check-prefix=WITHOUT-FULL
+
+; FULL:      Statements {
+; FULL-NEXT: 	Stmt_loop_1
+; FULL-NEXT:         Domain :=
+; FULL-NEXT:             [p] -> { Stmt_loop_1[i0] : p = 42 and 0 <= i0 <= 1025 };
+; FULL-NEXT:         Schedule :=
+; FULL-NEXT:             [p] -> { Stmt_loop_1[i0] -> [1, i0] };
+; FULL-NEXT:         MustWriteAccess :=	[Reduction Type: NONE] [Scalar: 0]
+; FULL-NEXT:             [p] -> { Stmt_loop_1[i0] -> MemRef_A[0] };
+; FULL-NEXT: 	Stmt_loop_2
+; FULL-NEXT:         Domain :=
+; FULL-NEXT:             [p] -> { Stmt_loop_2[i0] : 0 <= i0 <= 1025 and (p >= 43 or p <= 41) };
+; FULL-NEXT:         Schedule :=
+; FULL-NEXT:             [p] -> { Stmt_loop_2[i0] -> [0, i0] : p >= 43 or p <= 41 };
+; FULL-NEXT:         MustWriteAccess :=	[Reduction Type: NONE] [Scalar: 0]
+; FULL-NEXT:             [p] -> { Stmt_loop_2[i0] -> MemRef_A[0] };
+; FULL-NEXT: }
+
+; WITHOUT-FULL:        Statements {
+; WITHOUT-FULL-NEXT:    	Stmt_loop_2
+; WITHOUT-FULL-NEXT:            Domain :=
+; WITHOUT-FULL-NEXT:                { Stmt_loop_2[i0] : 0 <= i0 <= 1025 };
+; WITHOUT-FULL-NEXT:            Schedule :=
+; WITHOUT-FULL-NEXT:                { Stmt_loop_2[i0] -> [i0] };
+; WITHOUT-FULL-NEXT:            MustWriteAccess :=	[Reduction Type: NONE] [Scalar: 0]
+; WITHOUT-FULL-NEXT:                { Stmt_loop_2[i0] -> MemRef_A[0] };
+; WITHOUT-FULL-NEXT:    }
+
+; WITHOUT-FULL:         Statements {
+; WITHOUT-FULL-NEXT:    	Stmt_loop_1
+; WITHOUT-FULL-NEXT:            Domain :=
+; WITHOUT-FULL-NEXT:                { Stmt_loop_1[i0] : 0 <= i0 <= 1025 };
+; WITHOUT-FULL-NEXT:            Schedule :=
+; WITHOUT-FULL-NEXT:                { Stmt_loop_1[i0] -> [i0] };
+; WITHOUT-FULL-NEXT:            MustWriteAccess :=	[Reduction Type: NONE] [Scalar: 0]
+; WITHOUT-FULL-NEXT:                { Stmt_loop_1[i0] -> MemRef_A[0] };
+; WITHOUT-FULL-NEXT:    }
+
+define void @foo(float* %A, i32 %p) {
+bb:
+  %cmp = icmp eq i32 %p, 42
+  br i1 %cmp, label %loop.1, label %loop.2
+
+loop.1:
+  %indvar.1 = phi i64 [0, %bb], [%indvar.next.1, %loop.1]
+  %indvar.next.1 = add i64 %indvar.1, 1
+  store float 42.0, float* %A
+  %cmp.1 = icmp sle i64 %indvar.1, 1024
+  br i1 %cmp.1, label %loop.1, label %merge
+
+loop.2:
+  %indvar.2 = phi i64 [0, %bb], [%indvar.next.2, %loop.2]
+  %indvar.next.2 = add i64 %indvar.2, 1
+  store float 42.0, float* %A
+  %cmp.2 = icmp sle i64 %indvar.2, 1024
+  br i1 %cmp.2, label %loop.2, label %merge
+
+merge:
+  ret void
+}




More information about the llvm-commits mailing list