about summary refs log tree commit diff
path: root/src/test/codegen
AgeCommit message (Collapse)AuthorLines
2017-01-04Replace BlockAndBuilder with Builder.Mark Simulacrum-2/+2
2016-12-22Cleaned up the code and added tests.Ivan Molodetskikh-0/+85
2016-12-03Ignore test on -windows-gnu.Vadim Chugunov-1/+2
2016-12-01Emit 'dllimport' attribute for dylib foreign items on Windows.Vadim Chugunov-0/+103
2016-11-13Fix codegen test after change of llvm type naming schemeMichael Woerister-4/+4
2016-10-25Auto merge of #36421 - TimNN:check-abis, r=alexcrichtonbors-0/+6
check target abi support This PR checks for each extern function / block whether the ABI / calling convention used is supported by the current target. This was achieved by adding an `abi_blacklist` field to the target specifications, listing the calling conventions unsupported for that target.
2016-10-25adapt testsTim Neumann-0/+6
2016-10-21Adapt codegen test to new naming scheme for generated symbols.Michael Woerister-3/+3
2016-10-17Expand .zip() specialization to .map() and .cloned()Ulrik Sverdrup-0/+9
Implement .zip() specialization for Map and Cloned. The crucial thing for transparent specialization is that we want to preserve the potential side effects. The simplest example is that in this code snippet: `(0..6).map(f).zip((0..4).map(g)).count()` `f` will be called five times, and `g` four times. The last time for `f` is when the other iterator is at its end, so this element is unused. This side effect can be preserved without disturbing code generation for simple uses of `.map()`. The `Zip::next_back()` case is even more complicated, unfortunately.
2016-10-05emit an assume that cast-from enums are in rangeAriel Ben-Yehuda-0/+24
Fixes #36955.
2016-09-29Change the `local` prefix to `_`Jonas Schievink-4/+4
There's no need for a long prefix, since there's nothing to distinguish anymore.
2016-09-27Fix codegen test (value names changed)Jonas Schievink-4/+4
2016-09-25Auto merge of #36151 - camlorn:struct_layout_optimization, r=eddybbors-2/+2
refactor to remove trans::adt and make rustc::ty::layout authoritative I asked on IRC about optimizing struct layout by reordering fields from most-aligned to least-aligned and somehow ended up getting talked into doing this. The goal here is to make `layout` authoritative and to remove `adt`. The former has been accomplished by reimplementing `represent_type_uncached` and the latter is in progress. @eddyb thought I should make the PR now. My plan is to reserve the actual optimization for a second PR, as this work is useful by itself.
2016-09-24Update codegen/link_section.rs.Austin Hicks-2/+2
2016-09-24librustc_mir: Propagate constants during copy propagation.Patrick Walton-2/+2
This optimization kicks in a lot when bootstrapping the compiler.
2016-09-19librustc: Implement def-use chains and trivial copy propagation on MIR.Patrick Walton-2/+2
This only supports trivial cases in which there is exactly one def and one use.
2016-09-13Auto merge of #36181 - seanmonstar:likely, r=nikomatsakisbors-0/+41
core: add likely and unlikely intrinsics I'm no good at reading assembly, but I have tried a stage1 compiler with this patch, and it does cause different asm output. Additionally, testing this compiler on my httparse crate with some `likely` usage added in to the branches does affect benchmarks. However, I'm sure a codegen test should be included, if anyone knows what it should look like. There isn't an entry in `librustc_trans/context.rs` in this diff, because it already exists (`llvm.expect.i1` is used for array indices). ---- Even though this does affect httparse benchmarks, it doesn't seem to affect it the same way GCC's `__builtin_expect` affects picohttpparser. I was confused that the deviation on the benchmarks grew hugely when testing this, especially since I'm absolutely certain that the branchs where I added `likely` were always `true`. I chalk that up to GCC and LLVM handle branch prediction differently. cc #26179
2016-09-02core: add likely and unlikely intrinsicsSean McArthur-0/+41
2016-08-30Feature gate the sysv64 abi as feature(abi_sysv64) and add testsCensoredUsername-0/+24
2016-08-24Disable old trans access via -Z orbit, #[rustc_no_mir] or --disable-orbit.Eduard Burtescu-45/+30
2016-08-14[MIR] Add Storage{Live,Dead} statements to emit llvm.lifetime.{start,end}.Eduard Burtescu-0/+54
2016-07-19Add codegen test to make sure that closures are 'internalized' properly.Michael Woerister-0/+20
2016-07-08Fix codegen tests by make sure items are translated in AST order.Michael Woerister-7/+7
2016-06-20trans: generalize immediate temporaries to all MIR locals.Eduard Burtescu-1/+6
2016-06-14specialize zip: Add codegen testUlrik Sverdrup-0/+22
2016-06-13Auto merge of #34252 - dsprenkels:issue-32364-test, r=eddybbors-0/+24
Add regression test for #32364 This PR adds a regression test for #32364. r? @eddyb
2016-06-13Add regression test for #32364Daan Sprenkels-0/+24
2016-06-12Auto merge of #34241 - dsprenkels:issue-32031-test, r=eddybbors-0/+33
add a test case for issue #32031 I propose a test case to finish the fix for issue #32031. Please review this commit thoroughly, as I have never written a codegen test before. r? @eddyb
2016-06-12add a test case for issue #32031Daan Sprenkels-0/+33
2016-06-08trans: always use a memcpy for ABI argument/return casts.Eduard Burtescu-4/+12
2016-05-26Fix stores codegen passSimonas Kazlauskas-4/+4
2016-05-09rustc: Implement custom panic runtimesAlex Crichton-0/+31
This commit is an implementation of [RFC 1513] which allows applications to alter the behavior of panics at compile time. A new compiler flag, `-C panic`, is added and accepts the values `unwind` or `panic`, with the default being `unwind`. This model affects how code is generated for the local crate, skipping generation of landing pads with `-C panic=abort`. [RFC 1513]: https://github.com/rust-lang/rfcs/blob/master/text/1513-less-unwinding.md Panic implementations are then provided by crates tagged with `#![panic_runtime]` and lazily required by crates with `#![needs_panic_runtime]`. The panic strategy (`-C panic` value) of the panic runtime must match the final product, and if the panic strategy is not `abort` then the entire DAG must have the same panic strategy. With the `-C panic=abort` strategy, users can expect a stable method to disable generation of landing pads, improving optimization in niche scenarios, decreasing compile time, and decreasing output binary size. With the `-C panic=unwind` strategy users can expect the existing ability to isolate failure in Rust code from the outside world. Organizationally, this commit dismantles the `sys_common::unwind` module in favor of some bits moving part of it to `libpanic_unwind` and the rest into the `panicking` module in libstd. The custom panic runtime support is pretty similar to the custom allocator support with the only major difference being how the panic runtime is injected (takes the `-C panic` flag into account).
2016-03-22Add testsTicki-0/+69
2016-03-18Add intrinsics for float arithmetic with `fast` flag enabledUlrik Sverdrup-0/+60
`fast` a.k.a UnsafeAlgebra is the flag for enabling all "unsafe" (according to llvm) float optimizations. See LangRef for more information http://llvm.org/docs/LangRef.html#fast-math-flags Providing these operations with less precise associativity rules (for example) is useful to numerical applications. For example, the summation loop: let sum = 0.; for element in data { sum += *element; } Using the default floating point semantics, this loop expresses the floats must be added in a sequence, one after another. This constraint is usually completely unintended, and it means that no autovectorization is possible.
2016-03-17Add #[rustc_no_mir] to make tests pass with -Z orbit.Eduard Burtescu-0/+17
2016-03-17tests: Use arguments in codegen/stores.rs to turn aggregates into immediates.Eduard Burtescu-15/+8
2016-03-17tests: Force instantiation of extern fns.Eduard Burtescu-0/+5
2016-02-10Workaround LLVM optimizer bug by not marking &mut pointers as noaliasBjörn Steinbrink-3/+6
LLVM's memory dependence analysis doesn't properly account for calls that could unwind and thus effectively act as a branching point. This can lead to stores that are only visible when the call unwinds being removed, possibly leading to calls to drop() functions with b0rked memory contents. As there is no fix for this in LLVM yet and we want to keep compatibility to current LLVM versions anyways, we have to workaround this bug by omitting the noalias attribute on &mut function arguments. Benchmarks suggest that the performance loss by this change is very small. Thanks to @RalfJung for pushing me towards not removing too many noalias annotations and @alexcrichton for helping out with the test for this bug. Fixes #29485
2016-02-04Avoid quadratic growth of functions due to cleanupsBjörn Steinbrink-0/+47
If a new cleanup is added to a cleanup scope, the cached exits for that scope are cleared, so all previous cleanups have to be translated again. In the worst case this means that we get N distinct landing pads where the last one has N cleanups, then N-1 and so on. As new cleanups are to be executed before older ones, we can instead cache the number of already translated cleanups in addition to the block that contains them, and then only translate new ones, if any and then jump to the cached ones, getting away with linear growth instead. For the crate in #31381 this reduces the compile time for an optimized build from >20 minutes (I cancelled the build at that point) to about 11 seconds. Testing a few crates that come with rustc show compile time improvements somewhere between 1 and 8%. The "big" winner being rustc_platform_intrinsics which features code similar to that in #31381. Fixes #31381
2016-01-12[MIR] Avoid some code generation for stores of ZSTSimonas Kazlauskas-0/+27
Fixes #30831
2015-11-20Avoid FCA loads and extractvalue when copying fat pointersBjörn Steinbrink-0/+22
Since fat pointers do not qualify as structural types, they got copied using load_ty and store_ty, which means that we load an FCA and use extractvalue to get the components of the fat pointer. This breaks certain optimizations in LLVM. Found via apasel422/ref_count#13
2015-10-10Set proper alignment on constantsBjörn Steinbrink-0/+66
For enum variants, the default alignment for a specific variant might be lower than the alignment of the enum type itself. In such cases we, for example, generate memcpy calls with an alignment that's higher than the alignment of the constant we copy from. To avoid that, we need to explicitly set the required alignment on constants. Fixes #28912.
2015-10-01Avoid unnecessary temporaries when ref'ing a DST valueBjörn Steinbrink-0/+30
A DST value and a fat pointer to it have the same representation, all we have to do is to adjust the type of the datum holding the pointer.
2015-09-25Tell LLVM when a match is exhaustiveBjörn Steinbrink-0/+30
By putting an "unreachable" instruction into the default arm of a switch instruction we can let LLVM know that the match is exhaustive, allowing for better optimizations. For example, this match: ```rust pub enum Enum { One, Two, Three, } impl Enum { pub fn get_disc(self) -> u8 { match self { Enum::One => 0, Enum::Two => 1, Enum::Three => 2, } } } ``` Currently compiles to this on x86_64: ```asm .cfi_startproc movzbl %dil, %ecx cmpl $1, %ecx setne %al testb %cl, %cl je .LBB0_2 incb %al movb %al, %dil .LBB0_2: movb %dil, %al retq .Lfunc_end0: ``` But with this change we get: ```asm .cfi_startproc movb %dil, %al retq .Lfunc_end0: ```
2015-09-21Avoid loading the whole gdb debug scripts section.Richard Diamond-0/+37
This is so LLVM isn't forced to load every byte of it. Also sets the alignment of the load. Adds a test for the debug script section.
2015-09-18Skip no-op adjustments in transBjörn Steinbrink-0/+9
That allows us to keep using trans_into() in case of adjustments that may actually be ignored in trans because they are a plain deref/ref pair with no overloaded deref or unsizing. Unoptimized(!) benchmarks from servo/servo#7638 Before ``` test goser::bench_clone ... bench: 17,701 ns/iter (+/- 58) = 30 MB/s test goser::bincode::bench_decoder ... bench: 33,715 ns/iter (+/- 300) = 11 MB/s test goser::bincode::bench_deserialize ... bench: 36,804 ns/iter (+/- 329) = 9 MB/s test goser::bincode::bench_encoder ... bench: 34,695 ns/iter (+/- 149) = 11 MB/s test goser::bincode::bench_populate ... bench: 18,879 ns/iter (+/- 88) test goser::bincode::bench_serialize ... bench: 31,668 ns/iter (+/- 156) = 11 MB/s test goser::capnp::bench_deserialize ... bench: 2,049 ns/iter (+/- 87) = 218 MB/s test goser::capnp::bench_deserialize_packed ... bench: 10,707 ns/iter (+/- 258) = 31 MB/s test goser::capnp::bench_populate ... bench: 635 ns/iter (+/- 5) test goser::capnp::bench_serialize ... bench: 35,657 ns/iter (+/- 155) = 12 MB/s test goser::capnp::bench_serialize_packed ... bench: 37,881 ns/iter (+/- 146) = 8 MB/s test goser::msgpack::bench_decoder ... bench: 50,634 ns/iter (+/- 307) = 5 MB/s test goser::msgpack::bench_encoder ... bench: 25,738 ns/iter (+/- 90) = 11 MB/s test goser::msgpack::bench_populate ... bench: 18,900 ns/iter (+/- 138) test goser::protobuf::bench_decoder ... bench: 2,791 ns/iter (+/- 29) = 102 MB/s test goser::protobuf::bench_encoder ... bench: 75,414 ns/iter (+/- 358) = 3 MB/s test goser::protobuf::bench_populate ... bench: 19,248 ns/iter (+/- 92) test goser::rustc_serialize_json::bench_decoder ... bench: 109,999 ns/iter (+/- 797) = 5 MB/s test goser::rustc_serialize_json::bench_encoder ... bench: 58,777 ns/iter (+/- 418) = 10 MB/s test goser::rustc_serialize_json::bench_populate ... bench: 18,887 ns/iter (+/- 76) test goser::serde_json::bench_deserializer ... bench: 104,803 ns/iter (+/- 770) = 5 MB/s test goser::serde_json::bench_populate ... bench: 18,890 ns/iter (+/- 69) test goser::serde_json::bench_serializer ... bench: 75,046 ns/iter (+/- 435) = 8 MB/s ``` After ``` test goser::bench_clone ... bench: 16,052 ns/iter (+/- 188) = 34 MB/s test goser::bincode::bench_decoder ... bench: 31,194 ns/iter (+/- 941) = 12 MB/s test goser::bincode::bench_deserialize ... bench: 33,934 ns/iter (+/- 352) = 10 MB/s test goser::bincode::bench_encoder ... bench: 30,737 ns/iter (+/- 1,969) = 13 MB/s test goser::bincode::bench_populate ... bench: 17,234 ns/iter (+/- 176) test goser::bincode::bench_serialize ... bench: 28,269 ns/iter (+/- 452) = 12 MB/s test goser::capnp::bench_deserialize ... bench: 2,019 ns/iter (+/- 85) = 221 MB/s test goser::capnp::bench_deserialize_packed ... bench: 10,662 ns/iter (+/- 527) = 31 MB/s test goser::capnp::bench_populate ... bench: 607 ns/iter (+/- 2) test goser::capnp::bench_serialize ... bench: 30,488 ns/iter (+/- 219) = 14 MB/s test goser::capnp::bench_serialize_packed ... bench: 33,731 ns/iter (+/- 201) = 9 MB/s test goser::msgpack::bench_decoder ... bench: 46,921 ns/iter (+/- 461) = 6 MB/s test goser::msgpack::bench_encoder ... bench: 22,315 ns/iter (+/- 96) = 12 MB/s test goser::msgpack::bench_populate ... bench: 17,268 ns/iter (+/- 73) test goser::protobuf::bench_decoder ... bench: 2,658 ns/iter (+/- 44) = 107 MB/s test goser::protobuf::bench_encoder ... bench: 71,024 ns/iter (+/- 359) = 4 MB/s test goser::protobuf::bench_populate ... bench: 17,704 ns/iter (+/- 104) test goser::rustc_serialize_json::bench_decoder ... bench: 107,867 ns/iter (+/- 759) = 5 MB/s test goser::rustc_serialize_json::bench_encoder ... bench: 52,327 ns/iter (+/- 479) = 11 MB/s test goser::rustc_serialize_json::bench_populate ... bench: 17,262 ns/iter (+/- 68) test goser::serde_json::bench_deserializer ... bench: 99,156 ns/iter (+/- 657) = 6 MB/s test goser::serde_json::bench_populate ... bench: 17,264 ns/iter (+/- 77) test goser::serde_json::bench_serializer ... bench: 66,135 ns/iter (+/- 392) = 9 MB/s ```
2015-09-17Don't create adjustments from a type to itselfBjörn Steinbrink-0/+28
Currently, we're generating adjustments, for example, to get from &[u8] to &[u8], which is unneeded and kicks us out of trans_into() into trans() which means an additional stack slot and copy in the unoptimized code.
2015-09-14Mark all extern functions as nounwindBjörn Steinbrink-0/+23
Unwinding across an FFI boundary is undefined behaviour, so we can mark all external function as nounwind. The obvious exception are those functions that actually perform the unwinding.
2015-09-06Don't add unnamed address attributes to intrinsics.Richard Diamond-0/+22
Intrinsics never have an address, so it doesn't make sense to say that their address is unnamed.
2015-08-19Issue #27628 - Also support the LLVM 3.6 IR format in two testsSylvestre Ledru-6/+6