about summary refs log tree commit diff
path: root/src/test/codegen
AgeCommit message (Collapse)AuthorLines
2018-02-08Fix oversized loads on x86_64 SysV FFI callsBjörn Steinbrink-51/+87
The x86_64 SysV ABI should use exact sizes for small structs passed in registers, i.e. a struct that occupies 3 bytes should use an i24, instead of the i32 it currently uses. Refs #45543
2018-02-07Rollup merge of #47944 - oberien:unboundediterator-trustedlen, r=blussManish Goregaokar-0/+23
Implement TrustedLen for Take<Repeat> and Take<RangeFrom> This will allow optimization of simple `repeat(x).take(n).collect()` iterators, which are currently not vectorized and have capacity checks. This will only support a few aggregates on `Repeat` and `RangeFrom`, which might be enough for simple cases, but doesn't optimize more complex ones. Namely, Cycle, StepBy, Filter, FilterMap, Peekable, SkipWhile, Skip, FlatMap, Fuse and Inspect are not marked `TrustedLen` when the inner iterator is infinite. Previous discussion can be found in #47082 r? @alexcrichton
2018-02-06Rollup merge of #46030 - Zoxc:asm-volatile, r=nikomatsakiskennytm-0/+26
Make inline assembly volatile if it has no outputs. Fixes #46026
2018-02-05Make inline assembly volatile if it has no outputs. Fixes #46026John Kåre Alsaker-0/+26
2018-02-04Rollup merge of #47912 - cuviper:glibc-stack-guard, r=alexcrichtonkennytm-1/+1
Use a range to identify SIGSEGV in stack guards Previously, the `guard::init()` and `guard::current()` functions were returning a `usize` address representing the top of the stack guard, respectively for the main thread and for spawned threads. The `SIGSEGV` handler on `unix` targets checked if a fault was within one page below that address, if so reporting it as a stack overflow. Now `unix` targets report a `Range<usize>` representing the guard memory, so it can cover arbitrary guard sizes. Non-`unix` targets which always return `None` for guards now do so with `Option<!>`, so they don't pay any overhead. For `linux-gnu` in particular, the previous guard upper-bound was `stackaddr + guardsize`, as the protected memory was *inside* the stack. This was a glibc bug, and starting from 2.27 they are moving the guard *past* the end of the stack. However, there's no simple way for us to know where the guard page actually lies, so now we declare it as the whole range of `stackaddr ± guardsize`, and any fault therein will be called a stack overflow. This fixes #47863.
2018-02-04TrustedLen for Repeat / RangeFrom test casesoberien-0/+23
2018-01-31Enable stack-probe tests with system LLVM >= 5.0Josh Stone-1/+1
2018-01-31rustc_trans: keep LLVM types for trait objects anonymous.Eduard-Mihai Burtescu-2/+2
2018-01-26Merge branch 'simd-always-mem' of https://github.com/alexcrichton/rust into ↵Alex Crichton-3/+1
rollup
2018-01-25Rollup merge of #47618 - mrhota:dw_at_noreturn, r=michaelwoeristerAlex Crichton-0/+24
Teach rustc about DW_AT_noreturn and a few more DIFlags We achieve two small things with this PR: 1. We provide definitions for a few additional llvm debuginfo flags 1. We _use_ one of these new flags, `FlagNoReturn`, and add it to debuginfo for functions with the never return type (`!`).
2018-01-25rustc: SIMD types use pointers in Rust's ABIAlex Crichton-3/+1
This commit changes the ABI of SIMD types in the "Rust" ABI to unconditionally be passed via pointers instead of being passed as immediates. This should fix a longstanding issue, #44367, where SIMD-using programs ended up showing very odd behavior at runtime because the ABI between functions was mismatched. As a bit of a recap, this is sort of an LLVM bug and sort of an LLVM feature (today's behavior). LLVM will generate code for a function solely looking at the function it's generating, including calls to other functions. Let's then say you've got something that looks like: ```llvm define void @foo() { ; no target features enabled call void @bar(<i64 x 4> zeroinitializer) ret void } define void @bar(<i64 x 4>) #0 { ; enables the AVX feature ... } ``` LLVM will codegen the call to `bar` *without* using AVX registers becauase `foo` doesn't have access to these registers. Instead it's generated with emulation that uses two 128-bit registers. The `bar` function, on the other hand, will expect its argument in an AVX register (as it has AVX enabled). This means we've got a codegen problem! Comments on #44367 have some more contexutal information but the crux of the issue is that if we want SIMD to work in general we'll need to ensure that whenever a function calls another they ABI of the arguments being passed is in agreement. One possible solution to this would be to insert "shim functions" where whenever a `target_feature` mismatch is detected the compiler inserts a shim function where you pass arguments via memory to the shim and then the shim loads the values and calls the target function (where the shim and the target have the same target features enabled). This unfortunately is quite nontrivial to implement in rustc today (especially when accounting for function pointers and such). This commit takes a different solution, *always* passing SIMD arguments through memory instead of passing as immediates. This strategy solves the problem at the LLVM layer because the ABI between two functions never uses SIMD registers. This also shouldn't be a hit to performance because SIMD performance is thought to often rely on inlining anyway, where a `call` instruction, even if using SIMD registers, would be disastrous to performance regardless. LLVM should then be more than capable of fixing all our memory usage to use registers instead after enough inlining has been performed. Note that there's a few caveats to this commit though: * The "platform intrinsic" ABI is omitted from "always pass via memory". This ABI is used to define intrinsics like `simd_shuffle4` where LLVM and rustc need to have the arguments as an immediate. * Additionally this commit does *not* fix the `extern` ("C") ABI. This means that the bug in #44367 can still happen when using non-Rust-ABI functions. My hope is that before stabilization we can ban and/or warn about SIMD types in these functions (as AFAIK there's not much motivation to belong there anyway), but I'll leave that for a later commit and if this is merged I'll file a follow-up issue. All in all this... Closes #44367
2018-01-23Stabilized `#[repr(align(x))]` attribute (RFC 1358)Cameron Hart-3/+0
2018-01-22Auto merge of #47158 - rkruppe:repr-transparent, r=eddybbors-0/+284
Implement repr(transparent) r? @eddyb for the functional changes. The bulk of the PR is error messages and docs, might be good to have a doc person look over those. cc #43036 cc @nox
2018-01-21Ensure test doesn't run with llvm 3.9A.J. Gardner-3/+1
2018-01-20Simplify and fix testA.J. Gardner-5/+2
2018-01-20Teach rustc about DW_AT_noreturn and a few more DIFlagsA.J. Gardner-0/+29
2018-01-19Auto merge of #47401 - rkruppe:issue-47278, r=eddybbors-0/+19
Compute LLVM argument indices correctly in face of padding Closes #47278 r? @eddyb
2018-01-16Compute LLVM argument indices correctly in face of paddingRobin Kruppe-0/+19
Closes #47278
2018-01-16Implement repr(transparent)Robin Kruppe-0/+284
2018-01-16remove noop landing pads in cleanup shimsAriel Ben-Yehuda-0/+32
These are already removed in the normal optimization pipeline - so this should slightly improve codegen performance, as these cleanup blocks are known to hurt LLVM. This un-regresses and is therefore a fix for #47442. However, the reporter of that issue should try using `-C panic=abort` instead of carefully avoiding panics.
2018-01-05Auto merge of #46739 - arielb1:simple-loops, r=nikomatsakisbors-0/+25
[needs perf run] Try to improve LLVM pass ordering Fixes #45466
2018-01-04Auto merge of #46916 - michaelwoerister:generate-dead-code-plz, r=alexcrichtonbors-0/+27
Generate code for unused const- and inline-fns if -Clink-dead-code is specified. Fixes https://github.com/rust-lang/rust/issues/46467. r? @alexcrichton
2018-01-04Generate code for const- and inline-fns if -Clink-dead-code is specified.Michael Woerister-0/+27
2018-01-02Add 'ignore-cloudabi' to tests that don't and won't build on CloudABI.Ed Schouten-5/+7
It looks like many of these tests are already disabled on emscripten, which also doesn't seem to support environment variables and subprocess spawning. Just add a similar tag for CloudABI. While there, sort some of the lists of operating systems alphabetically.
2017-12-30Remove excessive trailing newlines.kennytm-2/+0
2017-12-26rustc: don't use union layouts for tagged union enums.Eduard-Mihai Burtescu-2/+3
2017-12-15rustc_trans: approximate ABI alignment for padding/union fillers.Eduard-Mihai Burtescu-0/+20
2017-12-14Simplify CFG after IndVarSimplifyAriel Ben-Yehuda-0/+25
Fixes #45466
2017-12-14Use PathBuf instead of String where applicableOliver Schneider-1/+1
2017-12-06Stabilize abi_sysv64CensoredUsername-1/+0
2017-12-02rustc: don't unpack newtypes of scalar-pairs with mismatched alignment.Eduard-Mihai Burtescu-0/+11
2017-11-25rustc: Add support for some more x86 SIMD opsAlex Crichton-0/+53
This commit adds compiler support for two basic operations needed for binding SIMD on x86 platforms: * First, a `nontemporal_store` intrinsic was added for the `_mm_stream_ps`, seen in rust-lang-nursery/stdsimd#114. This was relatively straightforward and is quite similar to the volatile store intrinsic. * Next, and much more intrusively, a new type to the backend was added. The `x86_mmx` type is used in LLVM for a 64-bit vector register and is used in various intrinsics like `_mm_abs_pi8` as seen in rust-lang-nursery/stdsimd#74. This new type was added as a new layout option as well as having support added to the trans backend. The type is enabled with the `#[repr(x86_mmx)]` attribute which is intended to just be an implementation detail of SIMD in Rust. I'm not 100% certain about how the `x86_mmx` type was added, so any extra eyes or thoughts on that would be greatly appreciated!
2017-11-19rustc_trans: work around i686-pc-windows-msvc byval align LLVM bug.Eduard-Mihai Burtescu-3/+3
2017-11-19Don't glob-import overlapping variant names in ↵Eduard-Mihai Burtescu-11/+9
test/codegen/match-optimizes-away.rs.
2017-11-19rustc: unpack scalar pair newtype layout ABIs.Eduard-Mihai Burtescu-1/+1
2017-11-19rustc: unpack scalar newtype layout ABIs.Eduard-Mihai Burtescu-5/+5
2017-11-19rustc: encode scalar pairs in layout ABI.Eduard-Mihai Burtescu-10/+7
2017-11-19rustc_trans: compute better align/dereferenceable attributes from pointees.Eduard-Mihai Burtescu-6/+6
2017-11-19rustc_trans: go through layouts uniformly for fat pointers and variants.Eduard-Mihai Burtescu-14/+13
2017-11-19rustc: do not inject discriminant fields into Layout::General's variants.Eduard-Mihai Burtescu-2/+2
2017-11-19rustc_trans: always insert alignment padding, even before the first field.Eduard-Mihai Burtescu-8/+11
2017-11-19rustc_trans: use *[T; 0] for slice data pointers instead of *T.Eduard-Mihai Burtescu-7/+8
2017-11-19rustc_trans: use more of the trans::mir and ty::layout APIs throughout.Eduard-Mihai Burtescu-6/+6
2017-11-19rustc_trans: use a predictable layout for constant ADTs.Eduard-Mihai Burtescu-4/+4
2017-11-15Emit debug info for trait object pointerTom Tromey-0/+33
Emit better debugging information for a trait object pointer. In particular, now: * The fields are explicitly represented in the DWARF; * DWARF for the vtable itself is emitted; and * The DWARF for the vtable's type has a DW_AT_containing_type which points to the concrete type for which the vtable was emitted. This is a small DWARF extension, that allows debuggers to determine the real type of the object to which a trait object points. I'll submit the gdb patch to take advantage of this new debuginfo once this lands. The vtable type is not currently complete -- it doesn't include members for the pointers it contains. This information was not needed for this feature. This addresses part 1 of #1563.
2017-11-14add optimization codegen testsDjzin-0/+44
2017-11-14always add an unreachable branch on matches to give more info to llvm about ↵Djzin-3/+6
which values are possible
2017-11-10Make saturating u128 -> f32 casts the default behaviorRobin Kruppe-21/+2
... rather than being gated by -Z saturating-float-casts. There are several reasons for this: 1. Const eval already implements this behavior. 2. Unlike with float->int casts, this behavior is uncontroversially the right behavior and it is not as performance critical. Thus there is no particular need to make the bug fix for u128->f32 casts opt-in. 3. Having two orthogonal features under one flag is silly, and never should have happened in the first place. 4. Benchmarking float->int casts with the -Z flag should not pick up performance changes due to the u128->f32 casts (assuming there are any). Fixes #41799
2017-11-08Auto merge of #45205 - rkruppe:saturating-casts, r=eddybbors-0/+65
Saturating casts between integers and floats Introduces a new flag, `-Z saturating-float-casts`, which makes code generation for int->float and float->int casts safe (`undef`-free), implementing [the saturating semantics laid out by](https://github.com/rust-lang/rust/issues/10184#issuecomment-299229143) @jorendorff for float->int casts and overflowing to infinity for `u128::MAX` -> `f32`. Constant evaluation in trans was changed to behave like HIR const eval already did, i.e., saturate for u128->f32 and report an error for problematic float->int casts. Many thanks to @eddyb, whose APFloat port simplified many parts of this patch, and made HIR constant evaluation recognize dangerous float casts as mentioned above. Also thanks to @ActuallyaDeviloper whose branchless implementation served as inspiration for this implementation. cc #10184 #41799 fixes #45134
2017-11-08Update fastcall-inreg codegen test so that functions actually get instantiated.Michael Woerister-7/+7