@@ -1580,37 +1580,25 @@ void ConversionPatternRewriterImpl::replaceOp(
1580
1580
1581
1581
// Check if replaced op is an unresolved materialization, i.e., an
1582
1582
// 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
+ }
1587
1590
1588
1591
// Create mappings for each of the new result values.
1589
1592
for (auto [repl, result] : llvm::zip_equal (newValues, op->getResults ())) {
1590
1593
if (repl.empty ()) {
1591
1594
// 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
-
1598
1595
// Materialize a replacement value "out of thin air".
1599
1596
buildUnresolvedMaterialization (
1600
1597
MaterializationKind::Source, computeInsertPoint (result),
1601
1598
result.getLoc (), /* valuesToMap=*/ {result}, /* inputs=*/ ValueRange (),
1602
1599
/* outputTypes=*/ result.getType (), /* originalType=*/ Type (),
1603
1600
currentTypeConverter);
1604
1601
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" );
1614
1602
}
1615
1603
1616
1604
// Remap result to replacement value.
0 commit comments