-
Notifications
You must be signed in to change notification settings - Fork 134
Drop for dynamic objects #402
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
Drop for dynamic objects #402
Conversation
db28d0b to
bb160fc
Compare
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.
Do we want to create an issue for this ? Not sure if this is tracked somewhere..
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.
Added
compiler/rustc_codegen_llvm/src/gotoc/mir_to_goto/codegen/typ.rs
Outdated
Show resolved
Hide resolved
compiler/rustc_codegen_llvm/src/gotoc/mir_to_goto/codegen/place.rs
Outdated
Show resolved
Hide resolved
15388e3 to
671b741
Compare
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 the right link? #202
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.
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.
Does this typecheck? We want a pointer to an unimplemented function, and instead we're getting an unimplemented function that returns a fn pointer.
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.
It does type check, we cast to the same type in the if case. I don't think we have any unit tests that hit this, only the standard library regression.
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.
The issue is that this code is called in a constructor, so it will always fail at CBMC time (which is sound, but not helpful). I think what we want is to make a function whose body is unimplemented, and put a pointer to that function into the vtable.
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.
Do we still need the hook here? Or could we just move its logic inside the regular codegen?
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.
Without it, we fail on:
failures:
[expected] expected/replace-hashmap/main.rs
[expected] expected/replace-vec/main.rs
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 we assert this above? Would that be a better check than matching on loc_ty.kind()
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.
The conditional doesn't work as a check, because asserting the inverse in the dynamic case fails whenever the instance def is InstanceDef::DropGlue instead of ::Virtual. This structure also matches how the Cranelift backend handles this case.
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.
This would be in the case of dropping a slice?
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.
We've also seen it be a fat pointer to a nested dynamic object.
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.
use the expect_fail macro
Description of changes:
RMC does not current codegen calls to drop for dynamic objects. This PR does that, inserting vtable calls as necessary.
Resolved issues:
Resolves #66
Should also resolve #435
Call-outs:
SizeAndAlignOfDsttests. This patch has a workaround to insert acodegen_unimplementedcall in the case that drop fails to typecheck, which maintains soundness (the current implementation is not sound because it does not call drop at all).Testing:
Existing plus 7 new regressions.
Not really.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.