-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Skip vptr when performing object initialization #4490
Skip vptr when performing object initialization #4490
Conversation
The cehck for vptr could be done differently (is this class dynamic and its base class non-dynamic), and if we change the layout (to put the vptr after any base) then this code will break (could add an assertion that the vptr isn't present apart from at the start of the field list if that'd seem worthwhile). There's still later issues with lowering (if this patch causes crashes in lowering, do they result in fuzz failures/need to be avoided before this change is submitted?)
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.
Looks good, thanks!
for (auto [i, dest_field_id] : llvm::enumerate(dest_elem_fields)) { | ||
auto dest_field = | ||
sem_ir.insts().GetAs<SemIR::StructTypeField>(dest_field_id); | ||
if (dest_field.name_id == SemIR::NameId::Vptr) { | ||
new_block.Set(i, SemIR::InstId::BuiltinError); |
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.
Please add a TODO comment here to put a real vtable pointer in the vptr slot.
bool dest_has_vptr = | ||
!dest_elem_fields.empty() && | ||
sem_ir.insts() | ||
.GetAs<SemIR::StructTypeField>(dest_elem_fields.front()) | ||
.name_id == SemIR::NameId::Vptr; |
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 might be worth factoring out into a helper function. Let's keep an eye on this and see if we want to do it in more places.
The cehck for vptr could be done differently (is this class dynamic and
its base class non-dynamic), and if we change the layout (to put the
vptr after any base) then this code will break (could add an assertion
that the vptr isn't present apart from at the start of the field list if
that'd seem worthwhile).
There's still later issues with lowering (if this patch causes crashes
in lowering, do they result in fuzz failures/need to be avoided before
this change is submitted?)