Skip to content

Commit b18bced

Browse files
Iterators: Remove unnecessary asserts or replace by better check. (#613)
1 parent fca714d commit b18bced

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

experimental/iterators/lib/Conversion/IteratorsToLLVM/IteratorsToLLVM.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ struct ConstantTupleLowering : public OpConversionPattern<ConstantTupleOp> {
145145
Location loc = op->getLoc();
146146

147147
// Convert tuple type.
148-
assert(op->getNumResults() == 1);
149148
Type tupleType = op.tuple().getType();
150149
Type structType = typeConverter->convertType(tupleType);
151150

@@ -154,7 +153,6 @@ struct ConstantTupleLowering : public OpConversionPattern<ConstantTupleOp> {
154153

155154
// Insert values.
156155
ArrayAttr values = op.values();
157-
assert(values);
158156
for (int i = 0; i < static_cast<int>(values.size()); i++) {
159157
// Create constant value op.
160158
Attribute field = values[i];
@@ -196,8 +194,7 @@ struct PrintOpLowering : public OpConversionPattern<PrintOp> {
196194
Location loc = op->getLoc();
197195
Type i32 = rewriter.getI32Type();
198196

199-
auto structType = adaptor.element().getType().dyn_cast<LLVMStructType>();
200-
assert(structType && "Only struct types supported for now");
197+
auto structType = adaptor.element().getType().cast<LLVMStructType>();
201198

202199
// Assemble format string in the form `(%lli, %lg, ...)`.
203200
std::string format("(");
@@ -723,8 +720,7 @@ buildNextBody(MapOp op, OpBuilder &builder, Value initialState,
723720
createExtractValueOp(b, upstreamStateType, initialState, {0});
724721

725722
// Extract input element type.
726-
StreamType inputStreamType = op.input().getType().dyn_cast<StreamType>();
727-
assert(inputStreamType);
723+
StreamType inputStreamType = op.input().getType().cast<StreamType>();
728724
Type inputElementType = inputStreamType.getElementType();
729725

730726
// Call next.
@@ -1360,9 +1356,7 @@ buildNextFuncInParentModule(Operation *originalOp, OpBuilder &builder,
13601356
ArrayRef<IteratorInfo> upstreamInfos) {
13611357
// Compute element type.
13621358
assert(originalOp->getNumResults() == 1);
1363-
StreamType streamType =
1364-
originalOp->getResult(0).getType().dyn_cast<StreamType>();
1365-
assert(streamType);
1359+
StreamType streamType = originalOp->getResult(0).getType().cast<StreamType>();
13661360
Type elementType = streamType.getElementType();
13671361

13681362
// Build function.

0 commit comments

Comments
 (0)