Skip to content

add core::arch::{x86, x86_64}::x87_f80 - #163992

Open
folkertdev wants to merge 1 commit into
rust-lang:mainfrom
folkertdev:x87_f80-simple
Open

folkertdev wants to merge 1 commit into
rust-lang:mainfrom
folkertdev:x87_f80-simple

Conversation

@folkertdev

@folkertdev folkertdev commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

View all comments

tracking issue: #163982
cc #161787

Add x87_f80 in the same way as f16b and ppcf128.

This changes the signature of size because the size of x87_f80 depends on the target (12 bytes on 32-bit targets, 16 bytes on 64-bit targets).

It also breaks an invariant that scalars are the size of their fields: the x87_f80 scalar is 80 bits, but the field is the aforementioned 12 or 16 bytes. Let's hope we don't subtly rely on that somewhere.


It's unclear what to do with this type on softfloat targets. Clang and GCC reject the type when the x87 registers are not available. We should do the same, probably just with a cfg?

I don't think we have a good cfg for this though? x87 is still set on softfloat targets, while soft-float doesn't get set (that does not give a warning even, it probably should?). We also don't set cfg_abi.

future work

  • the ABI of Complex<x87_f80> has not yet been implemented
  • x87_f80 does not yet implement VaArgSafe

@folkertdev folkertdev added the F-c_longdouble `#![feature(c_longdouble)]` label Oct 8, 2026
@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-test-infra-minicore Area: `minicore` test auxiliary and `//@ add-core-stubs` S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Oct 8, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

Comment on lines +108 to +132
assert_eq!(
layout.layout.size(),
size,
"size mismatch between ABI and layout in {layout:#?}"
);
if is_x87 {
assert_eq!(
layout.layout.size(),
size.align_to(align.unwrap()),
"size mismatch between ABI and layout in {layout:#?}"
);
} else {
assert_eq!(
layout.layout.size(),
size,
"size mismatch between ABI and layout in {layout:#?}"
);
}

@folkertdev folkertdev Oct 8, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The old invariant now no longer holds. CI passes here but who knows where we implicitly rely on it.

View changes since the review

Comment on lines +35 to +36
// SAFETY: the first 10 bytes are initialized.
unsafe { *(&raw const self).cast::<[u8; 10]>() }

@folkertdev folkertdev Oct 8, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We could use https://doc.rust-lang.org/std/mem/fn.transmute_prefix.html here but I don't see that used anywhere else yet.

View changes since the review

@folkertdev

Copy link
Copy Markdown
Contributor Author

r? beetrees
cc @tgross35 @RalfJung

@folkertdev
folkertdev marked this pull request as ready for review October 8, 2026 19:07
@rustbot

rustbot commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

stdarch is developed in its own repository. If possible, consider making this change to rust-lang/stdarch instead.

cc @Amanieu, @sayantn

Some changes occurred in compiler/rustc_attr_ir

cc @jdonszelmann, @JonathanBrouwer

rustc_codegen_cranelift is developed in its own repository. If possible, consider making this change to rust-lang/rustc_codegen_cranelift instead.

cc @bjorn3

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

This PR changes rustc_public

cc @oli-obk, @celinval, @ouz-a, @makai410

rustc_codegen_gcc is developed in its own repository. If possible, consider making this change to rust-lang/rustc_codegen_gcc instead.

cc @antoyo, @GuillaumeGomez

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 8, 2026
@folkertdev

Copy link
Copy Markdown
Contributor Author

@bors try jobs=test-various,test-i686-*

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Oct 8, 2026
add `core::arch::{x86, x86_64}::x87_f80`


try-job: test-various
try-job: test-i686-*
Comment on lines +43 to +48
// SAFETY: we initialize the first 10 bytes, any bit pattern is valid.
unsafe {
let mut tmp = crate::mem::MaybeUninit::<Self>::uninit();
tmp.as_mut_ptr().cast::<[u8; 10]>().write(bytes);
tmp.assume_init()
}

@tgross35 tgross35 Oct 8, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe transmute_copy for a bit simpler impl? Maybe also for to_ne_bytes

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That is UB because size_of_val::<Src>(src) >= size_of::<Dst>() does not hold

https://doc.rust-lang.org/std/mem/fn.transmute_copy.html

Hence my suggestion for

https://doc.rust-lang.org/std/mem/fn.transmute_prefix.html

#[allow(non_camel_case_types)]
#[doc(cfg(any(target_arch = "x86", target_arch = "x86_64")))]
#[derive(Clone, Copy)]
pub struct x87_f80([u8; 10]);

@tgross35 tgross35 Oct 8, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you assert the size+align of this somewhere? Since it's an unusual combination of those for a primitive.

View changes since the review

@rust-bors

