forked from OSchip/llvm-project
Always remap results when replacing an operation. This prevents a crash when lowering identity(passthrough) operations to the same resultant type as the original operation.
PiperOrigin-RevId: 251665492
This commit is contained in:
parent
0d2492eb2e
commit
9fc00cf840
|
@ -171,11 +171,14 @@ struct DialectConversionRewriter final : public PatternRewriter {
|
|||
void replaceOp(Operation *op, ArrayRef<Value *> newValues,
|
||||
ArrayRef<Value *> valuesToRemoveIfDead) override {
|
||||
assert(newValues.size() == op->getNumResults());
|
||||
// Create mappings for any type changes.
|
||||
for (unsigned i = 0, e = newValues.size(); i < e; ++i)
|
||||
if (newValues[i] &&
|
||||
op->getResult(i)->getType() != newValues[i]->getType())
|
||||
|
||||
// Create mappings for each of the new result values.
|
||||
for (unsigned i = 0, e = newValues.size(); i < e; ++i) {
|
||||
assert((newValues[i] || op->getResult(i)->use_empty()) &&
|
||||
"result value has remaining uses that must be replaced");
|
||||
if (newValues[i])
|
||||
mapping.map(op->getResult(i), newValues[i]);
|
||||
}
|
||||
|
||||
// Record the requested operation replacement.
|
||||
replacements.emplace_back(op, newValues);
|
||||
|
|
Loading…
Reference in New Issue