[polly] r264140 - Add option to disallow modref function calls in scops.

Tobias Grosser via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 22 23:40:16 PDT 2016


Author: grosser
Date: Wed Mar 23 01:40:15 2016
New Revision: 264140

URL: http://llvm.org/viewvc/llvm-project?rev=264140&view=rev
Log:
Add option to disallow modref function calls in scops.

This might be useful to evaluate the benefit of us handling modref funciton
calls. Also, a new bug that was triggered by modref function calls was
recently reported http://llvm.org/PR27035. To ensure the same issue does not
cause troubles for other people, we temporarily disable this until the bug
is resolved.

Modified:
    polly/trunk/lib/Analysis/ScopDetection.cpp
    polly/trunk/test/ScopDetect/mod_ref_read_pointer.ll
    polly/trunk/test/ScopInfo/mod_ref_access_pointee_arguments.ll
    polly/trunk/test/ScopInfo/mod_ref_read_pointee_arguments.ll
    polly/trunk/test/ScopInfo/mod_ref_read_pointer.ll
    polly/trunk/test/ScopInfo/mod_ref_read_pointers.ll
    polly/trunk/test/ScopInfo/multidim_2d_with_modref_call.ll
    polly/trunk/test/ScopInfo/multidim_2d_with_modref_call_2.ll
    polly/trunk/test/ScopInfo/multidim_fortran_2d_with_modref_call.ll

Modified: polly/trunk/lib/Analysis/ScopDetection.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopDetection.cpp?rev=264140&r1=264139&r2=264140&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopDetection.cpp (original)
+++ polly/trunk/lib/Analysis/ScopDetection.cpp Wed Mar 23 01:40:15 2016
@@ -132,6 +132,12 @@ static cl::opt<bool>
                    cl::Hidden, cl::init(false), cl::ZeroOrMore,
                    cl::cat(PollyCategory));
 
