-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Fix forwardingOwnershipKind of all OwnershipForwardingMixin's while cloning #36143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix forwardingOwnershipKind of all OwnershipForwardingMixin's while cloning #36143
Conversation
@swift-ci test |
lib/SIL/IR/SILPrinter.cpp
Outdated
void printForwardingOwnershipKind(OwnershipForwardingMixin *inst, | ||
SILValue op) { | ||
if (inst->getForwardingOwnershipKind() != op.getOwnershipKind()) { | ||
*this << " [" << inst->getForwardingOwnershipKind() << " forwarding] "; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use a syntax that is a postfix? That is:
unchecked_ref_cast %0 : $Foo to $Foo2, forwarding: @owned
I think with time this will make updating tests a lot easier.
createStructExtract(SILLocation Loc, SILValue Operand, VarDecl *Field, | ||
SILType ResultTy, | ||
ValueOwnershipKind forwardingOwnershipKind) { | ||
return insert(new (getModule()) StructExtractInst( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am a little nervous about struct_extract/tuple_extract. I am worried this may let them take an owned value by mistake. My thought: add a check in SILVerifier itself since this is a sort of structural test on StructExtract, TupleExtract. That I am cool.
include/swift/SIL/SILBuilder.h
Outdated
auto DerivativeFunctions = | ||
JVPAndVJPFunctions.hasValue() | ||
? ArrayRef<SILValue>( | ||
reinterpret_cast<SILValue *>(JVPAndVJPFunctions.getPointer()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this safe and correct? Can this be done in a cleaner way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Talked with @meg-gupta
They are going to make the changes that I suggested (change the printing, add a verifier check for struct_extract, tuple_extract, and fix the derivative instruction code). Once that is done, this is ready to go/merge!
+1!
cloning forwardingOwnershipKind can differ from the operand's ownershipKind. We need to copy forwardingOwnershipKind while cloning these instructions. Also print the forwarding ownership kind when it differs from its operand's ownershipKind This is a follow up of swiftlang#36063
a605f18
to
5660643
Compare
Thanks. I made all the suggested fixes. |
@swift-ci test and merge |
@meg-gupta When you change the printed SIL, please also make this parsable in SILParser and document it in SIL.rst |
Thanks @eeckstein . Fixing in #36263 |
forwardingOwnershipKind can differ from the operand's ownershipKind. We
need to copy forwardingOwnershipKind while cloning these instructions.
Also print the forwarding ownership kind when it differs from its
operand's ownershipKind
This is a follow up of #36063