mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[OpaqueValues] Handle Builtin.copy.
Specify the operand ownership of the Builtin differently depending on whether lowered addresses are used. Handle rewriting the value version of the builtin as the address version of the builtin in AddressLowering.
This commit is contained in:
@@ -2617,6 +2617,19 @@ protected:
|
||||
vmi->setOperand(opAddr);
|
||||
}
|
||||
|
||||
void visitBuiltinInst(BuiltinInst *bi) {
|
||||
switch (bi->getBuiltinKind().getValueOr(BuiltinValueKind::None)) {
|
||||
case BuiltinValueKind::Copy: {
|
||||
SILValue opAddr = addrMat.materializeAddress(use->get());
|
||||
bi->setOperand(0, opAddr);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
bi->dump();
|
||||
llvm::report_fatal_error("^^^ Unimplemented builtin opaque value use.");
|
||||
}
|
||||
}
|
||||
|
||||
void visitBeginBorrowInst(BeginBorrowInst *borrow);
|
||||
|
||||
void visitEndBorrowInst(EndBorrowInst *end) {}
|
||||
@@ -3112,6 +3125,22 @@ protected:
|
||||
ApplyRewriter(bai, pass).convertBeginApplyWithOpaqueYield();
|
||||
}
|
||||
|
||||
void visitBuiltinInst(BuiltinInst *bi) {
|
||||
switch (bi->getBuiltinKind().getValueOr(BuiltinValueKind::None)) {
|
||||
case BuiltinValueKind::Copy: {
|
||||
SILValue addr = addrMat.materializeAddress(bi);
|
||||
builder.createBuiltin(
|
||||
bi->getLoc(), bi->getName(),
|
||||
SILType::getEmptyTupleType(bi->getType().getASTContext()),
|
||||
bi->getSubstitutions(), {addr, bi->getOperand(0)});
|
||||
break;
|
||||
}
|
||||
default:
|
||||
bi->dump();
|
||||
llvm::report_fatal_error("^^^ Unimplemented builtin opaque value def.");
|
||||
}
|
||||
}
|
||||
|
||||
// Rewrite the apply for an indirect result.
|
||||
void visitDestructureTupleInst(DestructureTupleInst *destructure) {
|
||||
SILValue srcVal = destructure->getOperand();
|
||||
|
||||
Reference in New Issue
Block a user