diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2018-09-19 18:07:51 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-19 18:07:51 -0400 |
commit | 6fc0a31febb63d77da1a38aa2eea9d10fbea0d0d (patch) | |
tree | cb09d8cb35d94b1af4e3cf4f4bdf447d29a76029 /src/codegen/struct_layout.rs | |
parent | a54a9dc796372478d26fa5b165c3b4d129cbcfce (diff) | |
parent | c09c74e18b6ce8b69626a59737d8e82a3eb1d1b8 (diff) |
Auto merge of #1391 - emilio:u128, r=fitzgen
codegen: Generate u128 / i128 when available.
This is the first step to fix #1370 / #1338 / etc.
Fix for that will build up on this.
Diffstat (limited to 'src/codegen/struct_layout.rs')
-rw-r--r-- | src/codegen/struct_layout.rs | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/codegen/struct_layout.rs b/src/codegen/struct_layout.rs index 6de7e030..0ea23ddf 100644 --- a/src/codegen/struct_layout.rs +++ b/src/codegen/struct_layout.rs @@ -287,18 +287,23 @@ impl<'a> StructLayoutTracker<'a> { } pub fn requires_explicit_align(&self, layout: Layout) -> bool { + let repr_align = self.ctx.options().rust_features().repr_align; + + // Always force explicit repr(align) for stuff more than 16-byte aligned + // to work-around https://github.com/rust-lang/rust/issues/54341. + // + // Worst-case this just generates redundant alignment attributes. + if repr_align && self.max_field_align >= 16 { + return true; + } + if self.max_field_align >= layout.align { return false; } - // At this point we require explicit alignment, but we may not be able - // to generate the right bits, let's double check. - if self.ctx.options().rust_features().repr_align { - return true; - } // We can only generate up-to a word of alignment unless we support // repr(align). - layout.align <= self.ctx.target_pointer_size() + repr_align || layout.align <= self.ctx.target_pointer_size() } fn padding_bytes(&self, layout: Layout) -> usize { @@ -306,7 +311,7 @@ impl<'a> StructLayoutTracker<'a> { } fn padding_field(&mut self, layout: Layout) -> quote::Tokens { - let ty = helpers::blob(layout); + let ty = helpers::blob(self.ctx, layout); let padding_count = self.padding_count; self.padding_count += 1; |