rust-bors Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 4923e95 (4923e95bc1c5973505d6b35dcddbc97d11ae69e5)
Base parent: 65efa19 (65efa194201c67ba29b7384255a534d61c2aa3cb)

@RalfJung

RalfJung commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

This changes the signature of size because the size of x87_f80 depends on the target (12 bytes on 32-bit targets, 16 bytes on 64-bit targets).

"f80" is 128 bits large on 64-bit targets...?!?? How does that make any sense?

It also breaks an invariant that scalars are the size of their fields: the x87_f80 scalar is 80 bits, but the field is the aforementioned 12 or 16 bytes. Let's hope we don't subtly rely on that somewhere.

I'd be surprised if we didn't. That's been pretty much part of the definition of being a scalar -- if a type has padding, it is not a scalar type. The interpreter was built around that assumption.
Cc @scottmcm who recently generalized what a scalar can be, but even with that I don't think it can have padding.

It does not sound to me like this type can be a scalar, then.

Comment on lines +600 to +607
// For `x87_f80` the primitive is 80 bits, but the field (after rounding up to
// the alignment) is 12 bytes (on 32-bit systems) or 16 bytes (64-bit).
// So we can't assert equality of size and layout.size.
assert_eq!(
size.align_to(s.default_align(self).abi),
mplace.layout.size,
"abi::Scalar is larger than its layout"
);

@RalfJung RalfJung Oct 9, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The entire logic for dealing with scalars throughout the interpreter assumes that they have no padding. Changing this assertion is not enough, it just means the rest of the interpreter is now more or less silently wrong. Pretty much all codepaths that deal with scalars need to be audited. Same for every other MIR consumer.

I would strongly prefer if we didn't break the fundamental concept of a "scalar".

View changes since the review

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

To give just one example, here's one place we make that assumption:

Immediate::Scalar(scalar) => {
alloc.write_scalar(alloc_range(Size::ZERO, scalar.size()), scalar)?;
}

You can't even see it. But if you look at the ScalarPair path you can see that we have to ensure that padding gets reset to uninit, and in the Scalar path we don't have to worry about that.

Also, the basic APIs for reading/writing stuff in an Allocation are read_scalar/write_scalar. This again uses the term "scalar" to refer to something that has no padding. Same for the type Scalar. And so on.

@RalfJung

RalfJung commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

It would probably be possible, with a lot of effort, to fix all the places where we assume scalars have no padding. But I think that's a bad idea. It makes life harder for every MIR consumer. (Most likely it'll mean many MIR consumers will stay buggy as nobody will expect something as outlandish as this weird type.) This new type is the weird one here, we should not shape everything around a legacy type that hardly anyone needs and that has no justification to exist in the first place other than "it has always been here".

@beetrees

beetrees commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

