@@ -1580,37 +1580,25 @@ void ConversionPatternRewriterImpl::replaceOp(
15801580
15811581 // Check if replaced op is an unresolved materialization, i.e., an
15821582 // unrealized_conversion_cast op that was created by the conversion driver.
1583- bool isUnresolvedMaterialization = false ;
1584- if (auto castOp = dyn_cast<UnrealizedConversionCastOp>(op))
1585- if (unresolvedMaterializations.contains (castOp))
1586- isUnresolvedMaterialization = true ;
1583+ if (auto castOp = dyn_cast<UnrealizedConversionCastOp>(op)) {
1584+ // Make sure that the user does not mess with unresolved materializations
1585+ // that were inserted by the conversion driver. We keep track of these
1586+ // ops in internal data structures.
1587+ assert (!unresolvedMaterializations.contains (castOp) &&
1588+ " attempting to replace/erase an unresolved materialization" );
1589+ }
15871590
15881591 // Create mappings for each of the new result values.
15891592 for (auto [repl, result] : llvm::zip_equal (newValues, op->getResults ())) {
15901593 if (repl.empty ()) {
15911594 // This result was dropped and no replacement value was provided.
1592- if (isUnresolvedMaterialization) {
1593- // Do not create another materializations if we are erasing a
1594- // materialization.
1595- continue ;
1596- }
1597-
15981595 // Materialize a replacement value "out of thin air".
15991596 buildUnresolvedMaterialization (
16001597 MaterializationKind::Source, computeInsertPoint (result),
16011598 result.getLoc (), /* valuesToMap=*/ {result}, /* inputs=*/ ValueRange (),
16021599 /* outputTypes=*/ result.getType (), /* originalType=*/ Type (),
16031600 currentTypeConverter);
16041601 continue ;
1605- } else {
1606- // Make sure that the user does not mess with unresolved materializations
1607- // that were inserted by the conversion driver. We keep track of these
1608- // ops in internal data structures. Erasing them must be allowed because
1609- // this can happen when the user is erasing an entire block (including
1610- // its body). But replacing them with another value should be forbidden
1611- // to avoid problems with the `mapping`.
1612- assert (!isUnresolvedMaterialization &&
1613- " attempting to replace an unresolved materialization" );
16141602 }
16151603
16161604 // Remap result to replacement value.
0 commit comments