Add end user report message for unprofitable regions [NFC]

llvm-svn: 231593
This commit is contained in:
Johannes Doerfert 2015-03-08 15:11:50 +00:00
parent 90078c5580
commit 6a4d81c1f6
4 changed files with 33 additions and 7 deletions

View File

@ -835,8 +835,10 @@ public:
/// @brief Report regions that seem not profitable to be optimized.
class ReportUnprofitable : public ReportOther {
//===--------------------------------------------------------------------===//
Region *R;
public:
ReportUnprofitable();
ReportUnprofitable(Region *R);
/// @name LLVM-RTTI interface
//@{
@ -846,6 +848,8 @@ public:
/// @name RejectReason interface
//@{
virtual std::string getMessage() const override;
virtual std::string getEndUserMessage() const override;
virtual const DebugLoc &getDebugLoc() const override;
//@}
};

View File

@ -761,12 +761,15 @@ static unsigned eraseAllChildren(ScopDetection::RegionSet &Regs,
}
void ScopDetection::findScops(Region &R) {
if (!DetectRegionsWithoutLoops && regionWithoutLoops(R, LI))
return;
DetectionContext Context(R, *AA, NonAffineSubRegionMap[&R],
false /*verifying*/);
bool RegionIsValid = isValidRegion(Context);
bool RegionIsValid = false;
if (!DetectRegionsWithoutLoops && regionWithoutLoops(R, LI))
invalid<ReportUnprofitable>(Context, /*Assert=*/true, &R);
else
RegionIsValid = isValidRegion(Context);
bool HasErrors = !RegionIsValid || Context.Log.size() > 0;
if (PollyTrackFailures && HasErrors)
@ -905,7 +908,7 @@ bool ScopDetection::isValidRegion(DetectionContext &Context) const {
// We can probably not do a lot on scops that only write or only read
// data.
if (!DetectUnprofitable && (!Context.hasStores || !Context.hasLoads))
invalid<ReportUnprofitable>(Context, /*Assert=*/true);
invalid<ReportUnprofitable>(Context, /*Assert=*/true, &CurRegion);
DEBUG(dbgs() << "OK\n");
return true;

View File

@ -594,12 +594,29 @@ bool ReportEntry::classof(const RejectReason *RR) {
//===----------------------------------------------------------------------===//
// ReportUnprofitable.
ReportUnprofitable::ReportUnprofitable() : ReportOther(rrkUnprofitable) {}
ReportUnprofitable::ReportUnprofitable(Region *R)
: ReportOther(rrkUnprofitable), R(R) {}
std::string ReportUnprofitable::getMessage() const {
return "Region can not profitably be optimized!";
}
std::string ReportUnprofitable::getEndUserMessage() const {
return "The regions does not seem to be amendable to profitable polyhedral "
"optimization";
}
const DebugLoc &ReportUnprofitable::getDebugLoc() const {
for (const BasicBlock *BB : R->blocks())
for (const Instruction &Inst : *BB) {
const DebugLoc &DL = Inst.getDebugLoc();
if (!DL.isUnknown())
return DL;
}
return R->getEntry()->getTerminator()->getDebugLoc();
}
bool ReportUnprofitable::classof(const RejectReason *RR) {
return RR->getKind() == rrkUnprofitable;
}

View File

@ -13,9 +13,11 @@ target triple = "x86_64-unknown-linux-gnu"
; }
; CHECK: remark: /tmp/test.c:2:3: The following errors keep this region from being a Scop.
; CHECK: remark: /tmp/test.c:2:3: The regions does not seem to be amendable to profitable polyhedral optimization
; CHECK: remark: /tmp/test.c:3:10: Invalid Scop candidate ends here.
; CHECK: remark: /tmp/test.c:7:3: The following errors keep this region from being a Scop.
; CHECK: remark: /tmp/test.c:7:3: The regions does not seem to be amendable to profitable polyhedral optimization
; CHECK: remark: /tmp/test.c:8:10: Invalid Scop candidate ends here.