[PATCH] D12072: [FIX] Restrict the AST build with the assumed context

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 16 23:21:37 PDT 2015


jdoerfert created this revision.
jdoerfert added reviewers: grosser, Meinersbur.
jdoerfert added a subscriber: Polly.

  This is necessary as the dependence analysis is restricted by the
  assumed context as well and the AST generation needs to be in-sync.
  Otherwise this might generate not executed code that will crash the
  scalar code generation. Additionally, this change can simplify the AST
  as less conditions and code needs to be generated.

http://reviews.llvm.org/D12072

Files:
  lib/CodeGen/IslAst.cpp
  test/Isl/CodeGen/assumed_context_empty_domain_restriction.ll

Index: test/Isl/CodeGen/assumed_context_empty_domain_restriction.ll
===================================================================
--- test/Isl/CodeGen/assumed_context_empty_domain_restriction.ll
+++ test/Isl/CodeGen/assumed_context_empty_domain_restriction.ll
@@ -1,18 +1,19 @@
-; RUN: opt %loadPolly -S -polly-opt-isl -polly-codegen < %s
+; RUN: opt %loadPolly -S -polly-opt-isl -polly-ast -analyze < %s | FileCheck --check-prefix=AST %s
+; RUN: opt %loadPolly -S -polly-opt-isl -polly-codegen < %s | FileCheck %s
 ;
-; TODO: This test will crash the scalar code generation. The problem step by step:
-;         1) The assumed context is empty because of the out-of-bounds array access.
-;         2) The dependence analysis will use the assumed context and determine
-;            that there are not iterations executed, hence no dependences.
-;         3) The scheduler will transform the program somehow according to
-;            the orginal domains and empty dependences but not the assumed context.
-;            The new ast is shown below.
-;         4) The code generation will look for the new value of %0 when the
-;            for_body_328_lr_ph statement is copied, however it has not yet seen %0
-;            as the for_end_310 statement has been moved after for_body_328_lr_ph.
-;         5) Crash as no new value of %0 can be found.
+; This test crashed the scalar code generation. The problem step by step:
+;   1) The assumed context is empty because of the out-of-bounds array access.
+;   2) The dependence analysis will use the assumed context and determine
+;      that there are not iterations executed, hence no dependences.
+;   3) The scheduler will transform the program somehow according to
+;      the orginal domains and empty dependences but not the assumed context.
+;      The new and the old ast is shown below.
+;   4) The code generation will look for the new value of %0 when the
+;      for_body_328_lr_ph statement is copied, however it has not yet seen %0
+;      as the for_end_310 statement has been moved after for_body_328_lr_ph.
+;   5) Crash as no new value of %0 can be found.
 ;
-; AST:
+; AST old:
 ;
 ;   if (0)
 ;       {
@@ -24,11 +25,12 @@
 ;   else
 ;       {  /* original code */ }
 ;
-; CHECK: polly.start
-;
-; TODO: This test should not crash Polly.
+; AST new:
+; AST:  if (0)
+; AST:    {
+; AST:    }
 ;
-; XFAIL: *
+; CHECK: polly.start
 ;
 @endposition = external global i32, align 4
 @Bit = external global [0 x i32], align 4
Index: lib/CodeGen/IslAst.cpp
===================================================================
--- lib/CodeGen/IslAst.cpp
+++ lib/CodeGen/IslAst.cpp
@@ -416,6 +416,13 @@
 
   buildRunCondition(Build);
 
+  // The assumed context restricts the dependence analysis, hence it also has
+  // to restrict the AST generation otherwise the scalar code generation can
+  // become unstable. However, we need to do this after we generated the runtime
+  // checks as the context we use to restrict the AST generation with only holds
+  // if the runtime checks are true.
+  Build = isl_ast_build_restrict(Build, S->getAssumedContext());
+
   Root = isl_ast_build_node_from_schedule(Build, S->getScheduleTree());
 
   isl_ast_build_free(Build);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12072.32270.patch
Type: text/x-patch
Size: 3235 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150817/d349f413/attachment.bin>


More information about the llvm-commits mailing list