[polly] r265779 - [FIX] Allow to lookup domains for non-affine subregion blocks

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 8 03:32:27 PDT 2016


Author: jdoerfert
Date: Fri Apr  8 05:32:26 2016
New Revision: 265779

URL: http://llvm.org/viewvc/llvm-project?rev=265779&view=rev
Log:
[FIX] Allow to lookup domains for non-affine subregion blocks


Added:
    polly/trunk/test/Isl/CodeGen/invariant_load_in_non_affine_subregion.ll
Modified:
    polly/trunk/include/polly/ScopInfo.h
    polly/trunk/lib/Analysis/ScopInfo.cpp

Modified: polly/trunk/include/polly/ScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=265779&r1=265778&r2=265779&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopInfo.h (original)
+++ polly/trunk/include/polly/ScopInfo.h Fri Apr  8 05:32:26 2016
@@ -2053,12 +2053,12 @@ public:
   /// for complex cases without "error handling code" needed on the users side.
   __isl_give isl_pw_aff *getPwAff(const SCEV *E, BasicBlock *BB = nullptr);
 
-  /// @brief Return the non-loop carried conditions on the domain of @p Stmt.
+  /// @brief Return the domain of @p Stmt.
   ///
   /// @param Stmt The statement for which the conditions should be returned.
   __isl_give isl_set *getDomainConditions(ScopStmt *Stmt);
 
-  /// @brief Return the non-loop carried conditions on the domain of @p BB.
+  /// @brief Return the domain of @p BB.
   ///
   /// @param BB The block for which the conditions should be returned.
   __isl_give isl_set *getDomainConditions(BasicBlock *BB);

Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=265779&r1=265778&r2=265779&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Fri Apr  8 05:32:26 2016
@@ -2114,8 +2114,15 @@ isl_set *Scop::getDomainConditions(ScopS
 }
 
 isl_set *Scop::getDomainConditions(BasicBlock *BB) {
-  assert(DomainMap.count(BB) && "Requested BB did not have a domain");
-  return isl_set_copy(DomainMap[BB]);
+  auto DIt = DomainMap.find(BB);
+  if (DIt != DomainMap.end())
+    return isl_set_copy(DIt->getSecond());
+
+  auto &RI = *R.getRegionInfo();
+  auto *BBR = RI.getRegionFor(BB);
+  while (BBR->getEntry() == BB)
+    BBR = BBR->getParent();
+  return getDomainConditions(BBR->getEntry());
 }
 
 bool Scop::buildDomains(Region *R, ScopDetection &SD, DominatorTree &DT,
@@ -2442,24 +2449,6 @@ bool Scop::buildDomainsWithBranchConstra
   return true;
 }
 
-/// @brief Return the domain for @p BB wrt @p DomainMap.
-///
-/// This helper function will lookup @p BB in @p DomainMap but also handle the
-/// case where @p BB is contained in a non-affine subregion using the region
-/// tree obtained by @p RI.
-static __isl_give isl_set *
-getDomainForBlock(BasicBlock *BB, DenseMap<BasicBlock *, isl_set *> &DomainMap,
-                  RegionInfo &RI) {
-  auto DIt = DomainMap.find(BB);
-  if (DIt != DomainMap.end())
-    return isl_set_copy(DIt->getSecond());
-
-  Region *R = RI.getRegionFor(BB);
-  while (R->getEntry() == BB)
-    R = R->getParent();
-  return getDomainForBlock(R->getEntry(), DomainMap, RI);
-}
-
 isl_set *Scop::getPredecessorDomainConstraints(BasicBlock *BB, isl_set *Domain,
                                                ScopDetection &SD,
                                                DominatorTree &DT,
@@ -2509,7 +2498,7 @@ isl_set *Scop::getPredecessorDomainConst
       PropagatedRegions.insert(PredR);
     }
 
