Add support for PatternRewriter::eraseOp.

This hook is useful when an operation is known to be dead, and no replacement values make sense.

PiperOrigin-RevId: 275052756
This commit is contained in:
River Riddle
2019-10-16 09:50:28 -07:00
committed by A. Unique TensorFlower
parent f1f9e3b8d1
commit dfe09cc621
13 changed files with 54 additions and 31 deletions

View File

@@ -363,7 +363,7 @@ struct FuncOpConversion : public LLVMLegalizationPattern<FuncOp> {
}
}
rewriter.replaceOp(op, llvm::None);
rewriter.eraseOp(op);
return matchSuccess();
}
};
@@ -474,7 +474,7 @@ struct OneToOneLLVMOpLowering : public LLVMLegalizationPattern<SourceOp> {
// If the operation produced 0 or 1 result, return them immediately.
if (numResults == 0)
return rewriter.replaceOp(op, llvm::None), this->matchSuccess();
return rewriter.eraseOp(op), this->matchSuccess();
if (numResults == 1)
return rewriter.replaceOp(op, newOp.getOperation()->getResult(0)),
this->matchSuccess();