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

Use ty::layout for ABI computation instead of LLVM types. #40658

Merged
merged 4 commits into from
Apr 9, 2017

Conversation

eddyb
Copy link
Member

@eddyb eddyb commented Mar 19, 2017

This is the first step in creating a backend-agnostic library for computing call ABI details from signatures.
I wanted to open the PR before attempting to move cabi_* from trans to avoid rebase churn in #39999.
EDIT: As I suspected, #39999 needs this PR to fully work (see #39999 (comment)).

The first 3 commits add more APIs to ty::layout and replace non-ABI uses of sizing_type_of.
These APIs are probably usable by other backends, and miri too (cc @stoklund @solson).

The last commit rewrites rustc_trans::cabi_* to use ty::layout and new rustc_trans::abi APIs.
Also, during the process, a couple trivial bugs were identified and fixed:

  • msp430, nvptx, nvptx64: type sizes in bytes were compared with 32 and 64
  • x86 (fastcall): f64 was incorrectly not treated the same way as f32

Although not urgent, this PR also uses the more general "homogenous aggregate" logic to fix #32045.

@rust-highfive
Copy link
Collaborator

r? @pnkfelix

(rust_highfive has picked a reviewer for you, use r? to override)

@eddyb
Copy link
Member Author

eddyb commented Mar 19, 2017

cc @rust-lang/compiler

Copy link
Member

@nagisa nagisa left a comment

Choose a reason for hiding this comment

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

Some nits gathered over the day.

@@ -1087,25 +1089,33 @@ impl<'a, 'gcx, 'tcx> Layout {
// Arrays and slices.
ty::TyArray(element, count) => {
let element = element.layout(infcx)?;
let element_size = element.size(dl);
let count = count as u64;
Copy link
Member

Choose a reason for hiding this comment

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

The cast is not necessary and is possibly dangerous (e.g. after a type in the declaration changes)

Copy link
Member Author

Choose a reason for hiding this comment

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

It's currently usize (even if it shouldn't be).

Copy link
Contributor

Choose a reason for hiding this comment

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

if we care, maybe make fn usize_to_u64(x: usize) and then do usize_to_u64(count)?

Copy link
Contributor

Choose a reason for hiding this comment

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

or (count: usize) as u64.

Copy link
Member Author

Choose a reason for hiding this comment

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

LOL. I'll add a whole variable dealing with this fact and a comment on it.

i: usize,
variant_index: Option<usize>)
-> Size {
match *self {
Copy link
Member

Choose a reason for hiding this comment

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

debug_assert i==0, perhaps?


ty::TyTuple(tys, _) => tys[i],

// SIMD vector types.
Copy link
Member

Choose a reason for hiding this comment

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

Assumes that all fields of a some vector must be the same (true for LLVM but not true for some architectures/proposals such as for RISC-V)

Not a big issue (also we discussed this on IRC already)

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, just to be super clear: ty::layout already assumes uniform vectors.
We'd have to overhaul it a bit when that assumption breaks down anyway.

}
}
// Currently supported vector size (AVX).
const LARGEST_VECTOR_SIZE: usize = 256;
Copy link
Member

Choose a reason for hiding this comment

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

AVX-512 has 512 bits. (Also discussed on IRC)

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, I meant AVX. AVX512 is different from AVX like SSE3 is different from SSE.

Copy link
Member Author

Choose a reason for hiding this comment

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

Also cc @BurntSushi on what stance we should have in terms of ABI compat.

Scalar { .. } |
CEnum { .. } |
UntaggedUnion { .. } |
RawNullablePointer { .. } => {
Copy link
Member Author

Choose a reason for hiding this comment

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

debug_assert i==0, perhaps?

You mean here? I might just take this out, except for UntaggedUnion. It was meant for something I abandoned.

@bors
Copy link
Contributor

bors commented Mar 20, 2017

☔ The latest upstream changes (presumably #39628) made this pull request unmergeable. Please resolve the merge conflicts.

@nikomatsakis
Copy link
Contributor

r? @nikomatsakis

@@ -1087,25 +1089,33 @@ impl<'a, 'gcx, 'tcx> Layout {
// Arrays and slices.
ty::TyArray(element, count) => {
let element = element.layout(infcx)?;
let element_size = element.size(dl);
let count = count as u64;
Copy link
Contributor

Choose a reason for hiding this comment

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

or (count: usize) as u64.

pub fn size_of(&self, ty: Ty<'tcx>) -> machine::llsize {
let layout = self.layout_of(ty);
layout.size(&self.tcx().data_layout).bytes() as machine::llsize
}
}

fn llvm_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, ty: Ty<'tcx>) -> String {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice catch!

@@ -202,6 +202,16 @@ impl TargetDataLayout {
}
}

pub trait HasDataLayout: Copy {
Copy link
Contributor

Choose a reason for hiding this comment

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

Generic bloat? Not sure this is worth worrying about.

}
}