I think it might make sense to introduce something like BackendRepr::PaddedScalar (name bikesheddable)? This would be useful for more than just x87_f80: e.g. currently we can (don't have my laptop to check if we currently do) represent #[repr(align(16))] struct A(u8, u8); as a BackendRepr::ScalarPair, whereas #[repr(align(16))] struct A(u8); currently has to be represented as BackendRepr::Memory as it has padding.

@tgross35

tgross35 commented Oct 9, 2026

Copy link
Copy Markdown
Member

For Rust's purposes could we just pretend it's a MaybeUninit<u128> on x86-64 rather than treating it as a padded scalar?

@rustbot

This comment has been minimized.

@folkertdev
folkertdev force-pushed the x87_f80-simple branch 5 times, most recently from dc364ad to 280df50 Compare October 12, 2026 09:16

@folkertdev folkertdev left a comment •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines +78 to +81
// Map `core::arch::{x86, x86_64}::x87_f80` to LLVM's `x86_fp80`.
if Ty::is_x87_f80_lang_item(layout, cx) {
return cx.type_x87_f80();
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

So, this is really all it takes in the LLVM backend to make this type work. it gets the LLVM store size of 10 bytes (touched by load/store) and target-dependent alloc size of 12 or 16.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

x87_f80 is BackendRepr::Memory, so we should never be loading or storing its LLVM type. Instead, when uncached_llvm_type is fetching the type of the field of a struct or array, it should replace any occurrences of x87_f80_raw with [10 x i8]. This will ensure the returned struct always has the right size, which I AFAICT is the problem this is here to solve. Additionally, could you add an assert with FIXME to CastTarget::llvm_type ensuring it never returns an LLVM struct/array containing an LLVM x86_fp80 - load_cast/store_cast currently load/store the LLVM cast target aggregate directly (which is not generally a good idea for reasons like this, but that can be fixed in a separate PR).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think the LLVM type just behaves correctly though? It has a store size of 10 but an allocation size of 12/16, and LLVM uses the right value in the right context as far as I can tell. Hence, we don't need to manually convert to the array?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

phrased differently: what sort of code do you think fails with the current implementation, because we should test its behavior either way.

Comment thread compiler/rustc_ty_utils/src/layout.rs Outdated
Comment on lines +837 to +841
let x87_f80 = scalar_unit(Primitive::Float(abi::Float::X87F80));
assert_eq!(layout.size, abi::Float::X87F80.size());
layout.align = abi::Float::X87F80.align(cx);
layout.size = layout.size.align_to(layout.align.abi);
layout.backend_repr = BackendRepr::Scalar(x87_f80);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Eh, yeah, seems to work.

#[inline]
pub const fn to_ne_bytes(self) -> [u8; 10] {
// SAFETY: the first 10 bytes are initialized.
unsafe { (&raw const self).cast::<[u8; 10]>().read() }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

A self.0 projection here trips up const eval, so a pointer read will have to do.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What does "trips up const eval" mean?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I misremembered and the actual problem is from_ne_bytes. I think the problem is similar to how directly using the inner array of the Simd type is fragile.

In this case we hit the bug! in

(OperandValue::Ref(place), BackendRepr::Memory { .. }) => match &mut self.val {
OperandValueBuilder::Vector(val @ Either::Right(())) => {
let ibty = bx.cx().immediate_backend_type(self.layout);
let simd = bx.load_from_place(ibty, place);
*val = Either::Left(simd);
}
_ => {
bug!("Tried to insert {field_operand:?} into {variant:?}.{field:?} of {self:?}")
}
},

error: internal compiler error: compiler/rustc_codegen_ssa/src/mir/operand.rs:876:21: Tried to insert OperandRef(Ref(PlaceValue { llval: (ptr:ptr %1), llextra: None, align: Align(1 bytes) }) @ TyAndLayout { ty: [u8; 10], layout: Layout { size: Size(10 bytes), align: AbiAlign { abi: Align(1 bytes) }, backend_repr: Memory { sized: true }, fields: Array { stride: Size(1 bytes), count: 10 }, largest_niche: None, uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), repr_c: false, randomization_seed: 71776127651151883 } }) into 0.0 of OperandRefBuilder { val: Immediate(Right(x87_f80 is ..)), layout: TyAndLayout { ty: core::core_arch::x86::x87_f80_raw, layout: Layout { size: Size(10 bytes), align: AbiAlign { abi: Align(1 bytes) }, backend_repr: Scalar(x87_f80 is ..), fields: Arbitrary { offsets: [Size(0 bytes)], in_memory_order: [0] }, largest_niche: None, uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), repr_c: false, randomization_seed: 4653255336921355707 } } }

With debug assertions (if I remember right) you hit an assert earlier. But also, in line with Simd, it seems best to just not use projections into lang items like this?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(That's not const-eval. ;)

I would have expected that this behaves mostly like a repr(align) struct where projections are fine. But I guess there's a reason that you made it more like Simd?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The x87_f80_raw struct is still considered a scalar internally (with a size of 80 bits and an alignment of 1). Projecting an array out of that is fragile, and easy enough to work around.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oh yeah. That projection should not be allowed.

Why is this a lang item rather than a repr? It seems most parallel with repr(simd) and repr(complex).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We don't have repr(complex) any more, we went with just a lang item for Complex<T>. From what I understand repr(simd) also has its issues.

The main annoyance (reading back the discussion on #158885) is the interaction with other repr attributes, and no longer being able to make use of default paths in some functions. A lang item is much more targeted.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
unsafe { (&raw const self).cast::<[u8; 10]>().read() }
unsafe { mem::transmute(self.0) }

I think this should work now?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, self.0 has type core::num::imp::x87_f80 which is not 10 bytes in size. The raw field is (deliberately) private.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Makes sense.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 12, 2026
Comment on lines +121 to +124
if layout.backend_repr.is_x87_f80() {
// The lang item wraps a byte array, so it is not a newtype of a scalar.
return;
}

@RalfJung RalfJung Oct 15, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seems like this type is still breaking basic MIR assumptions that have been true since forever and that code inside and outside the compiler is likely to rely on in subtle ways. Why that?

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Well we don't have any 80-bit scalars available to wrap transparently. So we'd have to make this type fully magic. But I guess f32 kind of is (like, it doesn't wrap [u8; 4] or u32) so maybe that could just work. I'll have to look into that.

/// alignment, raising the total size to 12 or 16.
///
/// NOTE: this type MUST NOT be used anywhere except in the x87_f80 wrapper below.
#[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), lang = "x87_f80_raw")] // for docs

@RalfJung RalfJung Oct 15, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What does "for docs" mean here? The attribute seems quite important not just for docs...?

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Right, it's the cfg_attr that is important for a docs build: we now error on encountering the lang item on non-x86 targets. Just to make sure we never trigger that in a doc build, never declare the lang item on non-x86 targets.

@beetrees

Copy link
Copy Markdown
Contributor

With this new implementation, Rust type x87_f80_raw is size 10 but the LLVM (non-immediate) backend type x86_fp80 has an allocation size of 12/16. While in the source code it is only ever interacted with via Rust type x87_fp80, AFAICT it can at minimum still end up as the type of a local variable via MIR passes like SROA. This feels like something that could cause issues, although I haven't been able to come up with an example, so maybe not? Would changing the non-immediate backend type (llvm_type) to [10 x i8] for anything with BackendRepr::Scalar(Float::X87F80) work to solve this?

@rust-bors

This comment has been minimized.

@scottmcm

scottmcm commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

Cc @scottmcm who recently generalized what a scalar can be, but even with that I don't think it can have padding.

I was working on allowing different alignments, but as you say, not changing anything about adding padding or similar.


There's definitely a bunch of places that assume that Scalars of matching size are sound to transmute, for example. Changing that would affect all kinds of places and I agree that we shouldn't muck with that.

@rustbot

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rustbot

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rustbot

rustbot commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

F16 | F16B => dl.f16_align,
F32 => dl.f32_align,
F64 => dl.f64_align,
X87F80 => Align::ONE,

@beetrees beetrees Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Might be worth a short comment here explaining why this isn't dl.x87_f80_align?

View changes since the review

Comment thread compiler/rustc_abi/src/layout/ty.rs
Comment on lines +78 to +81
// Map `core::arch::{x86, x86_64}::x87_f80` to LLVM's `x86_fp80`.
if Ty::is_x87_f80_lang_item(layout, cx) {
return cx.type_x87_f80();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

x87_f80 is BackendRepr::Memory, so we should never be loading or storing its LLVM type. Instead, when uncached_llvm_type is fetching the type of the field of a struct or array, it should replace any occurrences of x87_f80_raw with [10 x i8]. This will ensure the returned struct always has the right size, which I AFAICT is the problem this is here to solve. Additionally, could you add an assert with FIXME to CastTarget::llvm_type ensuring it never returns an LLVM struct/array containing an LLVM x86_fp80 - load_cast/store_cast currently load/store the LLVM cast target aggregate directly (which is not generally a good idea for reasons like this, but that can be fixed in a separate PR).

Comment thread compiler/rustc_abi/src/layout/ty.rs
Comment thread compiler/rustc_target/src/callconv/mips64.rs Outdated
/// The `x87_f80` wrapper type below corresponds to the alloc size: it applies the target-specific
/// alignment, raising the total size to 12 or 16.
///
/// NOTE: this type MUST NOT be used anywhere except in the x87_f80 wrapper below.

@beetrees beetrees Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This note shouldn't be necessary if everything is working properly. If it is, it suggests there's a deeper problem that needs to be fixed before this is merged. x87_f80 should be like Complex<T>: is a lang item for ABI purposes, but otherwise is a regular struct.

View changes since the review

#[inline]
pub const fn to_ne_bytes(self) -> [u8; 10] {
// SAFETY: the first 10 bytes are initialized.
unsafe { (&raw const self).cast::<[u8; 10]>().read() }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
unsafe { (&raw const self).cast::<[u8; 10]>().read() }
unsafe { mem::transmute(self.0) }

I think this should work now?

Comment on lines +71 to +77
// SAFETY: we initialize the first 10 bytes, the remaining bytes remain uninitialized.
// That is exactly the layout of x87_f80.
unsafe {
let mut this = crate::mem::MaybeUninit::<x87_f80>::uninit();
this.as_mut_ptr().cast::<[u8; 10]>().write(bytes);
this.assume_init()
}

@beetrees beetrees Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
// SAFETY: we initialize the first 10 bytes, the remaining bytes remain uninitialized.
// That is exactly the layout of x87_f80.
unsafe {
let mut this = crate::mem::MaybeUninit::<x87_f80>::uninit();
this.as_mut_ptr().cast::<[u8; 10]>().write(bytes);
this.assume_init()
}
// SAFETY: All bit patterns are valid for `x87_f80_raw`
unsafe { Self(mem::transmute(bytes)) }

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Similarly here the suggested transmute has a size mismatch.

Comment thread tests/assembly-llvm/x87_f80.rs
16 => dl.f16_align,
32 => dl.f32_align,
64 => dl.f64_align,
80 => dl.x87_f80_align,

@beetrees beetrees Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Given that (80 / 8) % dl.x87_f80_align != 0, could you add a comment here explaining why this is correct (I think it is as the align is only used to affect the overall alignment of the cast alloca, but we should document that fact somewhere to avoid confusion).

View changes since the review

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 28, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-test-infra-minicore Area: `minicore` test auxiliary and `//@ add-core-stubs` F-c_longdouble `#![feature(c_longdouble)]` S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants