summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Grosser <tobias@grosser.es>2015-10-25 13:48:40 +0000
committerTobias Grosser <tobias@grosser.es>2015-10-25 13:48:40 +0000
commitbf45e742540cd14e44a2a065d8b9a32b49e95957 (patch)
tree7d290c0c0865197bef40c7a83a1c482f237e3cce
parent40ada57b7e217e6782f5dc16e45a8220b55d8c54 (diff)
downloadbcm5719-llvm-bf45e742540cd14e44a2a065d8b9a32b49e95957.tar.gz
bcm5719-llvm-bf45e742540cd14e44a2a065d8b9a32b49e95957.zip
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 llvm-svn: 251234
-rw-r--r--polly/include/polly/ScopDetectionDiagnostic.h25
-rw-r--r--polly/lib/Analysis/ScopDetection.cpp9
-rw-r--r--polly/lib/Analysis/ScopDetectionDiagnostic.cpp23
-rw-r--r--polly/test/ScopDetect/non-simple-memory-accesses.ll30
4 files changed, 87 insertions, 0 deletions
diff --git a/polly/include/polly/ScopDetectionDiagnostic.h b/polly/include/polly/ScopDetectionDiagnostic.h
index be40d9e8b79..ab51773d2ec 100644
--- a/polly/include/polly/ScopDetectionDiagnostic.h
+++ b/polly/include/polly/ScopDetectionDiagnostic.h
@@ -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
diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp
index 79461c8583c..2fa45addc2f 100644
--- a/polly/lib/Analysis/ScopDetection.cpp
+++ b/polly/lib/Analysis/ScopDetection.cpp
@@ -749,6 +749,15 @@ bool ScopDetection::isValidInstruction(Instruction &Inst,
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);
}
diff --git a/polly/lib/Analysis/ScopDetectionDiagnostic.cpp b/polly/lib/Analysis/ScopDetectionDiagnostic.cpp
index 1943dfc37f1..4eabfc9c9de 100644
--- a/polly/lib/Analysis/ScopDetectionDiagnostic.cpp
+++ b/polly/lib/Analysis/ScopDetectionDiagnostic.cpp
@@ -349,6 +349,29 @@ bool ReportFuncCall::classof(const RejectReason *RR) {
}
//===----------------------------------------------------------------------===//
+// 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)
diff --git a/polly/test/ScopDetect/non-simple-memory-accesses.ll b/polly/test/ScopDetect/non-simple-memory-accesses.ll
new file mode 100644
index 00000000000..73b4e76d964
--- /dev/null
+++ b/polly/test/ScopDetect/non-simple-memory-accesses.ll
@@ -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"
+
+@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
+}
+
OpenPOWER on IntegriCloud