Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upCompute sizedness with a fixed-point analysis #1102
Conversation
highfive
assigned
pepyakin
Oct 25, 2017
highfive
added
the
S-awaiting-review
label
Oct 25, 2017
fitzgen
force-pushed the
fitzgen:sizedness
branch
to
e7622f9
Oct 25, 2017
| } | ||
|
|
||
| TypeKind::ObjCInterface(..) => { | ||
| trace!(" I guess obj-c interfaces are not zero-sized?"); |
This comment has been minimized.
This comment has been minimized.
pepyakin
Oct 25, 2017
Contributor
FWIW, as far as I know, every obj-c "interface" have an isa pointer.
This comment has been minimized.
This comment has been minimized.
fitzgen
Oct 25, 2017
Author
Member
Cool, I'll note this. FWIW, I was just copying existing behavior.
| trace!(" comp considers its own fields and bases"); | ||
|
|
||
| if !info.fields().is_empty() { | ||
| return self.insert(id, SizednessResult::NonZeroSized); |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
fitzgen
Oct 25, 2017
Author
Member
They can't be, because of the every-object-must-be-addressable rules. Only base members can truly be zero sized, because its the "same" object.
This comment has been minimized.
This comment has been minimized.
fitzgen
Oct 25, 2017
Author
Member
That is, with
struct Empty {};
struct Inherits : public Empty {
int x;
};
struct Contains {
Empty empty;
int x;
};sizeof(Contains) is one greater than sizeof(Inherits)
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Thanks for the review @pepyakin ! |
fitzgen
force-pushed the
fitzgen:sizedness
branch
from
e7622f9
to
379bb16
Oct 25, 2017
This comment has been minimized.
This comment has been minimized.
|
I added that example, and another for arrays of zero-sized types, as tests. Thanks again for review @pepyakin ! @bors-servo r=pepyakin |
This comment has been minimized.
This comment has been minimized.
|
|
highfive
added
S-awaiting-merge
and removed
S-awaiting-review
labels
Oct 25, 2017
This comment has been minimized.
This comment has been minimized.
bors-servo
added a commit
that referenced
this pull request
Oct 25, 2017
highfive
added
S-awaiting-review
and removed
S-awaiting-merge
labels
Oct 25, 2017
This comment has been minimized.
This comment has been minimized.
|
Added one more test for arrays of zero elements and flexible arrays also. @bors-servo r=pepyakin |
This comment has been minimized.
This comment has been minimized.
|
|
highfive
added
S-awaiting-merge
and removed
S-awaiting-review
labels
Oct 25, 2017
This comment has been minimized.
This comment has been minimized.
bors-servo
added a commit
that referenced
this pull request
Oct 25, 2017
This comment has been minimized.
This comment has been minimized.
|
|
fitzgen commentedOct 25, 2017
This fixes a couple bugs where we weren't properly adding an
_addressbyte. It also helps pave the way for computing implicit fields (such as padding,_address, vtable pointers, etc) in its own pass, before codegen.Fixes #768
r? @pepyakin