pub trait LayoutTyper<'tcx>: HasTyCtxt<'tcx> {
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like a rather heavy abstraction - it is only used for .field, which is only called from trans::abi, which already defines LayoutExt. I'll move Layout::field to LayoutExt and remove this trait.

Copy link
Member Author

Choose a reason for hiding this comment

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

The abstraction exists so we can pull out the ABI computation into a separate crate, so the heaviness is intentional.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm fine with this if this is temporary code.

pub fn of(infcx: &InferCtxt<'a, 'gcx, 'tcx>, ty: Ty<'gcx>)
-> Result<Self, LayoutError<'gcx>> {
let ty = normalize_associated_type(infcx, ty);
pub trait HasTyCtxt<'tcx>: HasDataLayout {
Copy link
Contributor

Choose a reason for hiding this comment

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

If you are defining this trait, maybe move it to ty::fold and make TypeFolder a subtrait? Can you add a blanket impl<T: HasTyCtxt> HasDataLayout for T? Is there any place that needs data layout but does not have a tcx (aka do we need HasDataLayout)?

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried that and it required weird inexpressible region bounds to work, sadly.

@@ -133,32 +134,279 @@ impl ArgAttributes {
}
}

pub trait CastTarget {
Copy link
Contributor

@arielb1 arielb1 Mar 24, 2017

Choose a reason for hiding this comment

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

Any reason this is a trait rather than an enum (Reg | RegPair | Uniform)? That would make moving away from LLVM easier.

Copy link
Member Author

Choose a reason for hiding this comment

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

I wanted to make sure it works first, and the trait allows replacing with an enum later, but maybe I should do it now.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok

Copy link
Contributor

@arielb1 arielb1 left a comment

Choose a reason for hiding this comment

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

Looks excellent. I should look at this last commit more but I have to go.


// ADTs.
ty::TyAdt(def, _) => {
let v = if def.is_enum() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'll say "what about univariant enums" but you appear to have fixed this in the next commit.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll move it back (rebasing was painful when fixing that but now it should be fine.

ty::TyNever |
ty::TyFnDef(..) |
ty::TyDynamic(..) => {
ty::TyFnPtr(_) => {
bug!("TyLayout::field_type({:?}): not applicable", self)
Copy link
Contributor

@arielb1 arielb1 Mar 24, 2017

Choose a reason for hiding this comment

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

bug and comment are wrong - function is called field_count, and TyDynamic is not a ZST. OTOH, non-ADT/arrays have 0 fields, so presumably you should always return 0 for them (+TyStr).

Copy link
Member Author

Choose a reason for hiding this comment

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

It mostly has to match the Layout variant (maybe I should match on that instead).

}
}
RegKind::Vector => {
// Try to pick an integer at least twice as small.
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the motivation for this? AFAICT this seems to be used only for SSE/AVX on amd64 SysV, so the if statement can never be hit. If LLVM really does not care about the type of the vector elements as long as it has the right length, why not use [u8; N] everywhere? Or [u64; N] because all SIMD is a multiple of 64 bits.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll switch to <n x i8>, it's the cleanest simple solution.

use rustc::ty::layout::{self, Layout, TyLayout, Size};

#[derive(Clone, Copy, PartialEq, Debug)]
enum Class {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice to see we can reduce this.

SSEDv,
SSEInt(/* bitwidth */ u64),
LoneF32,
Sse,
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be worth commenting that this also includes AVX (yes I know the spec calls this Sse).

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, LoneF32 is also an Sse in the spec - the only difference is that we want to tell LLVM that only the lowest 32 bits matter. I'll make it a field of the enum.

Copy link
Member Author

Choose a reason for hiding this comment

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

There's a more elegant way to handle this (last Sse with only 4 bytes of data left, only way to get LoneF32 anyway, unless you have weird padding). I'll try to implement it.
Also, clang does somewhat complex type recovery - I don't think we care, as this is for FFI.

@@ -1513,6 +1531,59 @@ impl<'a, 'gcx, 'tcx> Layout {
}
}
}

pub fn field_offset(&self,
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like some comments, or better choice of names, would be good here. e.g. what is i -- the index of the field, I guess? variant_index is for structs/enums? (I'd also find the opposite order of those parameters more intuitive, but I can't say why -- I guess because the i is defined relative to variant_index)

Copy link
Member Author

Choose a reason for hiding this comment

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

We'll hopefully eventually remove variant_index by adding variant types, so I'm not sure how much I care about it.

@nikomatsakis
Copy link
Contributor

OK, since @arielb1 and @nagisa are already giving this a detailed look, I gave it more of a cursory overview. Seems quite nice to me, but I didn't dig into the last commit, which is obviously where most of the subtle logic resides.

Copy link
Contributor

@arielb1 arielb1 left a comment

Choose a reason for hiding this comment

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

Most changes should be fixed in a separate PR, but I don't like the "pirate" pair of floats feature in this PR.

}
}

