[polly] r251234 - ScopDetect: Bail out for non-simple memory accesses

Tobias Grosser via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 25 06:48:40 PDT 2015


Author: grosser
Date: Sun Oct 25 08:48:40 2015
New Revision: 251234

URL: http://llvm.org/viewvc/llvm-project?rev=251234&view=rev
Log:
ScopDetect: Bail out for non-simple memory accesses

Volatile or atomic memory accesses are currently not supported. Neither did
we think about any special handling needed nor do we support the unknown
instructions the alias set tracker turns them into sometimes. Before this
patch, us not supporting unkown instructions in an alias set caused the
following assertion failures:

Assertion `AG.size() > 1 && "Alias groups should contain at least two accesses"'
failed

Added:
    polly/trunk/test/ScopDetect/non-simple-memory-accesses.ll
Modified:
    polly/trunk/include/polly/ScopDetectionDiagnostic.h
    polly/trunk/lib/Analysis/ScopDetection.cpp
    polly/trunk/lib/Analysis/ScopDetectionDiagnostic.cpp

Modified: polly/trunk/include/polly/ScopDetectionDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopDetectionDiagnostic.h?rev=251234&r1=251233&r2=251234&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopDetectionDiagnostic.h (original)
+++ polly/trunk/include/polly/ScopDetectionDiagnostic.h Sun Oct 25 08:48:40 2015
@@ -83,6 +83,7 @@ enum RejectReasonKind {
   rrkLoopBound,
 
   rrkFuncCall,
+  rrkNonSimpleMemoryAccess,
 
   rrkAlias,
 
@@ -762,6 +763,30 @@ public:
   //@}
 };
 
+//===----------------------------------------------------------------------===//
+/// @brief Captures errors with non-simple memory accesses.
+class ReportNonSimpleMemoryAccess : public ReportOther {
+  //===--------------------------------------------------------------------===//
+
+  // The offending call instruction.
+  Instruction *Inst;
+
+public:
+  ReportNonSimpleMemoryAccess(Instruction *Inst);
+
+  /// @name LLVM-RTTI interface
+  //@{
+  static bool classof(const RejectReason *RR);
+  //@}
+
+  /// @name RejectReason interface
+  //@{
+  virtual std::string getMessage() const override;
+  virtual const DebugLoc &getDebugLoc() const override;
+  virtual std::string getEndUserMessage() const override;
+  //@}
+};
+
 } // namespace polly
 
 #endif // POLLY_SCOP_DETECTION_DIAGNOSTIC_H

Modified: polly/trunk/lib/Analysis/ScopDetection.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopDetection.cpp?rev=251234&r1=251233&r2=251234&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopDetection.cpp (original)
+++ polly/trunk/lib/Analysis/ScopDetection.cpp Sun Oct 25 08:48:40 2015
@@ -749,6 +749,15 @@ bool ScopDetection::isValidInstruction(I
   if (isa<LoadInst>(Inst) || isa<StoreInst>(Inst)) {
     Context.hasStores |= isa<StoreInst>(Inst);
     Context.hasLoads |= isa<LoadInst>(Inst);
+    if (auto *Load = dyn_cast<LoadInst>(&Inst))
+      if (!Load->isSimple())
+        return invalid<ReportNonSimpleMemoryAccess>(Context, /*Assert=*/true,
+                                                    &Inst);
+    if (auto *Store = dyn_cast<StoreInst>(&Inst))
+      if (!Store->isSimple())
+        return invalid<ReportNonSimpleMemoryAccess>(Context, /*Assert=*/true,
+                                                    &Inst);
+
     return isValidMemoryAccess(Inst, Context);
   }
 

Modified: polly/trunk/lib/Analysis/ScopDetectionDiagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopDetectionDiagnostic.cpp?rev=251234&r1=251233&r2=251234&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopDetectionDiagnostic.cpp (original)
+++ polly/trunk/lib/Analysis/ScopDetectionDiagnostic.cpp Sun Oct 25 08:48:40 2015
@@ -349,6 +349,29 @@ bool ReportFuncCall::classof(const Rejec
 }
 
 //===----------------------------------------------------------------------===//
+// ReportNonSimpleMemoryAccess
+
+ReportNonSimpleMemoryAccess::ReportNonSimpleMemoryAccess(Instruction *Inst)
+    : ReportOther(rrkNonSimpleMemoryAccess), Inst(Inst) {}
+
+std::string ReportNonSimpleMemoryAccess::getMessage() const {
+  return "Non-simple memory access: " + *Inst;
+}
+
+const DebugLoc &ReportNonSimpleMemoryAccess::getDebugLoc() const {
+  return Inst->getDebugLoc();
+}
+
+std::string ReportNonSimpleMemoryAccess::getEndUserMessage() const {
+  return "Volatile memory accesses or memory accesses for atomic types "
+         "are not supported.";
+}
+
+bool ReportNonSimpleMemoryAccess::classof(const RejectReason *RR) {
+  return RR->getKind() == rrkNonSimpleMemoryAccess;
+}
+
+//===----------------------------------------------------------------------===//
 // ReportAlias.
 
 ReportAlias::ReportAlias(Instruction *Inst, AliasSet &AS)

Added: polly/trunk/test/ScopDetect/non-simple-memory-accesses.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopDetect/non-simple-memory-accesses.ll?rev=251234&view=auto
==============================================================================
--- polly/trunk/test/ScopDetect/non-simple-memory-accesses.ll (added)
+++ polly/trunk/test/ScopDetect/non-simple-memory-accesses.ll Sun Oct 25 08:48:40 2015
@@ -0,0 +1,30 @@
+; RUN: opt %loadPolly -polly-detect \
+; RUN:   -analyze < %s | FileCheck %s
+;
+; Verify that we do not model atomic memory accesses. We did not reason about
+; how to handle them correctly and the Alias Set Tracker models some of them
+; only as Unknown Instructions, which we do not know how to handle either.;
+;
+; CHECK-NOT: Valid
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+
+ at global = external global i64, align 8
+
+declare void @foo55()
+
+define void @blam107() {
+bb:
+  br label %bb1
+
+bb1:                                              ; preds = %bb
+  %tmp = load atomic i8, i8* bitcast (i64* @global to i8*) acquire, align 8
+  br i1 false, label %bb2, label %bb3
+
+bb2:                                              ; preds = %bb1
+  tail call void @foo55() #6
+  br label %bb3
+
+bb3:                                              ; preds = %bb2, %bb1
+  unreachable
+}
+




More information about the llvm-commits mailing list