about summary refs log tree commit diff
path: root/src/librustc_trans
AgeCommit message (Collapse)AuthorLines
2017-08-09Initial pass review commentsAlex Crichton-3/+1
2017-08-09Merge remote-tracking branch 'origin/master' into genAlex Crichton-654/+1651
2017-08-09trans-scheduler: Let main thread take over for other worker.Michael Woerister-0/+10
2017-08-06Auto merge of #43488 - Florob:repeat-opt, r=arielb1bors-4/+34
Optimize initialization of arrays using repeat expressions This PR was inspired by [this thread](https://www.reddit.com/r/rust/comments/6o8ok9/understanding_rust_performances_a_newbie_question/) on Reddit. It tries to bring array initialization in the same ballpark as `Vec::from_elem()` for unoptimized builds. For optimized builds this should relieve LLVM of having to figure out the construct we generate is in fact a `memset()`. To that end this emits `llvm.memset()` when: * the array is of integer type and all elements are zero (`Vec::from_elem()` also explicitly optimizes for this case) * the array elements are byte sized If the array is zero-sized initialization is omitted entirely.
2017-08-05Auto merge of #43554 - eddyb:apfloat, r=nikomatsakisbors-12/+16
APFloat: Rewrite It In Rust and use it for deterministic floating-point CTFE. As part of the CTFE initiative, we're forced to find a solution for floating-point operations. By design, IEEE-754 does not explicitly define everything in a deterministic manner, and there is some variability between platforms, at the very least (e.g. NaN payloads). If types are to evaluate constant expressions involving type (or in the future, const) generics, that evaluation needs to be *fully deterministic*, even across `rustc` host platforms. That is, if `[T; T::X]` was used in a cross-compiled library, and the evaluation of `T::X` executed a floating-point operation, that operation has to be reproducible on *any other host*, only knowing `T` and the definition of the `X` associated const (as either AST or HIR). Failure to uphold those rules allows an associated type (e.g. `<Foo as Iterator>::Item`) to be seen as two (or more) different types, depending on the current host, and such type safety violations typically allow writing of a `transmute` in safe code, given enough generics. The options considered by @rust-lang/compiler were: 1. Ban floating-point operations in generic const-evaluation contexts 2. Emulate floating-point operations in an uniformly deterministic fashion The former option may seem appealing at first, but floating-point operations *are allowed today*, so they can't be banned wholesale, a distinction has to be made between the code that already works, and future generic contexts. *Moreover*, every computation that succeeded *has to be cached*, otherwise the generic case can be reproduced without any generics. IMO there are too many ways it can go wrong, and a single violation can be enough for an unsoundness hole. Not to mention we may end up really wanting floating-point operations *anyway*, in CTFE. I went with the latter option, and seeing how LLVM *already* has a library for this exact purpose (as it needs to perform optimizations independently of host floating-point capabilities), i.e. `APFloat`, that was what I ended up basing this PR on. But having been burned by the low reusability of bindings that link to LLVM, and because I would *rather* the floating-point operations to be wrong than not deterministic or not memory-safe (`APFloat` does far more pointer juggling than I'm comfortable with), I decided to RIIR. This way, we have a guarantee of *no* `unsafe` code, a bit more control over the where native floating-point might accidentally be involved, and non-LLVM backends can share it. I've also ported all the testcases over, *before* any functionality, to catch any mistakes. Currently the PR replaces all CTFE operations to go through `apfloat::ieee::{Single,Double}`, keeping only the bits of the `f32` / `f64` memory representation in between operations. Converting from a string also double-checks that `core::num` and `apfloat` agree on the interpretation of a floating-point number literal, in case either of them has any bugs left around. r? @nikomatsakis f? @nagisa @est31 <hr/> Huge thanks to @edef1c for first demoing usable `APFloat` bindings and to @chandlerc for fielding my questions on IRC about `APFloat` peculiarities (also upstreaming some bugfixes).
2017-08-04Auto merge of #43615 - dhduvall:lto-unaligned-read, r=nagisabors-2/+3
Fix some unaligned reads on SPARC in LTO This fixes #43593 by eliminating some undefined behavior.
2017-08-04Auto merge of #43403 - RalfJung:mir-validate, r=nikomatsakisbors-0/+3
Add MIR Validate statement This adds statements to MIR that express when types are to be validated (following [Types as Contracts](https://internals.rust-lang.org/t/types-as-contracts/5562)). Obviously nothing is stabilized, and in fact a `-Z` flag has to be passed for behavior to even change at all. This is meant to make experimentation with Types as Contracts in miri possible. The design is definitely not final. Cc @nikomatsakis @aturon
2017-08-04trans: Reuse immediate value in call to call_memset()Florian Zeitz-2/+1
2017-08-02Fix some unaligned reads on SPARC in LTODanek Duvall-2/+3
This fixes #43593 by eliminating some undefined behavior.
2017-08-02rustc_trans: do not pass floating-point values to LLVM through FFI.Eduard-Mihai Burtescu-14/+13
2017-08-02rustc_const_math: use apfloat::ieee::{Single,Double} in ConstFloat.Eduard-Mihai Burtescu-3/+8
2017-08-02incr.comp.: Properly incorporate symbol linkage and visibility into CGU hash.Michael Woerister-18/+5
2017-08-02Rollup merge of #43389 - alexcrichton:thread-error, r=michaelwoeristerCorey Farwell-12/+11
Thread through the original error when opening archives This updates the management of opening archives to thread through the original piece of error information from LLVM over to the end consumer, trans.
2017-08-02Fixed another problem.Isaac van Bakel-2/+2
2017-08-02trans: Check LLVM type instead of LayoutFlorian Zeitz-8/+4
2017-08-01Fixed all unnecessary muts in language coreIsaac van Bakel-2/+2
2017-08-01Auto merge of #43506 - michaelwoerister:async-llvm, r=alexcrichtonbors-575/+1487
Run translation and LLVM in parallel when compiling with multiple CGUs This is still a work in progress but the bulk of the implementation is done, so I thought it would be good to get it in front of more eyes. This PR makes the compiler start running LLVM while translation is still in progress, effectively allowing for more parallelism towards the end of the compilation pipeline. It also allows the main thread to switch between either translation or running LLVM, which allows to reduce peak memory usage since not all LLVM module have to be kept in memory until linking. This is especially good for incr. comp. but it works just as well when running with `-Ccodegen-units=N`. In order to help tuning and debugging the work scheduler, the PR adds the `-Ztrans-time-graph` flag which spits out html files that show how work packages where scheduled: ![Building regex](https://user-images.githubusercontent.com/1825894/28679272-f6752bd8-72f2-11e7-8a6c-56207855ce95.png) (red is translation, green is llvm) One side effect here is that `-Ztime-passes` might show something not quite correct because trans and LLVM are not strictly separated anymore. I plan to have some special handling there that will try to produce useful output. One open question is how to determine whether the trans-thread should switch to intermediate LLVM processing. TODO: - [x] Restore `-Z time-passes` output for LLVM. - [x] Update documentation, esp. for work package scheduling. - [x] Tune the scheduling algorithm. cc @alexcrichton @rust-lang/compiler
2017-08-01async-llvm(28): Make some error messages more informative.Michael Woerister-6/+18
2017-07-31async-llvm(27): Move #[rustc_error] check to an earlier point in order to ↵Michael Woerister-9/+17
restore some test expections.
2017-07-31trans::mir::constant - fix assignment error recoveryAriel Ben-Yehuda-27/+35
We used to not store anything when the RHS of an assignment returned an error, which caused ICEs downstream. Fixes #43197.
2017-07-31async-llvm(26): Print error when failing to acquire Jobserver token.Michael Woerister-14/+18
2017-07-31async-llvm(25): Restore -Ztime-passes output for trans and LLVM.Michael Woerister-7/+52
2017-07-31async-llvm(24): Improve scheduling and documentation.Michael Woerister-90/+214
2017-07-31async-llvm(23): Let the main thread also do LLVM work in order to reduce ↵Michael Woerister-98/+218
memory pressure.
2017-07-31async-llvm(22): mw invokes mad html skillz to produce graphical LLVM timing ↵Michael Woerister-0/+222
reports.
2017-07-31async-llvm(21): Re-use worker-ids in order to simulate persistent worker ↵Michael Woerister-6/+29
threads.
2017-07-31async-llvm(20): Do some cleanup.Michael Woerister-25/+24
2017-07-31async-llvm(19): Already start LLVM while still translating.Michael Woerister-48/+55
2017-07-31async-llvm(18): Instantiate OngoingCrateTranslation before starting translation.Michael Woerister-57/+70
2017-07-31async-llvm(17): Create MSVC __imp_ symbols immediately for each module.Michael Woerister-39/+27
2017-07-31async-llvm(16): Inject allocator shim into LLVM module immediately if necessary.Michael Woerister-12/+27
2017-07-31async-llvm(15): Don't require number of codegen units upfront.Michael Woerister-34/+27
2017-07-31async-llvm(14): Move LTO/codegen-unit conflict check to beginning of ↵Michael Woerister-13/+0
compilation process.
2017-07-31async-llvm(13): Submit LLVM work packages from base::trans_crate().Michael Woerister-83/+87
2017-07-31async-llvm(12): Hide no_integrated_as logic in write::run_passes.Michael Woerister-41/+23
2017-07-31async-llvm(11): Delay joining ongoing translation until right before linking.Michael Woerister-110/+98
2017-07-31async-llvm(10): Factor compile output files cleanup into separate functions.Michael Woerister-85/+101
2017-07-31async-llvm(9): Move OngoingCrateTranslation into back::write.Michael Woerister-71/+81
2017-07-31async-llvm(8): Clean up resource management and drop LLVM modules ASAP.Michael Woerister-149/+256
2017-07-31async-llvm(7): Clean up error handling a bit.Michael Woerister-6/+13
2017-07-31async-llvm(6): Make the LLVM work coordinator get its work package through a ↵Michael Woerister-28/+53
channel instead of upfront.
2017-07-31async-llvm(5): Do continuous error handling on main thread.Michael Woerister-14/+55
2017-07-31async-llvm(4): Move work coordination to separate thread in order to free up ↵Michael Woerister-63/+61
the main thread for translation.
2017-07-31async-llvm(3): Make write::CodegenContext Clone and Send.Michael Woerister-82/+78
2017-07-31async-llvm(2): Decouple diagnostics emission from LLVM worker coordination.Michael Woerister-154/+238
2017-07-31async-llvm(1): Run LLVM already in trans_crate().Michael Woerister-25/+119
2017-07-30add new instructions for asserting when values are valid, and to describe ↵Ralf Jung-0/+3
when we can rely on them being locked in memory
2017-07-29Auto merge of #43492 - lu-zero:master, r=alexcrichtonbors-1/+4
More Altivec Intrinsics
2017-07-29Auto merge of #43518 - cuviper:aapcs_vfp, r=eddybbors-5/+55
Support homogeneous aggregates for hard-float ARM Hard-float ARM targets use the AAPCS-VFP ABI, which passes and returns homogeneous float/vector aggregates in the VFP registers. Fixes #43329. r? @eddyb
2017-07-28Remove support for `gen arg`Alex Crichton-1/+1