Skip to content
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

ir: Fix a bunch of bitfield correctness issues. #736

Merged
merged 1 commit into from
Jun 5, 2017

Conversation

emilio
Copy link
Contributor

@emilio emilio commented Jun 4, 2017

In particular, the "flush the allocation unit" logic is only valid for
ms_structs (that is, MSVC).

It's slightly annoying to have this different behavior, but it'd work just fine
if we'd turn that on for MSVC.

This patch doesn't do that, yet at least, and adds tests for all the weird
bitfield alignments around.

Fixes #726 (and another set of hidden issues by the old code).

@highfive
Copy link

highfive commented Jun 4, 2017

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!

@emilio
Copy link
Contributor Author

emilio commented Jun 4, 2017

r? @fitzgen

@emilio
Copy link
Contributor Author

emilio commented Jun 4, 2017

(Probably needs some test updates for libclang <4.0)

@emilio
Copy link
Contributor Author

emilio commented Jun 4, 2017

(Probably needs some test updates for libclang <4.0)

Or not, yay!

Copy link
Member

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me with some nitpicks below

Thanks @emilio :)

@@ -490,49 +490,67 @@ fn bitfields_to_allocation_units<E, I>(ctx: &BindgenContext,
let mut unit_align = 0;
let mut bitfields_in_unit = vec![];

// TODO(emilio): Determine this from attributes or pragma ms_struct
// directives. Also, perhaps we should check if the target is MSVC?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think checking the target makes most sense.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, we could do this right now, right? Since the mangling PR, we have access to the target triple, so we should probably jsut check if "msvc" is in it or something like that here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could, but I'd like to check with @upsuper in order to confirm that integration tests work fine for him with that bit.

FOUR
};

struct TaggedPtr {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would really prefer to put the new definitions in a new test, because it is much easier to debug failing tests when they are small and isolated.

bitfield_align_2.h? issue_726.h?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd argue that it's somewhat easy to isolate once these fail, but sure :)


// Now we're working on a fresh bitfield allocation unit, so reset
// the current unit size and alignment.
#[allow(unused_assignments)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these assignments considered unused? Because we are always is_ms_struct == false?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only the unit_size_in_bits is unused, because we re-assign it in terms of offset. Still, I think it's saner to have all the assignments here.

In particular, the "flush the allocation unit" logic is only valid for
ms_structs (that is, MSVC).

It's slightly annoying to have this different behavior, but it'd work just fine
if we'd turn that on for MSVC.

This patch doesn't do that, yet at least, and adds tests for all the weird
bitfield alignments around.

Fixes rust-lang#726 (and another set of hidden issues by the old code).
@emilio
Copy link
Contributor Author

emilio commented Jun 5, 2017

@bors-servo r=fitzgen

@bors-servo
Copy link

📌 Commit 10106aa has been approved by fitzgen

@bors-servo
Copy link

⌛ Testing commit 10106aa with merge c0389c3...

bors-servo pushed a commit that referenced this pull request Jun 5, 2017
ir: Fix a bunch of bitfield correctness issues.

In particular, the "flush the allocation unit" logic is only valid for
ms_structs (that is, MSVC).

It's slightly annoying to have this different behavior, but it'd work just fine
if we'd turn that on for MSVC.

This patch doesn't do that, yet at least, and adds tests for all the weird
bitfield alignments around.

Fixes #726 (and another set of hidden issues by the old code).
@bors-servo
Copy link

☀️ Test successful - status-travis
Approved by: fitzgen
Pushing c0389c3 to master...

@bors-servo bors-servo merged commit 10106aa into rust-lang:master Jun 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants