Skip to content

Commit ed14ee8

Browse files
committed
Address review comments
1 parent b985d63 commit ed14ee8

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -93,26 +93,36 @@ class OpenMPVarMappingStackFrame
9393
/// Custom error class to signal translation errors that don't need reporting,
9494
/// since encountering them will have already triggered relevant error messages.
9595
///
96-
/// For example, it should be used to trigger errors from within callbacks
97-
/// passed to the \see OpenMPIRBuilder when these errors resulted from the
96+
/// Its purpose is to serve as the glue between MLIR failures represented as
97+
/// \see LogicalResult instances and \see llvm::Error instances used to
98+
/// propagate errors through the \see llvm::OpenMPIRBuilder. Generally, when an
99+
/// error of the first type is raised, a message is emitted directly (the \see
100+
/// LogicalResult itself does not hold any information). If we need to forward
101+
/// this error condition as an \see llvm::Error while avoiding triggering some
102+
/// redundant error reporting later on, we need a custom \see llvm::ErrorInfo
103+
/// class to just signal this situation has happened.
104+
///
105+
/// For example, this class should be used to trigger errors from within
106+
/// callbacks passed to the \see OpenMPIRBuilder when they were triggered by the
98107
/// translation of their own regions. This unclutters the error log from
99108
/// redundant messages.
100-
class SilentTranslationError : public llvm::ErrorInfo<SilentTranslationError> {
109+
class PreviouslyReportedError
110+
: public llvm::ErrorInfo<PreviouslyReportedError> {
101111
public:
102112
void log(raw_ostream &) const override {
103113
// Do not log anything.
104114
}
105115

106116
std::error_code convertToErrorCode() const override {
107117
llvm_unreachable(
108-
"SilentTranslationError doesn't support ECError conversion");
118+
"PreviouslyReportedError doesn't support ECError conversion");
109119
}
110120

111121
// Used by ErrorInfo::classID.
112122
static char ID;
113123
};
114124

115-
char SilentTranslationError::ID = 0;
125+
char PreviouslyReportedError::ID = 0;
116126

117127
} // namespace
118128

@@ -121,7 +131,7 @@ static LogicalResult handleError(llvm::Error error, Operation &op) {
121131
if (error) {
122132
llvm::handleAllErrors(
123133
std::move(error),
124-
[&](const SilentTranslationError &) { result = failure(); },
134+
[&](const PreviouslyReportedError &) { result = failure(); },
125135
[&](const llvm::ErrorInfoBase &err) {
126136
result = op.emitError(err.message());
127137
});
@@ -262,7 +272,7 @@ static llvm::Expected<llvm::BasicBlock *> convertOmpOpRegions(
262272
llvm::IRBuilderBase::InsertPointGuard guard(builder);
263273
if (failed(
264274
moduleTranslation.convertBlock(*bb, bb->isEntryBlock(), builder)))
265-
return llvm::make_error<SilentTranslationError>();
275+
return llvm::make_error<PreviouslyReportedError>();
266276

267277
// Special handling for `omp.yield` and `omp.terminator` (we may have more
268278
// than one): they return the control to the parent OpenMP dialect operation
@@ -1717,7 +1727,7 @@ convertOmpParallel(omp::ParallelOp opInst, llvm::IRBuilderBase &builder,
17171727
return contInsertPoint.takeError();
17181728

17191729
if (!contInsertPoint->getBlock())
1720-
return llvm::make_error<SilentTranslationError>();
1730+
return llvm::make_error<PreviouslyReportedError>();
17211731

17221732
tempTerminator->eraseFromParent();
17231733
builder.restoreIP(*contInsertPoint);
@@ -2049,7 +2059,7 @@ convertOmpAtomicUpdate(omp::AtomicUpdateOp &opInst,
20492059
moduleTranslation.mapValue(*opInst.getRegion().args_begin(), atomicx);
20502060
moduleTranslation.mapBlock(&bb, builder.GetInsertBlock());
20512061
if (failed(moduleTranslation.convertBlock(bb, true, builder)))
2052-
return llvm::make_error<SilentTranslationError>();
2062+
return llvm::make_error<PreviouslyReportedError>();
20532063

20542064
omp::YieldOp yieldop = dyn_cast<omp::YieldOp>(bb.getTerminator());
20552065
assert(yieldop && yieldop.getResults().size() == 1 &&
@@ -2141,7 +2151,7 @@ convertOmpAtomicCapture(omp::AtomicCaptureOp atomicCaptureOp,
21412151
atomicx);
21422152
moduleTranslation.mapBlock(&bb, builder.GetInsertBlock());
21432153
if (failed(moduleTranslation.convertBlock(bb, true, builder)))
2144-
return llvm::make_error<SilentTranslationError>();
2154+
return llvm::make_error<PreviouslyReportedError>();
21452155

21462156
omp::YieldOp yieldop = dyn_cast<omp::YieldOp>(bb.getTerminator());
21472157
assert(yieldop && yieldop.getResults().size() == 1 &&
@@ -3176,7 +3186,7 @@ convertOmpTargetData(Operation *op, llvm::IRBuilderBase &builder,
31763186

31773187
if (failed(inlineConvertOmpRegions(region, "omp.data.region", builder,
31783188
moduleTranslation)))
3179-
return llvm::make_error<SilentTranslationError>();
3189+
return llvm::make_error<PreviouslyReportedError>();
31803190
}
31813191
break;
31823192
case BodyGenTy::DupNoPriv:
@@ -3198,7 +3208,7 @@ convertOmpTargetData(Operation *op, llvm::IRBuilderBase &builder,
31983208

31993209
if (failed(inlineConvertOmpRegions(region, "omp.data.region", builder,
32003210
moduleTranslation)))
3201-
return llvm::make_error<SilentTranslationError>();
3211+
return llvm::make_error<PreviouslyReportedError>();
32023212
}
32033213
break;
32043214
}

0 commit comments

Comments
 (0)