+static cl::opt<bool>
+    AllowModrefCall("polly-allow-modref-calls",
+                    cl::desc("Allow functions with known modref behavior"),
+                    cl::Hidden, cl::init(false), cl::ZeroOrMore,
+                    cl::cat(PollyCategory));
+
 static cl::opt<bool> AllowNonAffineSubRegions(
     "polly-allow-nonaffine-branches",
     cl::desc("Allow non affine conditions for branches"), cl::Hidden,
@@ -470,39 +476,41 @@ bool ScopDetection::isValidCallInst(Call
   if (CalledFunction == 0)
     return false;
 
-  switch (AA->getModRefBehavior(CalledFunction)) {
-  case llvm::FMRB_UnknownModRefBehavior:
-    return false;
-  case llvm::FMRB_DoesNotAccessMemory:
-  case llvm::FMRB_OnlyReadsMemory:
-    // Implicitly disable delinearization since we have an unknown
-    // accesses with an unknown access function.
-    Context.HasUnknownAccess = true;
-    Context.AST.add(&CI);
-    return true;
-  case llvm::FMRB_OnlyReadsArgumentPointees:
-  case llvm::FMRB_OnlyAccessesArgumentPointees:
-    for (const auto &Arg : CI.arg_operands()) {
-      if (!Arg->getType()->isPointerTy())
-        continue;
-
-      // Bail if a pointer argument has a base address not known to
-      // ScalarEvolution. Note that a zero pointer is acceptable.
-      auto *ArgSCEV = SE->getSCEVAtScope(Arg, LI->getLoopFor(CI.getParent()));
-      if (ArgSCEV->isZero())
-        continue;
-
-      auto *BP = dyn_cast<SCEVUnknown>(SE->getPointerBase(ArgSCEV));
-      if (!BP)
-        return false;
-
+  if (AllowModrefCall) {
+    switch (AA->getModRefBehavior(CalledFunction)) {
+    case llvm::FMRB_UnknownModRefBehavior:
+      return false;
+    case llvm::FMRB_DoesNotAccessMemory:
+    case llvm::FMRB_OnlyReadsMemory:
       // Implicitly disable delinearization since we have an unknown
       // accesses with an unknown access function.
       Context.HasUnknownAccess = true;
-    }
+      Context.AST.add(&CI);
+      return true;
+    case llvm::FMRB_OnlyReadsArgumentPointees:
+    case llvm::FMRB_OnlyAccessesArgumentPointees:
+      for (const auto &Arg : CI.arg_operands()) {
+        if (!Arg->getType()->isPointerTy())
+          continue;
+
+        // Bail if a pointer argument has a base address not known to
+        // ScalarEvolution. Note that a zero pointer is acceptable.
+        auto *ArgSCEV = SE->getSCEVAtScope(Arg, LI->getLoopFor(CI.getParent()));
+        if (ArgSCEV->isZero())
+          continue;
+
+        auto *BP = dyn_cast<SCEVUnknown>(SE->getPointerBase(ArgSCEV));
+        if (!BP)
+          return false;
+
+        // Implicitly disable delinearization since we have an unknown
+        // accesses with an unknown access function.
+        Context.HasUnknownAccess = true;
+      }
 
-    Context.AST.add(&CI);
-    return true;
+      Context.AST.add(&CI);
+      return true;
+    }
   }
 
   return false;

Modified: polly/trunk/test/ScopDetect/mod_ref_read_pointer.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopDetect/mod_ref_read_pointer.ll?rev=264140&r1=264139&r2=264140&view=diff
==============================================================================
--- polly/trunk/test/ScopDetect/mod_ref_read_pointer.ll (original)
+++ polly/trunk/test/ScopDetect/mod_ref_read_pointer.ll Wed Mar 23 01:40:15 2016
@@ -1,6 +1,10 @@
-; RUN: opt %loadPolly -basicaa -polly-detect -analyze < %s | FileCheck %s
+; RUN: opt %loadPolly -basicaa -polly-detect -analyze \
+; RUN:  -polly-allow-modref-calls < %s | FileCheck %s -check-prefix=MODREF
+; RUN: opt %loadPolly -basicaa -polly-detect -analyze \
+; RUN:  < %s | FileCheck %s
 ;
-; CHECK: Valid Region for Scop: for.cond => for.end
+; CHECK-NOT: Valid Region for Scop: for.cond => for.end
+; MODREF: Valid Region for Scop: for.cond => for.end
 ;
 ;    #pragma readonly
 ;    int func(int *A);

Modified: polly/trunk/test/ScopInfo/mod_ref_access_pointee_arguments.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/mod_ref_access_pointee_arguments.ll?rev=264140&r1=264139&r2=264140&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/mod_ref_access_pointee_arguments.ll (original)
+++ polly/trunk/test/ScopInfo/mod_ref_access_pointee_arguments.ll Wed Mar 23 01:40:15 2016
@@ -1,5 +1,7 @@
-; RUN: opt %loadPolly -basicaa -polly-scops -analyze < %s | FileCheck %s
-; RUN: opt %loadPolly -basicaa -polly-codegen -disable-output < %s
+; RUN: opt %loadPolly -basicaa -polly-scops -analyze -polly-allow-modref-calls \
+; RUN:  < %s | FileCheck %s
+; RUN: opt %loadPolly -basicaa -polly-codegen -polly-allow-modref-calls \
+; RUN: -disable-output < %s
 ;
 ; Verify that we model the may-write access of the prefetch intrinsic
 ; correctly, thus that A is accessed by it but B is not.

Modified: polly/trunk/test/ScopInfo/mod_ref_read_pointee_arguments.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/mod_ref_read_pointee_arguments.ll?rev=264140&r1=264139&r2=264140&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/mod_ref_read_pointee_arguments.ll (original)
+++ polly/trunk/test/ScopInfo/mod_ref_read_pointee_arguments.ll Wed Mar 23 01:40:15 2016
@@ -1,5 +1,7 @@
-; RUN: opt %loadPolly -basicaa -polly-scops -analyze < %s | FileCheck %s
-; RUN: opt %loadPolly -basicaa -polly-codegen -disable-output < %s
+; RUN: opt %loadPolly -basicaa -polly-scops -analyze -polly-allow-modref-calls \
+; RUN: < %s | FileCheck %s
+; RUN: opt %loadPolly -basicaa -polly-codegen -disable-output \
+; RUN: -polly-allow-modref-calls < %s
 ;
 ; Verify that we model the read access of the gcread intrinsic
 ; correctly, thus that A is read by it but B is not.

Modified: polly/trunk/test/ScopInfo/mod_ref_read_pointer.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/mod_ref_read_pointer.ll?rev=264140&r1=264139&r2=264140&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/mod_ref_read_pointer.ll (original)
+++ polly/trunk/test/ScopInfo/mod_ref_read_pointer.ll Wed Mar 23 01:40:15 2016
@@ -1,5 +1,7 @@
-; RUN: opt %loadPolly -basicaa -polly-scops -analyze < %s | FileCheck %s
-; RUN: opt %loadPolly -basicaa -polly-codegen -disable-output < %s
+; RUN: opt %loadPolly -basicaa -polly-scops -analyze -polly-allow-modref-calls \
+; RUN:  < %s | FileCheck %s
+; RUN: opt %loadPolly -basicaa -polly-codegen -disable-output \
+; RUN: -polly-allow-modref-calls < %s
 ;
 ; Check that we assume the call to func has a read on the whole A array.
 ;

Modified: polly/trunk/test/ScopInfo/mod_ref_read_pointers.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/mod_ref_read_pointers.ll?rev=264140&r1=264139&r2=264140&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/mod_ref_read_pointers.ll (original)
+++ polly/trunk/test/ScopInfo/mod_ref_read_pointers.ll Wed Mar 23 01:40:15 2016
@@ -1,5 +1,7 @@
-; RUN: opt %loadPolly -basicaa -polly-scops -analyze < %s | FileCheck %s
-; RUN: opt %loadPolly -basicaa -polly-codegen -disable-output < %s
+; RUN: opt %loadPolly -basicaa -polly-scops -analyze -polly-allow-modref-calls \
+; RUN: < %s | FileCheck %s
+; RUN: opt %loadPolly -basicaa -polly-codegen -disable-output \
+; RUN: -polly-allow-modref-calls < %s
 ;
 ; Check that the call to func will "read" not only the A array but also the
 ; B array. The reason is the readonly annotation of func.

Modified: polly/trunk/test/ScopInfo/multidim_2d_with_modref_call.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/multidim_2d_with_modref_call.ll?rev=264140&r1=264139&r2=264140&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/multidim_2d_with_modref_call.ll (original)
+++ polly/trunk/test/ScopInfo/multidim_2d_with_modref_call.ll Wed Mar 23 01:40:15 2016
@@ -1,5 +1,7 @@
-; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s
-; RUN: opt %loadPolly -polly-scops -polly-allow-nonaffine -analyze < %s | FileCheck %s --check-prefix=NONAFFINE
+; RUN: opt %loadPolly -polly-scops -analyze -polly-allow-modref-calls \
+; RUN: < %s | FileCheck %s
+; RUN: opt %loadPolly -polly-scops -polly-allow-nonaffine -analyze \
+; RUN: -polly-allow-modref-calls < %s | FileCheck %s --check-prefix=NONAFFINE
 
 ;  TODO: We should delinearize the accesses despite the use in a call to a
 ;        readonly function. For now we verify we do not delinearize them though.

Modified: polly/trunk/test/ScopInfo/multidim_2d_with_modref_call_2.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/multidim_2d_with_modref_call_2.ll?rev=264140&r1=264139&r2=264140&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/multidim_2d_with_modref_call_2.ll (original)
+++ polly/trunk/test/ScopInfo/multidim_2d_with_modref_call_2.ll Wed Mar 23 01:40:15 2016
@@ -1,5 +1,7 @@
-; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s
-; RUN: opt %loadPolly -polly-scops -polly-allow-nonaffine -analyze < %s | FileCheck %s --check-prefix=NONAFFINE
+; RUN: opt %loadPolly -polly-scops -analyze -polly-allow-modref-calls \
+; RUN: < %s | FileCheck %s
+; RUN: opt %loadPolly -polly-scops -polly-allow-nonaffine \
+; RUN: -polly-allow-modref-calls -analyze < %s | FileCheck %s --check-prefix=NONAFFINE
 
 ;  TODO: We should delinearize the accesses despite the use in a call to a
 ;        readonly function. For now we verify we do not delinearize them though.

Modified: polly/trunk/test/ScopInfo/multidim_fortran_2d_with_modref_call.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/multidim_fortran_2d_with_modref_call.ll?rev=264140&r1=264139&r2=264140&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/multidim_fortran_2d_with_modref_call.ll (original)
+++ polly/trunk/test/ScopInfo/multidim_fortran_2d_with_modref_call.ll Wed Mar 23 01:40:15 2016
@@ -1,5 +1,7 @@
-; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s
-; RUN: opt %loadPolly -polly-scops -polly-allow-nonaffine -analyze < %s | FileCheck %s --check-prefix=NONAFFINE
+; RUN: opt %loadPolly -polly-scops -analyze -polly-allow-modref-calls \
+; RUN:  < %s | FileCheck %s
+; RUN: opt %loadPolly -polly-scops -polly-allow-nonaffine -analyze \
+; RUN: -polly-allow-modref-calls < %s | FileCheck %s --check-prefix=NONAFFINE
 
 ;  TODO: We should delinearize the accesses despite the use in a call to a
 ;        readonly function. For now we verify we do not delinearize them though.




More information about the llvm-commits mailing list