[polly] r250664 - [FIX] Do not try to hoist "empty" accesses

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 18 12:50:18 PDT 2015


Author: jdoerfert
Date: Sun Oct 18 14:50:18 2015
New Revision: 250664

URL: http://llvm.org/viewvc/llvm-project?rev=250664&view=rev
Log:
[FIX] Do not try to hoist "empty" accesses

  Accesses that have a relative offset (in bytes) that is not divisible
  by the type size (in bytes) will be represented as empty in the SCoP
  description. This is on its own not good but it also crashed the
  invariant load hoisting. This patch will fix the latter problem while
  the former should be addressed too.

  This fixes bug 25236.


Added:
    polly/trunk/test/Isl/CodeGen/invariant_cannot_handle_void.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=250664&r1=250663&r2=250664&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Sun Oct 18 14:50:18 2015
@@ -2564,6 +2564,15 @@ void Scop::hoistInvariantLoads() {
         continue;
 
       isl_map *AccessRelation = MA->getAccessRelation();
+
+      // Skip accesses that have an empty access relation. These can be caused
+      // by multiple offsets with a type cast in-between that cause the overall
+      // byte offset to be not divisible by the new types sizes.
+      if (isl_map_is_empty(AccessRelation)) {
+        isl_map_free(AccessRelation);
+        continue;
+      }
+
       if (isl_map_involves_dims(AccessRelation, isl_dim_in, 0,
                                 Stmt.getNumIterators())) {
         isl_map_free(AccessRelation);

Added: polly/trunk/test/Isl/CodeGen/invariant_cannot_handle_void.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/invariant_cannot_handle_void.ll?rev=250664&view=auto
==============================================================================
--- polly/trunk/test/Isl/CodeGen/invariant_cannot_handle_void.ll (added)
+++ polly/trunk/test/Isl/CodeGen/invariant_cannot_handle_void.ll Sun Oct 18 14:50:18 2015
@@ -0,0 +1,60 @@
+; RUN: opt %loadPolly -S -polly-codegen %s | FileCheck %s
+;
+; The offset of the %tmp1 load wrt. to %buff (62 bytes) is not divisible
+; by the type size (i32 = 4 bytes), thus the access function build for
+; %tmp1 is empty. As a result the code generation crashed when hoisting
+; %tmp1. This test verifies we do not crash anymore.
+;
+; CHECK: polly.start
+;
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+
+; Function Attrs: nounwind uwtable
+define void @sudecrypt(i8* %buff) #0 {
+entry:
+  br i1 undef, label %cleanup, label %if.end
+
+if.end:                                           ; preds = %entry
+  br i1 undef, label %if.end.6, label %if.then.5
+
+if.then.5:                                        ; preds = %if.end
+  unreachable
+
+if.end.6:                                         ; preds = %if.end
+  %add.ptr = getelementptr inbounds i8, i8* %buff, i64 62
+  %tmp = bitcast i8* %add.ptr to i32*
+  %tmp1 = load i32, i32* %tmp, align 4, !tbaa !1
+  br i1 false, label %if.then.13, label %switch.early.test
+
+switch.early.test:                                ; preds = %if.end.6
+  switch i32 0, label %if.end.16 [
+    i32 956, label %if.then.13
+    i32 520, label %if.then.13
+  ]
+
+if.then.13:                                       ; preds = %switch.early.test, %switch.early.test, %if.end.6
+  br label %if.end.16
+
+if.end.16:                                        ; preds = %if.then.13, %switch.early.test
+  %key.0 = phi i32 [ undef, %if.then.13 ], [ 0, %switch.early.test ]
+  br i1 undef, label %if.end.34, label %if.then.19
+
+if.then.19:                                       ; preds = %if.end.16
+  unreachable
+
+if.end.34:                                        ; preds = %if.end.16
+  unreachable
+
+cleanup:                                          ; preds = %entry
+  ret void
+}
+
+attributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
+
+!llvm.ident = !{!0}
+
+!0 = !{!"clang version 3.8.0 (trunk 250010) (llvm/trunk 250018)"}
+!1 = !{!2, !2, i64 0}
+!2 = !{!"int", !3, i64 0}
+!3 = !{!"omnipotent char", !4, i64 0}
+!4 = !{!"Simple C/C++ TBAA"}




More information about the llvm-commits mailing list