-    auto *PredBBDom = getDomainForBlock(PredBB, DomainMap, RI);
+    auto *PredBBDom = getDomainConditions(PredBB);
     auto *PredBBLoop = getFirstNonBoxedLoopFor(PredBB, LI, BoxedLoops);
     PredBBDom = adjustDomainDimensions(*this, PredBBDom, PredBBLoop, BBLoop);
 

Added: polly/trunk/test/Isl/CodeGen/invariant_load_in_non_affine_subregion.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/invariant_load_in_non_affine_subregion.ll?rev=265779&view=auto
==============================================================================
--- polly/trunk/test/Isl/CodeGen/invariant_load_in_non_affine_subregion.ll (added)
+++ polly/trunk/test/Isl/CodeGen/invariant_load_in_non_affine_subregion.ll Fri Apr  8 05:32:26 2016
@@ -0,0 +1,73 @@
+; RUN: opt %loadPolly -polly-codegen -S < %s | FileCheck %s
+;
+; This crashed at some point as the invariant load is in a non-affine
+; subregion. Just check it does not anymore.
+;
+; CHECK: polly.start
+;
+; ModuleID = 'bugpoint-reduced-simplified.bc'
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+
+%struct.d = type { i32, i32, i32, i32, float, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
+
+ at board = external global [421 x i8], align 16
+ at output_flags = external global i32, align 4
+ at dragon = external global [400 x %struct.d], align 16
+
+; Function Attrs: nounwind uwtable
+define void @sgffile_add_debuginfo() #0 {
+entry:
+  br label %entry.split
+
+entry.split:                                      ; preds = %entry
+  %0 = getelementptr inbounds [24 x i8], [24 x i8]* undef, i64 0, i64 0
+  br i1 false, label %cleanup, label %for.cond1.preheader
+
+for.cond1.preheader:                              ; preds = %entry.split
+  br i1 false, label %if.then7, label %land.lhs.true49
+
+if.then7:                                         ; preds = %for.cond1.preheader
+  %arrayidx = getelementptr inbounds [421 x i8], [421 x i8]* @board, i64 0, i64 0
+  %crude_status = getelementptr inbounds [400 x %struct.d], [400 x %struct.d]* @dragon, i64 0, i64 0, i32 5
+  switch i32 0, label %if.end15 [
+    i32 0, label %sw.bb
+    i32 2, label %sw.bb13
+  ]
+
+sw.bb:                                            ; preds = %if.then7
+  br label %if.end15
+
+sw.bb13:                                          ; preds = %if.then7
+  br label %if.end15
+
+if.end15:                                         ; preds = %sw.bb13, %sw.bb, %if.then7
+  %cmp21 = fcmp ogt float undef, 0.000000e+00
+  br i1 %cmp21, label %land.lhs.true23, label %for.cond1.for.inc44_crit_edge
+
+land.lhs.true23:                                  ; preds = %if.end15
+  %1 = load i32, i32* @output_flags, align 4
+  %and24 = and i32 %1, 2
+  %tobool25 = icmp eq i32 %and24, 0
+  br i1 %tobool25, label %for.cond1.for.inc44_crit_edge, label %if.else
+
+if.else:                                          ; preds = %land.lhs.true23
+  br label %for.cond1.for.inc44_crit_edge
+
+for.cond1.for.inc44_crit_edge:                    ; preds = %if.else, %land.lhs.true23, %if.end15
+  br label %land.lhs.true49
+
+land.lhs.true49:                                  ; preds = %for.cond1.for.inc44_crit_edge, %for.cond1.preheader
+  %2 = load i32, i32* @output_flags, align 4
+  %and50 = and i32 %2, 2
+  %tobool51 = icmp eq i32 %and50, 0
+  br i1 %tobool51, label %cleanup, label %if.then52
+
+if.then52:                                        ; preds = %land.lhs.true49
+  br label %cleanup
+
+cleanup:                                          ; preds = %if.then52, %land.lhs.true49, %entry.split
+  call void @llvm.lifetime.end(i64 24, i8* %0)
+  ret void
+}
+
+declare void @llvm.lifetime.end(i64, i8* nocapture)




More information about the llvm-commits mailing list