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

Support repr(simd) on ADTs containing a single array field #63531

Open
wants to merge 9 commits into
base: master
from

Conversation

@gnzlbg
Copy link
Contributor

commented Aug 13, 2019

This PR allows using #[repr(simd)] on ADTs containing a
single array field:

 #[repr(simd)] struct S0([f32; 4]);
 #[repr(simd)] struct S1<const N: usize>([f32; N]);
 #[repr(simd)] struct S2<T, const N: usize>([T; N]);

This should allow experimenting with portable packed SIMD
abstractions on nightly that make use of const generics.

It also has a fly-by cleanup that removes simd_type and simd_size methods.

r? @eddyb

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

commented Aug 13, 2019

Some changes occurred in diagnostic error codes

cc @GuillaumeGomez

for fi in &def.non_enum_variant().fields {
if fi.ty(tcx, substs) != f0_ty {
tcx.sess.fatal(&format!(
"monomorphising heterogeneous SIMD type `{}`", ty

This comment has been minimized.

Copy link
@Centril

Centril Aug 13, 2019

Member

Are these new post-monomorphization errors... if so, why that?

This comment has been minimized.

Copy link
@gnzlbg

gnzlbg Aug 13, 2019

Author Contributor

Not really, typeck errors before any of these can trigger, at least, as long as everything is correct there.

I added these to help during development. If typeck fails to error, an error here is better than an error down the line. That's why these are ICEs instead of something nicer.

This comment has been minimized.

Copy link
@Centril

Centril Aug 13, 2019

Member

Alright; this sounds good. Could you add comments to the places where you added these .fatal errors noting that these should be caught in typeck?

(Also, why isn't bug!(...) being used for ICEs here?)

This comment has been minimized.

Copy link
@gnzlbg

gnzlbg Aug 13, 2019

Author Contributor

(Also, why isn't bug!(...) being used for ICEs here?)

No idea, the code was using fatal error for ICES already so I just also used that - the existing fatal error even has a test..

Could you add comments to the places where you added these .fatal errors noting that these should be caught in typeck?

Sure.

This comment has been minimized.

Copy link
@gnzlbg

gnzlbg Aug 13, 2019

Author Contributor

So i've done that.

The already existing error that fails if the element type isn't a machine type is currently not caught in typeck (this was already the case), and can fail if a generic SIMD vector is instantiated with an inappropriate element type. The way this is handled is that libcore should have a trait that bounds the accepted types so that this cannot happen (these features are all perma unstable).

There is a new monomorphization type error here now that we support generic lengths, and that's if the length passed to the vector is zero. We can only catch this once we know the actual value of the vector length, which right now is only at monomorphization time.

Either libcore would bound the length of the vector, once we have bounds for const generics, or we should start accepting zero-element vectors (I don't see a reason to forbid this), but that is probably better done in a different PR.

This comment has been minimized.

Copy link
@gnzlbg

gnzlbg Aug 14, 2019

Author Contributor

@Centril so is this issue resolved?

This comment has been minimized.

Copy link
@Centril

Centril Aug 14, 2019

Member

I leave that to @eddyb -- the only thing I would note is that we don't want to add new monomorphization errors in stable but such a consideration seems far off since this is just for experimentation.

This comment has been minimized.

Copy link
@gnzlbg

gnzlbg Aug 14, 2019

Author Contributor

There is a huge difference between monomorphization time errors that affect Rust users, and adding code to catch logic errors in rustc early.

I regularly get LLVM errors when using Rust. Their output is completely useless, and the first step into debugging those is requiring users to re-compile a Rust toolchain with LLVM assertions enabled, and debugging back to Rust from there.

I'd much rather have a monomorphization time error just saying "This generic intrinsics does not support that type", and wish others would as well.

This comment has been minimized.

Copy link
@eddyb

eddyb Aug 14, 2019

Member

I think I know what needs to be cleared up: the fatal was moved from one place to another, it's not new (AFAIK).

This comment has been minimized.

Copy link
@Centril

Centril Aug 14, 2019

Member

@gnzlbg I think you misunderstood me; I was making a general remark about user exposed monmorphization time errors, not internal ones for intrinsics... so we should be good.

@gnzlbg gnzlbg force-pushed the gnzlbg:array_simd branch 4 times, most recently from 9f77ec4 to c9d6e43 Aug 13, 2019

Support repr(simd) on ADTs containing a single array field
This PR allows using `#[repr(simd)]` on ADTs containing a
single array field:

```rust
 #[repr(simd)] struct S0([f32; 4]);
 #[repr(simd)] struct S1<const N: usize>([f32; N]);
 #[repr(simd)] struct S2<T, const N: usize>([T; N]);
```

This should allow experimenting with portable packed SIMD
abstractions on nightly that make use of const generics.

@gnzlbg gnzlbg force-pushed the gnzlbg:array_simd branch from c9d6e43 to 257158f Aug 13, 2019

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

commented Aug 13, 2019

The job x86_64-gnu-llvm-6.0 of your PR failed (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2019-08-13T19:52:12.1000544Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-08-13T19:52:12.1193740Z ##[command]git config gc.auto 0
2019-08-13T19:52:12.1269911Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-08-13T19:52:12.1335282Z ##[command]git config --get-all http.proxy
2019-08-13T19:52:12.1489312Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/63531/merge:refs/remotes/pull/63531/merge
---
2019-08-13T19:52:48.5197821Z do so (now or later) by using -b with the checkout command again. Example:
2019-08-13T19:52:48.5197874Z 
2019-08-13T19:52:48.5198116Z   git checkout -b <new-branch-name>
2019-08-13T19:52:48.5198147Z 
2019-08-13T19:52:48.5198211Z HEAD is now at 25db08dd5 Merge 3773bcf6ee32ff432c67583172342a14ba8e475b into 60960a260f7b5c695fd0717311d72ce62dd4eb43
2019-08-13T19:52:48.5366490Z ##[section]Starting: Collect CPU-usage statistics in the background
2019-08-13T19:52:48.5369262Z ==============================================================================
2019-08-13T19:52:48.5369351Z Task         : Bash
2019-08-13T19:52:48.5369396Z Description  : Run a Bash script on macOS, Linux, or Windows
---
2019-08-13T19:58:51.6829528Z    Compiling serde_json v1.0.40
2019-08-13T19:58:56.0753775Z    Compiling tidy v0.1.0 (/checkout/src/tools/tidy)
2019-08-13T19:59:04.9003319Z     Finished release [optimized] target(s) in 1m 31s
2019-08-13T19:59:04.9081120Z tidy check
2019-08-13T19:59:05.6884325Z tidy error: /checkout/src/test/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs:15: line longer than 100 chars
2019-08-13T19:59:05.6889811Z tidy error: /checkout/src/test/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs:16: line longer than 100 chars
2019-08-13T19:59:06.9049290Z some tidy checks failed
2019-08-13T19:59:06.9056334Z 
2019-08-13T19:59:06.9056334Z 
2019-08-13T19:59:06.9058102Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor"
2019-08-13T19:59:06.9058650Z 
2019-08-13T19:59:06.9058792Z 
2019-08-13T19:59:06.9062971Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
2019-08-13T19:59:06.9063253Z Build completed unsuccessfully in 0:01:34
2019-08-13T19:59:06.9063253Z Build completed unsuccessfully in 0:01:34
2019-08-13T19:59:08.1965877Z ##[error]Bash exited with code '1'.
2019-08-13T19:59:08.2009757Z ##[section]Starting: Checkout
2019-08-13T19:59:08.2011465Z ==============================================================================
2019-08-13T19:59:08.2011540Z Task         : Get sources
2019-08-13T19:59:08.2011586Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

commented Aug 14, 2019

The job x86_64-gnu-llvm-6.0 of your PR failed (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2019-08-14T05:14:52.2880722Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-08-14T05:14:52.3061265Z ##[command]git config gc.auto 0
2019-08-14T05:14:52.3131400Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-08-14T05:14:52.3189530Z ##[command]git config --get-all http.proxy
2019-08-14T05:14:52.3334863Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/63531/merge:refs/remotes/pull/63531/merge
---
2019-08-14T05:15:27.9477828Z do so (now or later) by using -b with the checkout command again. Example:
2019-08-14T05:15:27.9478042Z 
2019-08-14T05:15:27.9478470Z   git checkout -b <new-branch-name>
2019-08-14T05:15:27.9478660Z 
2019-08-14T05:15:27.9481265Z HEAD is now at 1aea4b90d Merge 58fe6835bdc1ddb80a3be81872c7f5759f4eda3c into 60960a260f7b5c695fd0717311d72ce62dd4eb43
2019-08-14T05:15:27.9635804Z ##[section]Starting: Collect CPU-usage statistics in the background
2019-08-14T05:15:27.9638244Z ==============================================================================
2019-08-14T05:15:27.9638296Z Task         : Bash
2019-08-14T05:15:27.9638338Z Description  : Run a Bash script on macOS, Linux, or Windows
---
2019-08-14T06:19:10.5615259Z .................................................................................................... 1300/8876
2019-08-14T06:19:17.3504606Z .................................................................................................... 1400/8876
2019-08-14T06:19:23.8537211Z .................................................................................................... 1500/8876
2019-08-14T06:19:34.9042314Z ....................................................................................i............... 1600/8876
2019-08-14T06:19:42.9846088Z i................................................................................................... 1700/8876
2019-08-14T06:19:49.9461170Z ...........................................................................iiiii.................... 1800/8876
2019-08-14T06:20:13.1756801Z .................................................................................................... 2000/8876
2019-08-14T06:20:15.7348147Z .................................................................................................... 2100/8876
2019-08-14T06:20:18.5233328Z .................................................................................................... 2200/8876
2019-08-14T06:20:26.6186441Z .................................................................................................... 2300/8876
---
2019-08-14T06:24:29.7170595Z .................................................................................................... 5300/8876
2019-08-14T06:24:37.3203614Z ........i........................................................................................... 5400/8876
2019-08-14T06:24:43.0720713Z .................................................................................................... 5500/8876
2019-08-14T06:24:55.8306374Z .................................................................................................... 5600/8876
2019-08-14T06:25:13.0171616Z ...ii...i..ii...........i........................................................................... 5700/8876
2019-08-14T06:25:40.6819407Z .................................................................................................... 5900/8876
2019-08-14T06:25:46.5627180Z .................................................................................................... 6000/8876
2019-08-14T06:25:46.5627180Z .................................................................................................... 6000/8876
2019-08-14T06:26:01.7426334Z ....i..ii........................................................................................... 6100/8876
2019-08-14T06:26:22.4832905Z ...............................................i.................................................... 6300/8876
2019-08-14T06:26:24.8323485Z .................................................................................................... 6400/8876
2019-08-14T06:26:27.5863667Z ...................i................................................................................ 6500/8876
2019-08-14T06:26:32.6156389Z .................................................................................................... 6600/8876
---
2019-08-14T06:31:27.6528510Z  finished in 23.339
2019-08-14T06:31:27.6723546Z Check compiletest suite=codegen mode=codegen (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-08-14T06:31:27.8386232Z 
2019-08-14T06:31:27.8387050Z running 148 tests
2019-08-14T06:31:31.2118748Z i....iii......iii..iiii....i............................i..i................i....i.........ii.i.i..i 100/148
2019-08-14T06:31:33.2199075Z iii..............i......F..F.iii.i......ii......
2019-08-14T06:31:33.2203807Z 
2019-08-14T06:31:33.2204284Z ---- [codegen] codegen/simd-intrinsic/simd-intrinsic-generic-extract-insert.rs stdout ----
2019-08-14T06:31:33.2204882Z 
2019-08-14T06:31:33.2205964Z error: compilation failed!
2019-08-14T06:31:33.2205964Z error: compilation failed!
2019-08-14T06:31:33.2206027Z status: exit code: 101
2019-08-14T06:31:33.2207242Z command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/codegen/simd-intrinsic/simd-intrinsic-generic-extract-insert.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen/simd-intrinsic/simd-intrinsic-generic-extract-insert" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-C" "no-prepopulate-passes" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen/simd-intrinsic/simd-intrinsic-generic-extract-insert/auxiliary" "--emit=llvm-ir"
2019-08-14T06:31:33.2207724Z ------------------------------------------
2019-08-14T06:31:33.2207782Z 
2019-08-14T06:31:33.2208038Z ------------------------------------------
2019-08-14T06:31:33.2208089Z stderr:
2019-08-14T06:31:33.2208089Z stderr:
2019-08-14T06:31:33.2208332Z ------------------------------------------
2019-08-14T06:31:33.2208678Z thread 'rustc' panicked at 'internal error: entered unreachable code', src/librustc/ty/layout.rs:749:25
2019-08-14T06:31:33.2208787Z 
2019-08-14T06:31:33.2208855Z error: internal compiler error: unexpected panic
2019-08-14T06:31:33.2208889Z 
2019-08-14T06:31:33.2208939Z note: the compiler unexpectedly panicked. this is a bug.
2019-08-14T06:31:33.2208939Z note: the compiler unexpectedly panicked. this is a bug.
2019-08-14T06:31:33.2208981Z 
2019-08-14T06:31:33.2209671Z note: we would appreciate a bug report: ***/blob/master/CONTRIBUTING.md#bug-reports
2019-08-14T06:31:33.2210020Z note: rustc 1.38.0-dev running on x86_64-unknown-linux-gnu
2019-08-14T06:31:33.2210078Z 
2019-08-14T06:31:33.2210078Z 
2019-08-14T06:31:33.2210410Z note: compiler flags: -Z threads=1 -Z unstable-options -C prefer-dynamic -C rpath -C debuginfo=0 -C no-prepopulate-passes
2019-08-14T06:31:33.2210482Z 
2019-08-14T06:31:33.2210751Z ------------------------------------------
2019-08-14T06:31:33.2210786Z 
2019-08-14T06:31:33.2210816Z 
2019-08-14T06:31:33.2210816Z 
2019-08-14T06:31:33.2211106Z ---- [codegen] codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs stdout ----
2019-08-14T06:31:33.2211162Z 
2019-08-14T06:31:33.2211207Z error: compilation failed!
2019-08-14T06:31:33.2211256Z status: exit code: 101
2019-08-14T06:31:33.2212954Z command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen/simd-intrinsic/simd-intrinsic-transmute-array" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-C" "no-prepopulate-passes" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen/simd-intrinsic/simd-intrinsic-transmute-array/auxiliary" "--emit=llvm-ir"
2019-08-14T06:31:33.2213444Z ------------------------------------------
2019-08-14T06:31:33.2213485Z 
2019-08-14T06:31:33.2213738Z ------------------------------------------
2019-08-14T06:31:33.2213787Z stderr:
2019-08-14T06:31:33.2213787Z stderr:
2019-08-14T06:31:33.2214051Z ------------------------------------------
2019-08-14T06:31:33.2214370Z thread 'rustc' panicked at 'internal error: entered unreachable code', src/librustc/ty/layout.rs:749:25
2019-08-14T06:31:33.2214614Z 
2019-08-14T06:31:33.2214664Z error: internal compiler error: unexpected panic
2019-08-14T06:31:33.2214697Z 
2019-08-14T06:31:33.2214746Z note: the compiler unexpectedly panicked. this is a bug.
2019-08-14T06:31:33.2214746Z note: the compiler unexpectedly panicked. this is a bug.
2019-08-14T06:31:33.2214796Z 
2019-08-14T06:31:33.2215207Z note: we would appreciate a bug report: ***/blob/master/CONTRIBUTING.md#bug-reports
2019-08-14T06:31:33.2215556Z note: rustc 1.38.0-dev running on x86_64-unknown-linux-gnu
2019-08-14T06:31:33.2215594Z 
2019-08-14T06:31:33.2215594Z 
2019-08-14T06:31:33.2215922Z note: compiler flags: -Z threads=1 -Z unstable-options -C prefer-dynamic -C rpath -C debuginfo=0 -C no-prepopulate-passes
2019-08-14T06:31:33.2216013Z 
2019-08-14T06:31:33.2216262Z ------------------------------------------
2019-08-14T06:31:33.2216297Z 
2019-08-14T06:31:33.2216326Z 
---
2019-08-14T06:31:33.2217448Z test result: FAILED. 115 passed; 2 failed; 31 ignored; 0 measured; 0 filtered out
2019-08-14T06:31:33.2217489Z 
2019-08-14T06:31:33.2217517Z 
2019-08-14T06:31:33.2217544Z 
2019-08-14T06:31:33.2219251Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/codegen" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "codegen" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-6.0/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "6.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
2019-08-14T06:31:33.2219528Z 
2019-08-14T06:31:33.2219577Z 
2019-08-14T06:31:33.2225226Z thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:536:22
2019-08-14T06:31:33.2225470Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
2019-08-14T06:31:33.2225470Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
2019-08-14T06:31:33.2229083Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2019-08-14T06:31:33.2229157Z Build completed unsuccessfully in 1:09:30
2019-08-14T06:31:36.1517538Z ##[error]Bash exited with code '1'.
2019-08-14T06:31:36.1560770Z ##[section]Starting: Checkout
2019-08-14T06:31:36.1563336Z ==============================================================================
2019-08-14T06:31:36.1563403Z Task         : Get sources
2019-08-14T06:31:36.1563454Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@eddyb

This comment has been minimized.

Copy link
Member

commented Aug 14, 2019

@@ -1039,6 +1039,29 @@ fn generic_simd_intrinsic(
llret_ty: &'ll Type,
span: Span
) -> Result<&'ll Value, ()> {
// Given a SIMD vector type `x` return the element type and the number of
// elements in the vector.
fn simd_type_size(bx: &Builder<'a, 'll, 'tcx>, x: Ty<'tcx>) -> (Ty<'tcx>, usize) {

This comment has been minimized.

Copy link
@eddyb

eddyb Aug 14, 2019

Member

x -> ty (or simd_ty)

fn simd_type_size(bx: &Builder<'a, 'll, 'tcx>, x: Ty<'tcx>) -> (Ty<'tcx>, usize) {
let ty = if let ty::Adt(def, substs) = x.sty {
assert!(def.repr.simd());
let field0_ty = def.non_enum_variant().fields[0].ty(bx.tcx(), substs);

This comment has been minimized.

Copy link
@eddyb

eddyb Aug 14, 2019

Member

You could also do this with layout.field(bx, 0).ty, which seems cleaner.

This comment has been minimized.

Copy link
@gnzlbg

gnzlbg Aug 14, 2019

Author Contributor

Where does layout come from ?

This comment has been minimized.

Copy link
@eddyb

eddyb Aug 14, 2019

Member

It's what you get from layout_of(x) below.

src/librustc_typeck/check/mod.rs Outdated Show resolved Hide resolved
@@ -1761,6 +1761,7 @@ pub fn check_simd(tcx: TyCtxt<'_>, sp: Span, def_id: DefId) {
match e.sty {
ty::Param(_) => { /* struct<T>(T, T, T, T) is ok */ }

This comment has been minimized.

Copy link
@eddyb

eddyb Aug 14, 2019

Member

Was this added later? It effectively invalidates the checks below...
Even more reason we should have a single #[lang = "simd"] instead of many #[repr(simd)].

This comment has been minimized.

Copy link
@gnzlbg

gnzlbg Aug 14, 2019

Author Contributor

I think this was added at some point last year to support generic vectors.

This comment has been minimized.

Copy link
@gnzlbg

gnzlbg Aug 14, 2019

Author Contributor

For the time being at least we probably want to type check SIMD vectors early, e.g., #[repr(simd)] struct Foo(Vec<i32>, Vec<i32>); and #[repr(simd)] struct Bar<const N: usize>([Vec<i32>; N]); should fail to type check.

If we move to a single:

#[lang = "simd"]
struct Simd<T, const N: usize>([T; N]) where [T; N]: SomeTrait;

in the future then we might just accept anything and leave rejecting invalid inputs to SomeTrait.

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

commented Aug 14, 2019

The job x86_64-gnu-llvm-6.0 of your PR failed (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2019-08-14T15:45:17.9245251Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-08-14T15:45:17.9433573Z ##[command]git config gc.auto 0
2019-08-14T15:45:17.9517977Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-08-14T15:45:17.9572922Z ##[command]git config --get-all http.proxy
2019-08-14T15:45:17.9714037Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/63531/merge:refs/remotes/pull/63531/merge
---
2019-08-14T15:45:53.2665637Z do so (now or later) by using -b with the checkout command again. Example:
2019-08-14T15:45:53.2666024Z 
2019-08-14T15:45:53.2666351Z   git checkout -b <new-branch-name>
2019-08-14T15:45:53.2666383Z 
2019-08-14T15:45:53.2666433Z HEAD is now at d3e305fa8 Merge fbe64f42f5617ab00e4d38285bd81d62c7fc5af0 into c43d03a19f326f4a323569328cc501e86eb6d22e
2019-08-14T15:45:53.2847109Z ##[section]Starting: Collect CPU-usage statistics in the background
2019-08-14T15:45:53.2850505Z ==============================================================================
2019-08-14T15:45:53.2850565Z Task         : Bash
2019-08-14T15:45:53.2850627Z Description  : Run a Bash script on macOS, Linux, or Windows
---
2019-08-14T15:51:49.8453673Z    Compiling serde_json v1.0.40
2019-08-14T15:51:54.1201617Z    Compiling tidy v0.1.0 (/checkout/src/tools/tidy)
2019-08-14T15:52:02.7147136Z     Finished release [optimized] target(s) in 1m 28s
2019-08-14T15:52:02.7225025Z tidy check
2019-08-14T15:52:03.5105371Z tidy error: /checkout/src/librustc/ty/layout.rs:775: line longer than 100 chars
2019-08-14T15:52:04.6673822Z some tidy checks failed
2019-08-14T15:52:04.6674129Z 
2019-08-14T15:52:04.6674129Z 
2019-08-14T15:52:04.6681022Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor"
2019-08-14T15:52:04.6681709Z 
2019-08-14T15:52:04.6681742Z 
2019-08-14T15:52:04.6691166Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
2019-08-14T15:52:04.6691243Z Build completed unsuccessfully in 0:01:31
2019-08-14T15:52:04.6691243Z Build completed unsuccessfully in 0:01:31
2019-08-14T15:52:04.6746462Z == clock drift check ==
2019-08-14T15:52:04.6755815Z   local time: Wed Aug 14 15:52:04 UTC 2019
2019-08-14T15:52:04.7024085Z   network time: Wed, 14 Aug 2019 15:52:04 GMT
2019-08-14T15:52:04.7032104Z == end clock drift check ==
2019-08-14T15:52:05.9853004Z ##[error]Bash exited with code '1'.
2019-08-14T15:52:05.9883207Z ##[section]Starting: Checkout
2019-08-14T15:52:05.9884793Z ==============================================================================
2019-08-14T15:52:05.9884842Z Task         : Get sources
2019-08-14T15:52:05.9884898Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

commented Aug 15, 2019

The job x86_64-gnu-llvm-6.0 of your PR failed (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2019-08-15T14:19:50.0103953Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-08-15T14:19:50.0265188Z ##[command]git config gc.auto 0
2019-08-15T14:19:50.0333830Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-08-15T14:19:50.0396468Z ##[command]git config --get-all http.proxy
2019-08-15T14:19:50.0522615Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/63531/merge:refs/remotes/pull/63531/merge
---
2019-08-15T14:20:25.0184542Z do so (now or later) by using -b with the checkout command again. Example:
2019-08-15T14:20:25.0184570Z 
2019-08-15T14:20:25.0184740Z   git checkout -b <new-branch-name>
2019-08-15T14:20:25.0184782Z 
2019-08-15T14:20:25.0202305Z HEAD is now at d297e83fb Merge 173aafa8279a41f9b0f6f374b4705e5f446aeecd into 1cdcea920e56a5d0587307a4c9cf8fff5c77c4bc
2019-08-15T14:20:25.0357657Z ##[section]Starting: Collect CPU-usage statistics in the background
2019-08-15T14:20:25.0360544Z ==============================================================================
2019-08-15T14:20:25.0360596Z Task         : Bash
2019-08-15T14:20:25.0360636Z Description  : Run a Bash script on macOS, Linux, or Windows
---
2019-08-15T15:20:08.0541905Z .................................................................................................... 1400/8921
2019-08-15T15:20:14.1510380Z .................................................................................................... 1500/8921
2019-08-15T15:20:23.0230997Z .............................................................................................i...... 1600/8921
2019-08-15T15:20:30.7939615Z .........i.......................................................................................... 1700/8921
2019-08-15T15:20:37.4158931Z ....................................................................................iiiii........... 1800/8921
2019-08-15T15:20:57.9613673Z .................................................................................................... 2000/8921
2019-08-15T15:21:00.1771144Z .................................................................................................... 2100/8921
2019-08-15T15:21:02.5213861Z .................................................................................................... 2200/8921
2019-08-15T15:21:09.2733048Z .................................................................................................... 2300/8921
---
2019-08-15T15:23:57.2637471Z ..........................................................................................i......... 4600/8921
2019-08-15T15:24:04.6259339Z ......i............................................................................................. 4700/8921
2019-08-15T15:24:14.4217164Z .................................................................................................... 4800/8921
2019-08-15T15:24:20.3302078Z .................................................................................................... 4900/8921
2019-08-15T15:24:30.6519938Z ......................................................................ii.ii......................... 5000/8921
2019-08-15T15:24:39.6055097Z .................................................................................................... 5200/8921
2019-08-15T15:24:48.5841838Z .................................................................................................... 5300/8921
2019-08-15T15:24:55.8039775Z ...........................i........................................................................ 5400/8921
2019-08-15T15:25:01.1935381Z .................................................................................................... 5500/8921
2019-08-15T15:25:01.1935381Z .................................................................................................... 5500/8921
2019-08-15T15:25:12.5476638Z .................................................................................................... 5600/8921
2019-08-15T15:25:24.8538560Z ......................ii...i..ii...........i........................................................ 5700/8921
2019-08-15T15:25:41.0011216Z .................................................................................................... 5900/8921
2019-08-15T15:25:45.0322306Z .................................................................................................... 6000/8921
2019-08-15T15:25:45.0322306Z .................................................................................................... 6000/8921
2019-08-15T15:25:58.3241895Z .......................i..ii........................................................................ 6100/8921
2019-08-15T15:26:16.6933310Z ..................................................................i................................. 6300/8921
2019-08-15T15:26:18.5482997Z .................................................................................................... 6400/8921
2019-08-15T15:26:20.7414911Z ......................................i............................................................. 6500/8921
2019-08-15T15:26:24.3162206Z .................................................................................................... 6600/8921
---
2019-08-15T15:27:15.3673392Z .................................................................................................... 7100/8921
2019-08-15T15:27:20.5419466Z .................................................................................................... 7200/8921
2019-08-15T15:27:28.5799547Z .................................................................................................... 7300/8921
2019-08-15T15:27:39.1247548Z .................................................................................................... 7400/8921
2019-08-15T15:27:48.9484694Z .........................................................................................ii......i.. 7500/8921
2019-08-15T15:28:01.7300073Z .................................................................................................... 7700/8921
2019-08-15T15:28:18.5489095Z .................................................................................................... 7800/8921
2019-08-15T15:28:26.2228140Z .................................................................................................... 7900/8921
2019-08-15T15:28:37.3535619Z .................................................................................................... 8000/8921
---
2019-08-15T15:30:56.5248178Z  finished in 20.028
2019-08-15T15:30:56.5424596Z Check compiletest suite=codegen mode=codegen (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-08-15T15:30:56.7138409Z 
2019-08-15T15:30:56.7138884Z running 150 tests
2019-08-15T15:31:00.0434034Z i....iii......iii..iiii....i............................i..i..................i....i.........ii.i.i. 100/150
2019-08-15T15:31:01.9726746Z .iiii..............i..........Fiii.i......ii......
2019-08-15T15:31:01.9727188Z 
2019-08-15T15:31:01.9727597Z ---- [codegen] codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs stdout ----
2019-08-15T15:31:01.9727799Z 
2019-08-15T15:31:01.9727799Z 
2019-08-15T15:31:01.9728052Z error: verification with 'FileCheck' failed
2019-08-15T15:31:01.9728116Z status: exit code: 1
2019-08-15T15:31:01.9728509Z command: "/usr/lib/llvm-6.0/bin/FileCheck" "--input-file" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen/simd-intrinsic/simd-intrinsic-transmute-array/simd-intrinsic-transmute-array.ll" "/checkout/src/test/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs"
2019-08-15T15:31:01.9728773Z ------------------------------------------
2019-08-15T15:31:01.9728800Z 
2019-08-15T15:31:01.9728975Z ------------------------------------------
2019-08-15T15:31:01.9729029Z stderr:
2019-08-15T15:31:01.9729029Z stderr:
2019-08-15T15:31:01.9729206Z ------------------------------------------
2019-08-15T15:31:01.9729461Z /checkout/src/test/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs:24:12: error: expected string not found in input
2019-08-15T15:31:01.9729909Z  // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %{{[0-9]+}}, i8* align 4 %3, i64 16, i1 false)
2019-08-15T15:31:01.9730125Z            ^
2019-08-15T15:31:01.9731111Z /checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen/simd-intrinsic/simd-intrinsic-transmute-array/simd-intrinsic-transmute-array.ll:7:27: note: scanning from here
2019-08-15T15:31:01.9731212Z define void @build_array_s(<4 x float>* noalias nocapture sret dereferenceable(16), [4 x float]* noalias nocapture dereferenceable(16) %x) unnamed_addr #0 {
2019-08-15T15:31:01.9731267Z                           ^
2019-08-15T15:31:01.9731634Z /checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen/simd-intrinsic/simd-intrinsic-transmute-array/simd-intrinsic-transmute-array.ll:14:2: note: possible intended match here
2019-08-15T15:31:01.9731717Z  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %2, i8* %3, i64 16, i32 4, i1 false)
2019-08-15T15:31:01.9732066Z /checkout/src/test/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs:32:12: error: expected string not found in input
2019-08-15T15:31:01.9732066Z /checkout/src/test/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs:32:12: error: expected string not found in input
2019-08-15T15:31:01.9732389Z  // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %{{[0-9]+}}, i8* align 4 %3, i64 16, i1 false)
2019-08-15T15:31:01.9732443Z            ^
2019-08-15T15:31:01.9732787Z /checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen/simd-intrinsic/simd-intrinsic-transmute-array/simd-intrinsic-transmute-array.ll:25:27: note: scanning from here
2019-08-15T15:31:01.9732879Z define void @build_array_t(<4 x float>* noalias nocapture sret dereferenceable(16), [4 x float]* noalias nocapture dereferenceable(16) %x) unnamed_addr #0 {
2019-08-15T15:31:01.9732933Z                           ^
2019-08-15T15:31:01.9733285Z /checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen/simd-intrinsic/simd-intrinsic-transmute-array/simd-intrinsic-transmute-array.ll:32:2: note: possible intended match here
2019-08-15T15:31:01.9733369Z  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %2, i8* %3, i64 16, i32 4, i1 false)
2019-08-15T15:31:01.9733720Z /checkout/src/test/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs:40:12: error: expected string not found in input
2019-08-15T15:31:01.9733720Z /checkout/src/test/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs:40:12: error: expected string not found in input
2019-08-15T15:31:01.9734165Z  // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %{{[0-9]+}}, i8* align 4 %3, i64 16, i1 false)
2019-08-15T15:31:01.9734306Z            ^
2019-08-15T15:31:01.9734629Z /checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen/simd-intrinsic/simd-intrinsic-transmute-array/simd-intrinsic-transmute-array.ll:43:27: note: scanning from here
2019-08-15T15:31:01.9734709Z define void @build_array_u(<4 x float>* noalias nocapture sret dereferenceable(16), [4 x float]* noalias nocapture dereferenceable(16) %x) unnamed_addr #0 {
2019-08-15T15:31:01.9734754Z                           ^
2019-08-15T15:31:01.9735112Z /checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen/simd-intrinsic/simd-intrinsic-transmute-array/simd-intrinsic-transmute-array.ll:50:2: note: possible intended match here
2019-08-15T15:31:01.9735177Z  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %2, i8* %3, i64 16, i32 4, i1 false)
2019-08-15T15:31:01.9735239Z 
2019-08-15T15:31:01.9735442Z ------------------------------------------
2019-08-15T15:31:01.9735473Z 
2019-08-15T15:31:01.9735495Z 
---
2019-08-15T15:31:01.9738912Z thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:536:22
2019-08-15T15:31:01.9739035Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
2019-08-15T15:31:01.9739073Z 
2019-08-15T15:31:01.9739128Z 
2019-08-15T15:31:01.9740939Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/codegen" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "codegen" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-6.0/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "6.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
2019-08-15T15:31:01.9741378Z 
2019-08-15T15:31:01.9741415Z 
2019-08-15T15:31:01.9748692Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2019-08-15T15:31:01.9748969Z Build completed unsuccessfully in 1:04:35
2019-08-15T15:31:01.9748969Z Build completed unsuccessfully in 1:04:35
2019-08-15T15:31:01.9802791Z == clock drift check ==
2019-08-15T15:31:01.9817008Z   local time: Thu Aug 15 15:31:01 UTC 2019
2019-08-15T15:31:02.0751462Z   network time: Thu, 15 Aug 2019 15:31:02 GMT
2019-08-15T15:31:02.0753715Z == end clock drift check ==
2019-08-15T15:31:05.2200320Z ##[error]Bash exited with code '1'.
2019-08-15T15:31:05.2245065Z ##[section]Starting: Checkout
2019-08-15T15:31:05.2246540Z ==============================================================================
2019-08-15T15:31:05.2246598Z Task         : Get sources
2019-08-15T15:31:05.2246653Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@gnzlbg

This comment has been minimized.

Copy link
Contributor Author

commented Aug 15, 2019

So apparently align 4 is not generated on Linux but is generated on osx, I need to skip that. The important part of the test is to verify that the memcpy actually copies the whole vector.

let e_abi = if let Abi::Scalar(ref scalar) = e_ly.abi {
scalar.clone()
} else {
// This error isn;t caught in typeck, e.g., if

This comment has been minimized.

Copy link
@Dante-Broggi

Dante-Broggi Aug 18, 2019

Contributor

Typo: “isn;t” => “isn’t”

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.