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
This commit is contained in:
parent
40ada57b7e
commit
bf45e74254
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -348,6 +348,29 @@ bool ReportFuncCall::classof(const RejectReason *RR) {
|
|||
return RR->getKind() == rrkFuncCall;
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// 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.
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue