[polly] r233480 - Bail out if too many alias run-time-check comparisions would be needed

Tobias Grosser tobias at grosser.es
Sat Mar 28 08:11:14 PDT 2015


Author: grosser
Date: Sat Mar 28 10:11:14 2015
New Revision: 233480

URL: http://llvm.org/viewvc/llvm-project?rev=233480&view=rev
Log:
Bail out if too many alias run-time-check comparisions would be needed

This fixes a crash observed in ffmpeg.

Added:
    polly/trunk/test/ScopInfo/aliasing_many_arrays_to_compare.ll
Modified:
    polly/trunk/lib/Analysis/ScopInfo.cpp

Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=233480&r1=233479&r2=233480&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Sat Mar 28 10:11:14 2015
@@ -68,6 +68,11 @@ static cl::opt<unsigned> RunTimeChecksMa
     cl::desc("The maximal number of parameters allowed in RTCs."), cl::Hidden,
     cl::ZeroOrMore, cl::init(8), cl::cat(PollyCategory));
 
+static cl::opt<unsigned> RunTimeChecksMaxArraysPerGroup(
+    "polly-rtc-max-arrays-per-group",
+    cl::desc("The maximal number of arrays to compare in each alias group."),
+    cl::Hidden, cl::ZeroOrMore, cl::init(20), cl::cat(PollyCategory));
+
 /// Translate a 'const SCEV *' expression in an isl_pw_aff.
 struct SCEVAffinator : public SCEVVisitor<SCEVAffinator, isl_pw_aff *> {
 public:
@@ -1559,6 +1564,13 @@ bool Scop::buildAliasGroups(AliasAnalysi
       return false;
   }
 
+  // Bail out if the number of values we need to compare is too large.
+  // This is important as the number of comparisions grows quadratically with
+  // the number of values we need to compare.
+  for (const auto *Values : MinMaxAliasGroups)
+    if (Values->size() > RunTimeChecksMaxArraysPerGroup)
+      return false;
+
   return true;
 }
 

Added: polly/trunk/test/ScopInfo/aliasing_many_arrays_to_compare.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/aliasing_many_arrays_to_compare.ll?rev=233480&view=auto
==============================================================================
--- polly/trunk/test/ScopInfo/aliasing_many_arrays_to_compare.ll (added)
+++ polly/trunk/test/ScopInfo/aliasing_many_arrays_to_compare.ll Sat Mar 28 10:11:14 2015
@@ -0,0 +1,52 @@
+; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s --check-prefix=FOUND
+; RUN: opt %loadPolly -polly-scops -analyze -polly-rtc-max-arrays-per-group=3 < %s | FileCheck %s --check-prefix=IGNORED
+;
+; FOUND: Function: foo
+; IGNORED-NOT: Function: foo
+;
+;    void foo(float *A, float *B, float *C, float *D) {
+;      for (long i = 0; i < 100; i++) {
+;        A[i]++;
+;        B[i]++;
+;        C[i]++;
+;        D[i]++;
+;      }
+;    }
+;
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+
+define void @foo(float* %A, float* %B, float* %C, float* %D) {
+entry:
+  br label %for.cond
+
+for.cond:                                         ; preds = %for.inc, %entry
+  %i.0 = phi i64 [ 0, %entry ], [ %inc7, %for.inc ]
+  %exitcond = icmp ne i64 %i.0, 100
+  br i1 %exitcond, label %for.body, label %for.end
+
+for.body:                                         ; preds = %for.cond
+  %arrayidx = getelementptr inbounds float, float* %A, i64 %i.0
+  %tmp = load float, float* %arrayidx, align 4
+  %inc = fadd float %tmp, 1.000000e+00
+  store float %inc, float* %arrayidx, align 4
+  %arrayidx1 = getelementptr inbounds float, float* %B, i64 %i.0
+  %tmp1 = load float, float* %arrayidx1, align 4
+  %inc2 = fadd float %tmp1, 1.000000e+00
+  store float %inc2, float* %arrayidx1, align 4
+  %arrayidx3 = getelementptr inbounds float, float* %C, i64 %i.0
+  %tmp2 = load float, float* %arrayidx3, align 4
+  %inc4 = fadd float %tmp2, 1.000000e+00
+  store float %inc4, float* %arrayidx3, align 4
+  %arrayidx5 = getelementptr inbounds float, float* %D, i64 %i.0
+  %tmp3 = load float, float* %arrayidx5, align 4
+  %inc6 = fadd float %tmp3, 1.000000e+00
+  store float %inc6, float* %arrayidx5, align 4
+  br label %for.inc
+
+for.inc:                                          ; preds = %for.body
+  %inc7 = add nuw nsw i64 %i.0, 1
+  br label %for.cond
+
+for.end:                                          ; preds = %for.cond
+  ret void
+}





More information about the llvm-commits mailing list