pub trait LayoutTyper<'tcx>: HasTyCtxt<'tcx> {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm fine with this if this is temporary code.

self.layout.field_offset(cx, i, self.variant_index)
}

pub fn field_count<C: HasTyCtxt<'tcx>>(&self, cx: C) -> usize {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you match on the layout instead?

@@ -133,32 +134,279 @@ impl ArgAttributes {
}
}

pub trait CastTarget {
Copy link
Contributor

Choose a reason for hiding this comment

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

ok

return;
}

// Pairs of floats.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not present in the original code. Random micro-optimization?

Copy link
Member Author

@eddyb eddyb Mar 25, 2017

Choose a reason for hiding this comment

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

Oh I meant to find that issue and mention it in the description. This is a long-wanted feature and now it's easy to implement so I just did it when I rewrote that code.

let fields = variant.field_index_by_increasing_offset().map(|i| fields[i as usize]);
if sizing {
fields.filter(|ty| !dst || cx.shared().type_is_sized(*ty))
.map(|ty| type_of::sizing_type_of(cx, ty)).collect()
bug!()
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: remove the sizing and dst parameters? They don't seem to be used anywhere.

Copy link
Member Author

Choose a reason for hiding this comment

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

Have to keep to allow #39999 to rebase.

let size = ret.layout.size(ccx);
let bits = size.bits();
if bits <= 128 {
let unit = if bits <= 8 {
Copy link
Contributor

Choose a reason for hiding this comment

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

can't this logic be lifted to abi? It appears to be used in several places, including the Rust ABI.

SSEDv,
SSEInt(/* bitwidth */ u64),
LoneF32,
Sse,
Copy link
Contributor

Choose a reason for hiding this comment

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

Also, LoneF32 is also an Sse in the spec - the only difference is that we want to tell LLVM that only the lowest 32 bits matter. I'll make it a field of the enum.


#[derive(Clone, Copy, PartialEq, Debug)]
enum Class {
None,
Copy link
Contributor

Choose a reason for hiding this comment

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

This is called NoClass in the spec. Why not stick to it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because Class::NoClass is unidiomatic.

@@ -121,13 +121,13 @@ pub fn unsafe_slice(_: &[UnsafeInner]) {
fn str(_: &[u8]) {
}

// CHECK: @trait_borrow(i8* nonnull, void (i8*)** noalias nonnull readonly)
// CHECK: @trait_borrow({}* nonnull, {}* noalias nonnull readonly)
Copy link
Contributor

Choose a reason for hiding this comment

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

Are LLVM's problems with unit pointers gone?

Copy link
Member Author

Choose a reason for hiding this comment

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

Those problems were only around C FFI were LLVM was looking for a specific signature, IIRC.
i.e. Not unit pointers were the problem but any pointer thst wasn't i8*.

@arielb1
Copy link
Contributor

arielb1 commented Mar 25, 2017

@bors r+

@bors
Copy link
Contributor

bors commented Mar 25, 2017

📌 Commit 6ac00de has been approved by arielb1

@bors
Copy link
Contributor

bors commented Mar 25, 2017

⌛ Testing commit 6ac00de with merge 0b20dbd...

@bors
Copy link
Contributor

bors commented Mar 25, 2017

💔 Test failed - status-travis

@arielb1
Copy link
Contributor

arielb1 commented Mar 25, 2017

@bors
Copy link
Contributor

bors commented Mar 25, 2017

⌛ Testing commit 6ac00de with merge 5f08d8d...

@bors
Copy link
Contributor

bors commented Mar 25, 2017

💔 Test failed - status-travis

@eddyb
Copy link
Member Author

eddyb commented Apr 8, 2017

@bors r=arielb1

@bors
Copy link
Contributor

bors commented Apr 8, 2017

📌 Commit 1759358 has been approved by arielb1

@bors
Copy link
Contributor

bors commented Apr 8, 2017

⌛ Testing commit 1759358 with merge fbe44d3...

@eddyb
Copy link
Member Author

eddyb commented Apr 8, 2017

@bors r- retry

@eddyb
Copy link
Member Author

eddyb commented Apr 8, 2017

@bors r=arielb1

@bors
Copy link
Contributor

bors commented Apr 8, 2017

📌 Commit a8dd65a has been approved by arielb1

@bors
Copy link
Contributor

bors commented Apr 9, 2017

⌛ Testing commit a8dd65a with merge c5404c5...

@bors
Copy link
Contributor

bors commented Apr 9, 2017

💔 Test failed - status-travis

@eddyb
Copy link
Member Author

eddyb commented Apr 9, 2017

@bors retry

  • unrelated (AFAICT) emscripten failure ("The end of the file was unexpectedly encountered")

@nagisa
Copy link
Member

nagisa commented Apr 9, 2017

This is the log of the error (there are multiple like these:

[00:52:59] error: linking with `emcc` failed: exit code: 1
[00:52:59]   |
[00:52:59]   = note: "emcc" "-s" "DISABLE_EXCEPTION_CATCHING=0" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-fail/test-should-panic-no-message.0.o" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-fail/test-should-panic-no-message.stage2-asmjs-unknown-emscripten.js" "-s" "EXPORTED_FUNCTIONS=[\"_main\",\"_rust_eh_personality\"]" "-O2" "--memory-init-file" "0" "-g0" "-s" "DEFAULT_LIBRARY_FUNCS_TO_INCLUDE=[]" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-fail" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-fail/test-should-panic-no-message.stage2-asmjs-unknown-emscripten.run-fail.libaux" "-L" "/checkout/obj/build/asmjs-unknown-emscripten/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib/libtest-6c35a477e7bec8d3.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib/libterm-fa872424129019f5.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib/libgetopts-a80f7c589731de53.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib/libstd-f4594d3e53dcb114.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib/libpanic_unwind-a0157c0ca919c364.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib/libunwind-488b4ab4bd53a138.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib/librand-1efbcfd8938372b6.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib/libcollections-532a3dbf317eff86.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib/liballoc-ca07b617414dd0fa.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib/libstd_unicode-cfbd6648f7db2ee5.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib/liballoc_system-68e33a366943aef4.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib/liblibc-88c194c15fdb6521.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib/libcore-687e6a964d22cbb4.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib/libcompiler_builtins-987729be881d4d32.rlib" "-l" "c" "-s" "ERROR_ON_UNDEFINED_SYMBOLS=1"
[00:52:59]   = note: /tmp/emsdk_portable/clang/tag-e1.37.1/build_tag-e1.37.1_32/bin/llvm-nm: /checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib/libtest-6c35a477e7bec8d3.rlib(rust.metadata.bin) The end of the file was unexpectedly encountered
[00:52:59]           
[00:52:59]           /tmp/emsdk_portable/clang/tag-e1.37.1/build_tag-e1.37.1_32/bin/llvm-nm: /checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib/libterm-fa872424129019f5.rlib(rust.metadata.bin) The end of the file was unexpectedly encountered
[00:52:59]           
[00:52:59]           /tmp/emsdk_portable/clang/tag-e1.37.1/build_tag-e1.37.1_32/bin/llvm-nm: /checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib/libgetopts-a80f7c589731de53.rlib(rust.metadata.bin) The end of the file was unexpectedly encountered
[00:52:59]           
[00:52:59]           /tmp/emsdk_portable/clang/tag-e1.37.1/build_tag-e1.37.1_32/bin/llvm-nm: /checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib/libstd-f4594d3e53dcb114.rlib(rust.metadata.bin) The end of the file was unexpectedly encountered
[00:52:59]           
[00:52:59]           /tmp/emsdk_portable/clang/tag-e1.37.1/build_tag-e1.37.1_32/bin/llvm-nm: /checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib/libpanic_unwind-a0157c0ca919c364.rlib(rust.metadata.bin) The end of the file was unexpectedly encountered
[00:52:59]           
[00:52:59]           /tmp/emsdk_portable/clang/tag-e1.37.1/build_tag-e1.37.1_32/bin/llvm-nm: /checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib/libunwind-488b4ab4bd53a138.rlib(rust.metadata.bin) The end of the file was unexpectedly encountered
[00:52:59]           
[00:52:59]           /tmp/emsdk_portable/clang/tag-e1.37.1/build_tag-e1.37.1_32/bin/llvm-nm: /checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib/librand-1efbcfd8938372b6.rlib(rust.metadata.bin) The end of the file was unexpectedly encountered
[00:52:59]           
[00:52:59]           /tmp/emsdk_portable/clang/tag-e1.37.1/build_tag-e1.37.1_32/bin/llvm-nm: /checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib/libcollections-532a3dbf317eff86.rlib(rust.metadata.bin) The end of the file was unexpectedly encountered
[00:52:59]           
[00:52:59]           /tmp/emsdk_portable/clang/tag-e1.37.1/build_tag-e1.37.1_32/bin/llvm-nm: /checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib/liballoc-ca07b617414dd0fa.rlib(rust.metadata.bin) The end of the file was unexpectedly encountered
[00:52:59]           
[00:52:59]           /tmp/emsdk_portable/clang/tag-e1.37.1/build_tag-e1.37.1_32/bin/llvm-nm: /checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib/libstd_unicode-cfbd6648f7db2ee5.rlib(rust.metadata.bin) The end of the file was unexpectedly encountered
[00:52:59]           
[00:52:59]           /tmp/emsdk_portable/clang/tag-e1.37.1/build_tag-e1.37.1_32/bin/llvm-nm: /checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib/liballoc_system-68e33a366943aef4.rlib(rust.metadata.bin) The end of the file was unexpectedly encountered
[00:52:59]           
[00:52:59]           /tmp/emsdk_portable/clang/tag-e1.37.1/build_tag-e1.37.1_32/bin/llvm-nm: /checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib/liblibc-88c194c15fdb6521.rlib(rust.metadata.bin) The end of the file was unexpectedly encountered
[00:52:59]           
[00:52:59]           /tmp/emsdk_portable/clang/tag-e1.37.1/build_tag-e1.37.1_32/bin/llvm-nm: /checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib/libcore-687e6a964d22cbb4.rlib(rust.metadata.bin) The end of the file was unexpectedly encountered
[00:52:59]           
[00:52:59]           /tmp/emsdk_portable/clang/tag-e1.37.1/build_tag-e1.37.1_32/bin/llvm-nm: /checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib/libcompiler_builtins-987729be881d4d32.rlib(rust.metadata.bin) The end of the file was unexpectedly encountered
[00:52:59]           
[00:52:59]           Value:   %.fca.1.insert109.i361.i = phi [2 x double] [ %.fca.1.insert109.i.i, %bb21.i.thread.i ], [ %.fca.1.insert109.i353.i, %bb3.i33.i.preheader.i ]
[00:52:59]           LLVM ERROR: Unrecognized struct value
[00:52:59]           Traceback (most recent call last):
[00:52:59]             File "/tmp/emsdk_portable/emscripten/tag-1.37.1/emcc", line 13, in <module>
[00:52:59]               emcc.run()
[00:52:59]             File "/tmp/emsdk_portable/emscripten/tag-1.37.1/emcc.py", line 1635, in run
[00:52:59]               final = shared.Building.emscripten(final, append_ext=False, extra_args=extra_args)
[00:52:59]             File "/tmp/emsdk_portable/emscripten/tag-1.37.1/tools/shared.py", line 1745, in emscripten
[00:52:59]               call_emscripten(cmdline)
[00:52:59]             File "/tmp/emsdk_portable/emscripten/tag-1.37.1/emscripten.py", line 1783, in _main
[00:52:59]               temp_files.run_and_clean(lambda: main(
[00:52:59]             File "/tmp/emsdk_portable/emscripten/tag-1.37.1/tools/tempfiles.py", line 78, in run_and_clean
[00:52:59]               return func()
[00:52:59]             File "/tmp/emsdk_portable/emscripten/tag-1.37.1/emscripten.py", line 1788, in <lambda>
[00:52:59]               DEBUG=DEBUG,
[00:52:59]             File "/tmp/emsdk_portable/emscripten/tag-1.37.1/emscripten.py", line 1689, in main
[00:52:59]               temp_files=temp_files, DEBUG=DEBUG)
[00:52:59]             File "/tmp/emsdk_portable/emscripten/tag-1.37.1/emscripten.py", line 91, in emscript
[00:52:59]               funcs, metadata, mem_init = get_and_parse_backend(infile, settings, temp_files, DEBUG)
[00:52:59]             File "/tmp/emsdk_portable/emscripten/tag-1.37.1/emscripten.py", line 157, in get_and_parse_backend
[00:52:59]               backend_output = open(temp_js).read()
[00:52:59]           IOError: [Errno 2] No such file or directory: '/tmp/tmpswNHZh.4.js'
[00:52:59]           
[00:52:59] 
[00:52:59] error: aborting due to previous error
[00:52:59] 
[00:52:59] 
[00:52:59] ------------------------------------------
[00:52:59] 
[00:52:59] thread '[run-fail] run-fail/test-should-panic-no-message.rs' panicked at 'explicit panic', /checkout/src/tools/compiletest/src/runtest.rs:2621

This is not related to the out-of-disk-space errors. There’s still plenty left.

cc @alexcrichton this one is new.

@eddyb
Copy link
Member Author

eddyb commented Apr 9, 2017

@bors r- Aaaaah there's an LLVM error in there, thanks!

@eddyb
Copy link
Member Author

eddyb commented Apr 9, 2017

This appears to be an emscripten bug, which I've filed as emscripten-core/emscripten-fastcomp#178.
I'll try to work around it by not using Uniform in the Rust ABI and I'll leave a FIXME in.

@eddyb
Copy link
Member Author

eddyb commented Apr 9, 2017

@bors r=arielb1

@bors
Copy link
Contributor

bors commented Apr 9, 2017

📌 Commit f0636b6 has been approved by arielb1

@bors
Copy link
Contributor

bors commented Apr 9, 2017

⌛ Testing commit f0636b6 with merge 2c48ae6...

bors added a commit that referenced this pull request Apr 9, 2017
Use ty::layout for ABI computation instead of LLVM types.

This is the first step in creating a backend-agnostic library for computing call ABI details from signatures.
I wanted to open the PR *before* attempting to move `cabi_*` from trans to avoid rebase churn in #39999.
**EDIT**: As I suspected, #39999 needs this PR to fully work (see #39999 (comment)).

The first 3 commits add more APIs to `ty::layout` and replace non-ABI uses of `sizing_type_of`.
These APIs are probably usable by other backends, and miri too (cc @stoklund @solson).

The last commit rewrites `rustc_trans::cabi_*` to use `ty::layout` and new `rustc_trans::abi` APIs.
Also, during the process, a couple trivial bugs were identified and fixed:
* `msp430`, `nvptx`, `nvptx64`: type sizes *in bytes* were compared with `32` and `64`
* `x86` (`fastcall`): `f64` was incorrectly not treated the same way as `f32`

Although not urgent, this PR also uses the more general "homogenous aggregate" logic to fix #32045.
@bors
Copy link
Contributor

bors commented Apr 9, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: arielb1
Pushing 2c48ae6 to master...

@bors bors merged commit f0636b6 into rust-lang:master Apr 9, 2017
@eddyb eddyb deleted the lay-more-out branch April 9, 2017 15:31
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Apr 12, 2017
Fix pairs of doubles using an illegal <8 x i8> vector.

Accidentally introduced in rust-lang#40658 and discovered in some Objective-C bindings (returning `NSPoint`).
Turns out LLVM will widen element types of illegal vectors instead of increasing element count, i.e. it will zero-extend `<8 x i8>` to `<8 x i16>`, interleaving the bytes, instead of using the first 8 of `<16 x i8>`.
TimNN added a commit to TimNN/rust that referenced this pull request Apr 12, 2017
Fix pairs of doubles using an illegal <8 x i8> vector.

Accidentally introduced in rust-lang#40658 and discovered in some Objective-C bindings (returning `NSPoint`).
Turns out LLVM will widen element types of illegal vectors instead of increasing element count, i.e. it will zero-extend `<8 x i8>` to `<8 x i16>`, interleaving the bytes, instead of using the first 8 of `<16 x i8>`.
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.

Sub-optimal codegen for f32 tuples
7 participants