about summary refs log tree commit diff
path: root/src/librustc/mir
AgeCommit message (Collapse)AuthorLines
2018-08-14Label definition of captured variables in errors.David Wood-5/+22
2018-08-03Auto merge of #52712 - oli-obk:const_eval_cleanups, r=RalfJungbors-127/+158
Reintroduce `Undef` and properly check constant value sizes r? @RalfJung cc @eddyb basically all kinds of silent failures that never occurred are assertions now
2018-08-03Unify API of `Scalar` and `ScalarMaybeUndef`Oliver Schneider-2/+6
2018-08-02Second field of ScalarPair can be undef in some casesOliver Schneider-6/+5
2018-08-01Address behaviour changing review commentsOliver Schneider-18/+0
2018-08-01Address stylistic review comments and rebase falloutOliver Schneider-3/+6
2018-08-01Reintroduce `Undef` and properly check constant value sizesOliver Schneider-126/+169
2018-08-01Split out growth functionality into BitVector typeMark Rousskov-5/+5
2018-07-29Auto merge of #52738 - ljedrz:push_to_extend, r=eddybbors-3/+1
Replace push loops with extend() where possible Or set the vector capacity where I couldn't do it. According to my [simple benchmark](https://gist.github.com/ljedrz/568e97621b749849684c1da71c27dceb) `extend`ing a vector can be over **10 times** faster than `push`ing to it in a loop: 10 elements (6.1 times faster): ``` test bench_extension ... bench: 75 ns/iter (+/- 23) test bench_push_loop ... bench: 458 ns/iter (+/- 142) ``` 100 elements (11.12 times faster): ``` test bench_extension ... bench: 87 ns/iter (+/- 26) test bench_push_loop ... bench: 968 ns/iter (+/- 3,528) ``` 1000 elements (11.04 times faster): ``` test bench_extension ... bench: 311 ns/iter (+/- 9) test bench_push_loop ... bench: 3,436 ns/iter (+/- 233) ``` Seems like a good idea to use `extend` as much as possible.
2018-07-29Sanity-check all constantsOliver Schneider-1/+1
2018-07-29Replace push loops with collect() and extend() where possibleljedrz-3/+1
2018-07-27Prefer to_string() to format!()ljedrz-1/+1
2018-07-25parameterize `BitVector` and `BitMatrix` by their index typesNiko Matsakis-7/+6
2018-07-23Promoteds are statics and statics have a place, not just a valueOliver Schneider-64/+13
2018-07-22Improved is_upvar_field_projection - no longer need recurse parameter.David Wood-10/+12
2018-07-22Improved closure errors.David Wood-0/+31
2018-07-20MIR changes to improve NLL cannot mutate errorsMatthew Jasper-0/+3
Alway use unique instead of mutable borrows immutable upvars. Mark variables that are references for a match guard
2018-07-16rustc: Use link_section, not wasm_custom_sectionAlex Crichton-5/+2
This commit transitions definitions of custom sections on the wasm target from the unstable `#[wasm_custom_section]` attribute to the already-stable-for-other-targets `#[link_section]` attribute. Mostly the same restrictions apply as before, except that this now applies only to statics. Closes #51088
2018-07-16BinOpKindcsmoe-17/+17
2018-07-16Revert "Clean up CodegenUnit name generation."Michael Woerister-77/+2
This reverts commit 2c5cd9ce53d2d25041db0cb02b40ba460ffa8908.
2018-07-13Auto merge of #52266 - michaelwoerister:incr-thinlto-preliminaries, ↵bors-2/+77
r=alexcrichton Preliminary work for incremental ThinLTO. Since implementing incremental ThinLTO is a bit more involved than I initially thought, I'm splitting out some of the things that already work. This PR (1) adds a way accessing some ThinLTO information in `rustc` and (2) does some cleanup around CGU/object file naming (which makes things quite a bit nicer). This is probably best reviewed one commit at a time.
2018-07-13Auto merge of #51987 - nikomatsakis:nll-region-infer-scc, r=pnkfelixbors-6/+14
nll experiment: compute SCCs instead of iterative region solving This is an attempt to speed up region solving by replacing the current iterative dataflow with a SCC computation. The idea is to detect cycles (SCCs) amongst region constraints and then compute just one value per cycle. The graph with all cycles removed is of course a DAG, so we can then solve constraints "bottom up" once the liveness values are known. I kinda ran out of time this morning so the last commit is a bit sloppy but I wanted to get this posted, let travis run on it, and maybe do a perf run, before I clean it up.
2018-07-13nit: `use graph::{self, ..}`Niko Matsakis-2/+1
2018-07-12rename `control_flow_graph` to `graph`Niko Matsakis-10/+10
2018-07-12deconstruct the `ControlFlowGraph` trait into more granular traitsNiko Matsakis-4/+13
2018-07-11Rollup merge of #52207 - RalfJung:unsafety-errors, r=estebankMark Rousskov-0/+1
improve error message shown for unsafe operations Add a short explanation saying why undefined behavior could arise. In particular, the error many people got for "creating a pointer to a packed field requires unsafe block" was not worded great -- it lead to people just adding the unsafe block without considering if what they are doing follows the rules. I am not sure if a "note" is the right thing, but that was the easiest thing to add... Inspired by @gnzlbg at https://github.com/rust-lang/rust/issues/46043#issuecomment-381544673
2018-07-11Auto merge of #51702 - ecstatic-morse:infinite-loop-detection, r=oli-obkbors-2/+5
Infinite loop detection for const evaluation Resolves #50637. An `EvalContext` stores the transient state (stack, heap, etc.) of the MIRI virtual machine while it executing code. As long as MIRI only executes pure functions, we can detect if a program is in a state where it will never terminate by periodically taking a "snapshot" of this transient state and comparing it to previous ones. If any two states are exactly equal, the machine must be in an infinite loop. Instead of fully cloning a snapshot every time the detector is run, we store a snapshot's hash. Only when a hash collision occurs do we fully clone the interpreter state. Future snapshots which cause a collision will be compared against this clone, causing the interpreter to abort if they are equal. At the moment, snapshots are not taken until MIRI has progressed a certain amount. After this threshold, snapshots are taken every `DETECTOR_SNAPSHOT_PERIOD` steps. This means that an infinite loop with period `P` will be detected after a maximum of `2 * P * DETECTOR_SNAPSHOT_PERIOD` interpreter steps. The factor of 2 arises because we only clone a snapshot after it causes a hash collision.
2018-07-11Clean up CodegenUnit name generation.Michael Woerister-2/+77
2018-07-10Upgrade to LLVM's master branch (LLVM 7)Alex Crichton-2/+6
This commit upgrades the main LLVM submodule to LLVM's current master branch. The LLD submodule is updated in tandem as well as compiler-builtins. Along the way support was also added for LLVM 7's new features. This primarily includes the support for custom section concatenation natively in LLD so we now add wasm custom sections in LLVM IR rather than having custom support in rustc itself for doing so. Some other miscellaneous changes are: * We now pass `--gc-sections` to `wasm-ld` * The optimization level is now passed to `wasm-ld` * A `--stack-first` option is passed to LLD to have stack overflow always cause a trap instead of corrupting static data * The wasm target for LLVM switched to `wasm32-unknown-unknown`. * The syntax for aligned pointers has changed in LLVM IR and tests are updated to reflect this. * The `thumbv6m-none-eabi` target is disabled due to an [LLVM bug][llbug] Nowadays we've been mostly only upgrading whenever there's a major release of LLVM but enough changes have been happening on the wasm target that there's been growing motivation for quite some time now to upgrade out version of LLD. To upgrade LLD, however, we need to upgrade LLVM to avoid needing to build yet another version of LLVM on the builders. The revision of LLVM in use here is arbitrarily chosen. We will likely need to continue to update it over time if and when we discover bugs. Once LLVM 7 is fully released we can switch to that channel as well. [llbug]: https://bugs.llvm.org/show_bug.cgi?id=37382
2018-07-10improve error message shown for unsafe operations: explain why undefined ↵Ralf Jung-0/+1
behavior could arise Inspired by @gnzlbg at https://github.com/rust-lang/rust/issues/46043#issuecomment-381544673
2018-07-06Auto merge of #52021 - nikomatsakis:nll-region-errors, r=estebankbors-1/+13
refactor and cleanup region errors for NLL This is a WIP commit. It simplifies some of the code from https://github.com/rust-lang/rust/pull/51536 and extends a few more steps towards the errors that @davidtwco and I were shooting for. These are intended as a replacement for the general "unable to infer lifetime" messages -- one that is actually actionable. We're certainly not there yet, but the overall shape hopefully gets a bit clearer. I'm thinking about trying to open up an internals thread to sketch out the overall plan and perhaps discuss how to get the wording right, which special cases to handle, etc. r? @estebank cc @davidtwco
2018-07-04Shorten error message and add link to testDylan MacKenzie-2/+1
Implements @bjorn3's suggestions.
2018-07-04Derive Eq and Hash for types used in Miri's evaluatorDylan MacKenzie-2/+2
2018-07-04Explain reason behind error spanDylan MacKenzie-1/+3
We can't expand the span of the error reliably according to @oli-obk, so just mention why it points to this particular expression.
2018-07-04Add an `InfiniteLoop` variant to `EvalErrorKind`Dylan MacKenzie-0/+2
2018-07-03add `assert_crate_local` method to `ClearCrossCrate`Niko Matsakis-0/+9
2018-07-03store the `HirId` of the upvarNiko Matsakis-1/+4
2018-07-03Update outdated comment: ByVal -> Scalar.Zach Wolfe-2/+2
2018-07-03Auto merge of #51889 - spastorino:make-causal-tracking-lazy, r=nikomatsakisbors-0/+29
Make causal tracking lazy Closes #51710 r? @nikomatsakis
2018-07-01Make causal tracking lazySantiago Pastorino-0/+29
2018-07-01Auto merge of #51110 - alexreg:new-static-eval-rules, r=eddybbors-0/+3
Loosened rules involving statics mentioning other statics Before this PR, trying to mention a static in any way other than taking a reference to it caused a compile-time error. So, while ```rust static A: u32 = 42; static B: &u32 = &A; ``` compiles successfully, ```rust static A: u32 = 42; static B: u32 = A; // error ``` and ```rust static A: u32 = 42; static B: u32 = *&A; // error ``` are not possible to express in Rust. On the other hand, introducing an intermediate `const fn` can presently allow one to do just that: ```rust static A: u32 = 42; static B: u32 = foo(&A); // success! const fn foo(a: &u32) -> u32 { *a } ``` Preventing `const fn` from allowing to work around the ban on reading from statics would cripple `const fn` almost into uselessness. Additionally, the limitation for reading from statics comes from the old const evaluator(s) and is not shared by `miri`. This PR loosens the rules around use of statics to allow statics to evaluate other statics by value, allowing all of the above examples to compile and run successfully. Reads from extern (foreign) statics are however still disallowed by miri, because there is no compile-time value to be read. ```rust extern static A: u32; static B: u32 = A; // error ``` This opens up a new avenue of potential issues, as a static can now not just refer to other statics or read from other statics, but even contain references that point into itself. While it might seem like this could cause subtle bugs like allowing a static to be initialized by its own value, this is inherently impossible in miri. Reading from a static causes the `const_eval` query for that static to be invoked. Calling the `const_eval` query for a static while already inside the `const_eval` query of said static will cause cycle errors. It is not possible to accidentally create a bug in miri that would enable initializing a static with itself, because the memory of the static *does not exist* while being initialized. The memory is not uninitialized, it is not there. Thus any change that would accidentally allow reading from a not yet initialized static would cause ICEs. Tests have been modified according to the new rules, and new tests have been added for writing to `static mut`s within definitions of statics (which needs to fail), and incremental compilation with complex/interlinking static definitions. Note that incremental compilation did not need to be adjusted, because all of this was already possible before with workarounds (like intermediate `const fn`s) and the encoding/decoding already supports all the possible cases. r? @eddyb
2018-07-01Auto merge of #51833 - wesleywiser:faster_large_constant_arrays, r=oli-obkbors-0/+3
Speed up compilation of large constant arrays This is a different approach to #51672 as suggested by @oli-obk. Rather than write each repeated value one-by-one, we write the first one and then copy its value directly into the remaining memory. With this change, the [toy program](https://github.com/rust-lang/rust/blob/c2f4744d2db4e162df824d0bd0b093ba4b351545/src/test/run-pass/mir_heavy_promoted.rs) goes from 63 seconds to 19 seconds on my machine. Edit: Inlining `Size::bytes()` saves an additional 6 seconds dropping the total time to 13 seconds on my machine. Edit2: Now down to 2.8 seconds. r? @oli-obk cc @nnethercote @eddyb
2018-06-30Minor refactoring.Alexander Regueiro-1/+1
2018-06-30Added miri error for evaluating foreign statics.Alexander Regueiro-0/+3
Updated tests accordingly.
2018-06-29Inline a few `UndefMask` methods.Wesley Wiser-0/+3
This saves 2.5 seconds on the test program.
2018-06-29Auto merge of #51729 - matthewjasper:move-errors, r=nikomatsakisbors-9/+39
[NLL] Better move errors Make a number of changes to improve the quality of NLL cannot move errors. * Group errors that occur in the same `match` with the same cause. * Suggest `ref`, `&` or removing `*` to avoid the move. * Show the place being matched on. Differences from AST borrowck: * `&` is suggested over `ref` when matching on a place that can't be moved from. * Removing `*` is suggested instead of adding `&` when applicable. * Sub-pattern spans aren't used, this would probably need Spans on Places. Closes #45699 Closes #46627 Closes #51187 Closes #51189 r? @pnkfelix
2018-06-28Turn the use of erroneous constants into errors againOliver Schneider-1/+1
2018-06-28Merge `ConstVal` and `ConstValue`Oliver Schneider-24/+16
2018-06-28FixupOliver Schneider-8/+6
2018-06-28Move everything over from `middle::const_val` to `mir::interpret`Oliver Schneider-3/+122