Skip to content

Commit 81db109

Browse files
committed
exit gracefully
1 parent aa46203 commit 81db109

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

mlir/lib/Ion/Transforms/ion-to-rtio.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,7 @@ auto traceValueWithCallback(Value value, CallbackT &&callback)
108108
worklist.push(inQubit);
109109
continue;
110110
}
111-
parentOp->emitError("Unsupported parent operation for block argument: ") << value;
112-
llvm::reportFatalInternalError("Unsupported block argument");
111+
return WalkResult::interrupt();
113112
}
114113

115114
Operation *defOp = value.getDefiningOp();
@@ -364,7 +363,10 @@ struct ParallelProtocolToRTIOPattern : public OpConversionPattern<ion::ParallelP
364363
return WalkResult::advance();
365364
});
366365

367-
assert(index != nullptr && "index must not be null");
366+
if (index == nullptr) {
367+
op->emitError("Failed to trace the channel index");
368+
return failure();
369+
}
368370

369371
// update cache
370372
for (Value value : chain) {
@@ -473,7 +475,11 @@ struct PulseToRTIOPattern : public OpConversionPattern<ion::PulseOp> {
473475
}
474476
return WalkResult::advance();
475477
});
476-
assert(memrefLoadValue != nullptr && "memrefLoadValue must not be null");
478+
479+
if (memrefLoadValue == nullptr) {
480+
op->emitError("Failed to trace the memref load value");
481+
return failure();
482+
}
477483

478484
Value channel =
479485
rewriter.create<rtio::RTIOQubitToChannelOp>(loc, channelType, memrefLoadValue);
@@ -657,7 +663,7 @@ struct PropagateEventsPattern : public OpRewritePattern<UnrealizedConversionCast
657663

658664
if (events.empty()) {
659665
op.emitError("No events found for cast op");
660-
llvm::reportFatalInternalError("No events found for cast op");
666+
return failure();
661667
}
662668

663669
// Create a sync event from all collected events

0 commit comments

Comments
 (0)