Simplify the emission of various diagnostics created in Analysis/ and Transforms/ by using the new diagnostic infrastructure.

--

PiperOrigin-RevId: 246955332
This commit is contained in:
River Riddle 2019-05-06 21:59:40 -07:00 committed by Mehdi Amini
parent c34386e3e5
commit ae9f4f2157
5 changed files with 19 additions and 28 deletions

View File

@ -398,8 +398,8 @@ LogicalResult mlir::boundCheckLoadOrStoreOp(LoadOrStoreOpPointer loadOrStoreOp,
ucst.addConstantLowerBound(r, dimSize);
outOfBounds = !ucst.isEmpty();
if (outOfBounds && emitError) {
loadOrStoreOp.emitOpError(
"memref out of upper bound access along dimension #" + Twine(r + 1));
loadOrStoreOp.emitOpError()
<< "memref out of upper bound access along dimension #" << (r + 1);
}
// Check for a negative index.
@ -409,8 +409,8 @@ LogicalResult mlir::boundCheckLoadOrStoreOp(LoadOrStoreOpPointer loadOrStoreOp,
lcst.addConstantUpperBound(r, -1);
outOfBounds = !lcst.isEmpty();
if (outOfBounds && emitError) {
loadOrStoreOp.emitOpError(
"memref out of lower bound access along dimension #" + Twine(r + 1));
loadOrStoreOp.emitOpError()
<< "memref out of lower bound access along dimension #" << (r + 1);
}
}
return failure(outOfBounds);

View File

@ -349,8 +349,8 @@ LogicalResult FuncVerifier::verifyOpDominance(Operation &op) {
if (domInfo->properlyDominates(operand, &op))
continue;
auto diag = op.emitError("operand #" + Twine(operandNo) +
" does not dominate this use");
auto diag = op.emitError("operand #")
<< operandNo << " does not dominate this use";
if (auto *useOp = operand->getDefiningOp())
diag.attachNote(useOp->getLoc()) << "operand defined here";
return failure();

View File

@ -158,8 +158,7 @@ impl::FunctionConversion::convertOp(DialectOpConversion *converter,
auto results = converter->rewrite(op, operands, builder);
if (results.size() != op->getNumResults())
return (op->emitError("rewriting produced a different number of results"),
failure());
return op->emitError("rewriting produced a different number of results");
for (unsigned i = 0, e = results.size(); i < e; ++i)
mapping.map(op->getResult(i), results[i]);

View File

@ -211,13 +211,9 @@ static bool getFullMemRefAsRegion(Operation *opInst, unsigned numParamLoopIVs,
return true;
}
static void emitRemarkForBlock(Block &block, const Twine &message) {
static InFlightDiagnostic emitRemarkForBlock(Block &block) {
auto *op = block.getContainingOp();
if (!op) {
block.getFunction()->emitRemark(message);
} else {
op->emitRemark(message);
}
return op ? op->emitRemark() : block.getFunction()->emitRemark();
}
/// Creates a buffer in the faster memory space for the specified region;
@ -356,11 +352,10 @@ bool DmaGeneration::generateDma(const MemRefRegion &region, Block *block,
fastBufferMap[memref] = fastMemRef;
// fastMemRefType is a constant shaped memref.
*sizeInBytes = getMemRefSizeInBytes(fastMemRefType).getValue();
LLVM_DEBUG(std::string ss; llvm::raw_string_ostream oss(ss);
oss << "Creating DMA buffer of type " << fastMemRefType;
oss << " and size " << llvm::divideCeil(*sizeInBytes, 1024)
<< " KiB\n";
emitRemarkForBlock(*block, oss.str()));
LLVM_DEBUG(emitRemarkForBlock(*block)
<< "Creating DMA buffer of type " << fastMemRefType
<< " and size " << llvm::divideCeil(*sizeInBytes, 1024)
<< " KiB\n");
} else {
// Reuse the one already created.
fastMemRef = fastBufferMap[memref];
@ -741,9 +736,9 @@ uint64_t DmaGeneration::runOnBlock(Block::iterator begin, Block::iterator end) {
AffineForOp forOp;
uint64_t sizeInKib = llvm::divideCeil(totalDmaBuffersSizeInBytes, 1024);
if (llvm::DebugFlag && (forOp = begin->dyn_cast<AffineForOp>())) {
forOp.emitRemark(
Twine(sizeInKib) +
" KiB of DMA buffers in fast memory space for this block\n");
forOp.emitRemark()
<< sizeInKib
<< " KiB of DMA buffers in fast memory space for this block\n";
}
if (totalDmaBuffersSizeInBytes > fastMemCapacityBytes) {

View File

@ -397,13 +397,10 @@ void LoopTiling::runOnFunction() {
SmallVector<unsigned, 6> tileSizes;
getTileSizes(band, &tileSizes);
if (llvm::DebugFlag) {
std::stringstream msg;
msg << "using tile sizes [";
auto diag = band[0].emitRemark("using tile sizes [");
for (auto tSize : tileSizes)
msg << tSize << " ";
msg << "]\n";
auto rootForOp = band[0];
rootForOp.emitRemark(msg.str());
diag << tSize << " ";
diag << "]\n";
}
if (failed(tileCodeGen(band, tileSizes)))
return signalPassFailure();