Commit Graph

1782 Commits

Author SHA1 Message Date
Manish Goregaokar
7208d25003 Rollup merge of #30776 - antonblanchard:powerpc64_merge, r=alexcrichton
This adds support for big endian and little endian PowerPC64.
make check runs clean apart from one big endian backtrace issue.
2016-01-15 17:28:28 +05:30
bors
d8869d3487 Auto merge of #30711 - nrc:json-errs, r=huonw
The compiler can emit errors and warning in JSON format. This is a more easily machine readable form then the usual error output.

Closes #10492, closes #14863.
2016-01-15 01:52:01 +00:00
Michael Wu
a4f91e5fed Support generic associated consts 2016-01-14 17:35:55 -05:00
Nick Cameron
fd46c78f8f Add an --output option for specifying an error emitter 2016-01-15 10:24:12 +13:00
Brian Anderson
4bcca8bcf7 Revert "Link with ld.gold by default"
This reverts commit 34dc0e0739.
2016-01-14 19:20:11 +00:00
bors
e5bab5dd00 Auto merge of #30848 - nagisa:mir-no-store-zsts, r=nikomatsakis
Fixes #30831

r? @nikomatsakis
2016-01-14 15:37:07 +00:00
Manish Goregaokar
e51de045ef Rollup merge of #30851 - jonas-schievink:unneeded-dropflags, r=pnkfelix
Apparently we allocate and maintain non-working dropflag hints since June... In anticipation of a working implementation of on-stack drop flag hints, let's not spend even more time on types that don't even need to be dropped.

```rust
fn main() {
    let (i,j,k,l) = (0,0,0,0);
}
```
used to translate to (unoptimized only, of course):
```llvm
define internal void @_ZN4main20ha8deb085c47920d8eaaE() unnamed_addr #0 {
entry-block:
  %dropflag_hint_10 = alloca i8
  %dropflag_hint_11 = alloca i8
  %dropflag_hint_12 = alloca i8
  %dropflag_hint_13 = alloca i8
  %const = alloca { i32, i32, i32, i32 }
  %i = alloca i32
  %j = alloca i32
  %k = alloca i32
  %l = alloca i32
  store i8 61, i8* %dropflag_hint_10
  store i8 61, i8* %dropflag_hint_11
  store i8 61, i8* %dropflag_hint_12
  store i8 61, i8* %dropflag_hint_13
  %0 = bitcast { i32, i32, i32, i32 }* %const to i8*
  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %0, i8* bitcast ({ i32, i32, i32, i32 }* @const2752 to i8*), i64 16, i32 4, i1 false)
  %1 = getelementptr inbounds { i32, i32, i32, i32 }, { i32, i32, i32, i32 }* %const, i32 0, i32 0
  %2 = load i32, i32* %1, align 4
  store i32 %2, i32* %i, align 4
  %3 = getelementptr inbounds { i32, i32, i32, i32 }, { i32, i32, i32, i32 }* %const, i32 0, i32 1
  %4 = load i32, i32* %3, align 4
  store i32 %4, i32* %j, align 4
  %5 = getelementptr inbounds { i32, i32, i32, i32 }, { i32, i32, i32, i32 }* %const, i32 0, i32 2
  %6 = load i32, i32* %5, align 4
  store i32 %6, i32* %k, align 4
  %7 = getelementptr inbounds { i32, i32, i32, i32 }, { i32, i32, i32, i32 }* %const, i32 0, i32 3
  %8 = load i32, i32* %7, align 4
  store i32 %8, i32* %l, align 4
  ret void
}
```

Now it gives:
```llvm
define internal void @_ZN4main20ha8deb085c47920d8eaaE() unnamed_addr #0 {
entry-block:
  %const = alloca { i32, i32, i32, i32 }
  %i = alloca i32
  %j = alloca i32
  %k = alloca i32
  %l = alloca i32
  %0 = bitcast { i32, i32, i32, i32 }* %const to i8*
  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %0, i8* bitcast ({ i32, i32, i32, i32 }* @const2748 to i8*), i64 16, i32 4, i1 false)
  %1 = getelementptr inbounds { i32, i32, i32, i32 }, { i32, i32, i32, i32 }* %const, i32 0, i32 0
  %2 = load i32, i32* %1, align 4
  store i32 %2, i32* %i, align 4
  %3 = getelementptr inbounds { i32, i32, i32, i32 }, { i32, i32, i32, i32 }* %const, i32 0, i32 1
  %4 = load i32, i32* %3, align 4
  store i32 %4, i32* %j, align 4
  %5 = getelementptr inbounds { i32, i32, i32, i32 }, { i32, i32, i32, i32 }* %const, i32 0, i32 2
  %6 = load i32, i32* %5, align 4
  store i32 %6, i32* %k, align 4
  %7 = getelementptr inbounds { i32, i32, i32, i32 }, { i32, i32, i32, i32 }* %const, i32 0, i32 3
  %8 = load i32, i32* %7, align 4
  store i32 %8, i32* %l, align 4
  ret void
}
```

Let's hope I didn't break anything!
2016-01-14 11:04:43 +05:30
Felix S. Klock II
decc286757 add doc for new fn alloc_ty_init.
(Note that it might be a good idea to replace *all* calls of
`alloc_ty` with calls to `alloc_ty_init`, to encourage programmers to
consider the appropriate value for the `init` flag when creating
temporary values.)
2016-01-13 14:29:50 +01:00
Felix S. Klock II
7706e2333e revise lifetime handling for alloca's that are initialized as "dropped."
(This can/should be revisited when drop flags are stored out of band.)
2016-01-13 14:29:50 +01:00
Felix S. Klock II
8168765d43 Factored out private routine for emitting LLVM lifetime intrinsic calls.
(The reason this is not factored as far as possible because a
subsequent commit is going to need to do construction without having
access to a `cx`.)
2016-01-13 14:29:50 +01:00
Felix S. Klock II
f251ff4081 bug fixes for issues 30018 and 30822.
includes bugfixes pointed out during review:

 * Only `call_lifetime_start` for an alloca if the function entry does
   not itself initialize it to "dropped."

 * Remove `schedule_lifetime_end` after writing an *element* into a
   borrowed slice. (As explained by [dotdash][irc], "the lifetime end
   that is being removed was for an element in the slice, which is not
   an alloca of its own and has no lifetime start of its own")

[irc]: https://botbot.me/mozilla/rust-internals/2016-01-13/?msg=57844504&page=3
2016-01-13 14:02:06 +01:00
Anton Blanchard
b372910476 Add powerpc64 and powerpc64le support
This adds support for big endian and little endian PowerPC64.
make check runs clean apart from one big endian backtrace issue.
2016-01-13 01:39:00 +00:00
Michael Neumann
d485a511d0 Recognize #[thread_local] on extern static. Fixes #30795.
This will correctly add the thread_local attribute to the external static
variable "errno":

    extern {
         #[thread_local]
         static errno: c_int;
    }

Before this commit, the thread_local attribute is ignored.
2016-01-12 20:39:22 +01:00
Simonas Kazlauskas
20618d0e42 [MIR] Avoid some code generation for stores of ZST
Fixes #30831
2016-01-12 21:35:10 +02:00
Jonas Schievink
e3abc3cfe7 Don't use dropflag hints when the type is dropless 2016-01-12 18:04:21 +01:00
Felix S. Klock II
cec7280bf3 debug instrumentation (can remove) 2016-01-12 15:24:52 +01:00
Felix S. Klock II
965b0bfefe Issue 30530: initialize allocas for Datum::to_lvalue_datum_in_scope.
In particular, bring back the `zero` flag for `lvalue_scratch_datum`,
which controls whether the alloca's created immediately at function
start are uninitialized at that point or have their embedded
drop-flags initialized to "dropped".

Then made `to_lvalue_datum_in_scope` pass "dropped" as `zero` flag.
2016-01-12 15:24:52 +01:00
Simonas Kazlauskas
6aaa6068c5 Rollup merge of #30774 - nagisa:mir-fix-constval-adts, r=arielb1
Fixes #30772

We used to have a untested special case which didn’t really work anyway, because of lacking casts. This PR removes the case in question.
2016-01-11 21:17:53 +02:00
Simonas Kazlauskas
2f86c1605c Change destination accessor to return references
Previously it was returning a value, mostly for the two reasons:

* Cloning Lvalue is very cheap most of the time (i.e. when Lvalue is not a Projection);
* There’s users who want &mut lvalue and there’s users who want &lvalue. Returning a value allows
  to make either one easier when pattern matching (i.e. Some(ref dest) or Some(ref mut dest)).

However, I’m now convinced this is an invalid approach. Namely the users which want a mutable
reference may modify the Lvalue in-place, but the changes won’t be reflected in the final MIR,
since the Lvalue modified is merely a clone.

Instead, we have two accessors `destination` and `destination_mut` which return a reference to the
destination in desired mode.
2016-01-08 14:40:32 +02:00
Simonas Kazlauskas
ea52d9ebda [MIR] Fix translation of ConstVal::{Struct, Tuple}
Fixes #30772
2016-01-08 01:15:59 +02:00
bors
1e8350387c Auto merge of #30317 - jseyfried:refactor_type_folder, r=nikomatsakis
`TypeFoldable`s can currently be visited inefficiently with an identity folder that is run only for its side effects. This creates a more efficient visitor for `TypeFoldable`s and uses it to implement `RegionEscape` and `HasProjectionTypes`, fixing cleanup issue #20298.
This is a pure refactoring.
2016-01-07 11:48:35 +00:00
bors
91b27ec9be Auto merge of #30724 - nikomatsakis:feature-gate-defaulted-type-parameters, r=pnkfelix
It was recently realized that we accept defaulted type parameters everywhere, without feature gate, even though the only place that we really *intended* to accept them were on types. This PR adds a lint warning unless the "type-parameter-defaults" feature is enabled. This should eventually become a hard error.

This is a [breaking-change] in that new feature gates are required (or simply removing the defaults, which is probably a better choice as they have little effect at this time). Results of a [crater run][crater] suggest that approximately 5-15 crates are affected. I didn't do the measurement quite right so that run cannot distinguish "true" regressions from "non-root" regressions, but even the upper bound of 15 affected crates seems relatively minimal.

[crater]: https://gist.github.com/nikomatsakis/760c6a67698bd24253bf

cc @rust-lang/lang
r? @pnkfelix
2016-01-07 06:32:56 +00:00
Jeffrey Seyfried
76021d84b3 Refactor away extension traits RegionEscape and HasTypeFlags 2016-01-07 00:42:12 +00:00
Jeffrey Seyfried
f9808ea4b4 Create a visitor for TypeFoldables and use it to implement RegionEscape and HasTypeFlags (fixes #20298) 2016-01-07 00:40:18 +00:00
bors
e8c337b5ca Auto merge of #30532 - nikomatsakis:cross-item-dependencies, r=mw
This is roughly the same as my previous PR that created a dependency graph, but that:

1. The dependency graph is only optionally constructed, though this doesn't seem to make much of a difference in terms of overhead (see measurements below).
2. The dependency graph is simpler (I combined a lot of nodes).
3. The dependency graph debugging facilities are much better: you can now use `RUST_DEP_GRAPH_FILTER` to filter the dep graph to just the nodes you are interested in, which is super help.
4. The tests are somewhat more elaborate, including a few known bugs I need to fix in a second pass.

This is potentially a `[breaking-change]` for plugin authors. If you are poking about in tcx state or something like that, you probably want to add `let _ignore = tcx.dep_graph.in_ignore();`, which will cause your reads/writes to be ignored and not affect the dep-graph.

After this, or perhaps as an add-on to this PR in some cases, what I would like to do is the following:

- [x] Write-up a little guide to how to use this system, the debugging options available, and what the possible failure modes are.
- [ ] Introduce read-only and perhaps the `Meta` node
- [x] Replace "memoization tasks" with node from the map itself
- [ ] Fix the shortcomings, obviously! Notably, the HIR map needs to register reads, and there is some state that is not yet tracked. (Maybe as a separate PR.)
- [x] Refactor the dep-graph code so that the actual maintenance of the dep-graph occurs in a parallel thread, and the main thread simply throws things into a shared channel (probably a fixed-size channel). There is no reason for dep-graph construction to be on the main thread. (Maybe as a separate PR.)

Regarding performance: adding this tracking does add some overhead, approximately 2% in my measurements (I was comparing the build times for rustdoc). Interestingly, enabling or disabling tracking doesn't seem to do very much. I want to poke at this some more and gather a bit more data -- in some tests I've seen that 2% go away, but on others it comes back. It's not entirely clear to me if that 2% is truly due to constructing the dep-graph at all.

The next big step after this is write some code to dump the dep-graph to disk and reload it.

r? @michaelwoerister
2016-01-06 18:37:57 +00:00
Simonas Kazlauskas
36b3951c73 Create personality slot when translating Resume
This considerably simplifies code around calling functions and translation of Resume itself. This
removes requirement that a block containing Resume terminator is always translated after something
which creates a landing pad, thus allowing us to actually translate some valid MIRs we could not
translate before.

However, an assumption is added that translator is correct (in regards to landing pad generation)
and code will never reach the Resume terminator without going through a landing pad first. Breaking
these assumptions would pass an `undef` value into the personality functions.
2016-01-06 13:57:52 +02:00
Simonas Kazlauskas
d1c644c1e9 Merge Call and DivergingCall diffs into CallKind
This merges two separate Call terminators and uses a separate CallKind sub-enum instead.

A little bit unrelatedly, copying into destination value for a certain kind of invoke, is also
implemented here. See the associated comment in code for various details that arise with this
implementation.
2016-01-06 13:57:52 +02:00
Simonas Kazlauskas
cef6aee369 Don’t generate landing-pads if -Z no-landing-pads 2016-01-06 13:57:52 +02:00
Simonas Kazlauskas
20ec53a0d3 Fix ReturnPointer generation for void return types
Fixes #30480
2016-01-06 13:57:52 +02:00
Simonas Kazlauskas
924bb1e5eb Refine call terminator translation
* Implement landing pads; and
* Implement DivergingCall translation; and
* Modernise previous implementation of Call somewhat.
2016-01-06 13:57:51 +02:00
Simonas Kazlauskas
a1e13983f7 Have a cached unreachable block inside MIR state
It is useful for various cases where direct unreachable cannot be translated and a separate block
is necessary.
2016-01-06 13:57:51 +02:00
Simonas Kazlauskas
4e86dcdb72 Remove diverge terminator
Unreachable terminator can be contained all within the trans.
2016-01-06 13:57:51 +02:00
Simonas Kazlauskas
5b34690842 Remove the Panic block terminator 2016-01-06 13:57:51 +02:00
Simonas Kazlauskas
ecf4d0e3ad Add Resume Terminator which corresponds to resume
Diverge should eventually go away
2016-01-06 13:57:51 +02:00
Simonas Kazlauskas
893a66d7a1 Split Call into Call and DivergingCall
DivergingCall is different enough from the regular converging Call to warrant the split. This also
inlines CallData struct and creates a new CallTargets enum in order to have a way to differentiate
between calls that do not have an associated cleanup block.

Note, that this patch still does not produce DivergingCall terminator anywhere. Look for that in
the next patches.
2016-01-06 13:40:57 +02:00
bors
7312e0a163 Auto merge of #30692 - michaelwoerister:mir-overloaded-fn-calls, r=nikomatsakis
So far, calls going through `Fn::call`, `FnMut::call_mut`, or `FnOnce::call_once` have not been translated properly into MIR:
The call `f(a, b, c)` where `f: Fn(T1, T2, T3)` would end up in MIR as:
```
call `f` with arguments  `a`, `b`, `c`
```
What we really want is:
```
call `Fn::call` with arguments  `f`, `a`, `b`, `c`
```
This PR transforms these kinds of overloaded calls during `HIR -> HAIR` translation.

What's still a bit funky is that the `Fn` traits expect arguments to be tupled but due to special handling type-checking and trans, we do not actually tuple arguments and everything still checks out fine. So, after this PR we end up with MIR containing calls where function signature and arguments seemingly don't match:
```
call Fn::call(&self, args: (T1, T2, T3)) with arguments `f`, `a`, `b`, `c`
```
instead of
```
call Fn::call(&self, args: (T1, T2, T3)) with arguments `f`, (`a`, `b`, `c`)  //  <- args tupled!
```
It would be nice if the call traits could go without special handling in MIR and later on.
2016-01-06 09:00:57 +00:00
Niko Matsakis
8b22ed8651 Add assert-dep-graph testing mechanism and tests 2016-01-05 21:05:51 -05:00
Niko Matsakis
005fa14358 Annotate the compiler with information about what it is doing when. 2016-01-05 21:05:50 -05:00
bors
dc1f442634 Auto merge of #30492 - wesleywiser:fix_extra_drops, r=pnkfelix
Fixes #28159
2016-01-06 01:55:45 +00:00
Niko Matsakis
27d6b9d215 improve visibility of future-incompatibilities (mildly, at least) 2016-01-05 16:21:53 -05:00
Michael Woerister
7d357190ff [MIR] Implement calling of closures and add missing monomorphization when translating function references. 2016-01-05 12:50:46 -05:00
bors
41611baece Auto merge of #30661 - michaelwoerister:trans_fn_attrs, r=nrc
So far `librustc::trans::base::trans_fn()` and `trans_closure()` have been passed the list of attributes on the function being translated *only* if the function was local and non-generic. For generic functions, functions inlined from other crates, functions with foreign ABI and for closures, only an empty list of attributes was ever passed to `trans_fn()`.
This led to the case that generic functions marked with `#[rustc_mir]` where not actually translated via MIR but via the legacy translation path.

This PR makes function/closure attributes always be passed to `trans_fn()` and disables the one test where this makes a difference.

If there is an actual reason why attributes were not passed along in these cases, let me know.

cc @rust-lang/compiler
cc @luqmana regarding the test case
2016-01-04 22:09:52 +00:00
Wesley Wiser
8c897ee0ab Avoid adding drops for types w/ no dtor in MIR construction
Fixes #28159
2015-12-31 17:05:08 -05:00
Simonas Kazlauskas
1aa4abdb3b Rollup merge of #30590 - nagisa:mir-constval-function, r=luqmana
This moves back (essentially reverts #30265) into MIR-specific translation code, but keeps the
funcition split out, since it is expected to eventually become recursive.

Fixes https://github.com/rust-lang/rust/issues/29572

cc @oli-obk
2015-12-31 18:52:20 +02:00
Simonas Kazlauskas
23d24ff667 Rollup merge of #30565 - michaelwoerister:opaque_encoder, r=brson
This PR changes the `emit_opaque` and `read_opaque` methods in the RBML library to use a space-efficient binary encoder that does not emit any tags and uses the LEB128 variable-length integer format for all numbers it emits.

The space savings are nice, albeit a bit underwhelming, especially for dynamic libraries where metadata is already compressed.

| RLIBs        |  NEW   |   OLD     |
|--------------|--------|-----------|
|libstd        | 8.8 MB |  10.5 MB  |
|libcore       |15.6 MB |   19.7 MB |
|libcollections| 3.7 MB |    4.8 MB |
|librustc      |34.0 MB |   37.8 MB |
|libsyntax     |28.3 MB |   32.1 MB |

| SOs           |     NEW   |    OLD |
|---------------|-----------|--------|
| libstd        |  4.8 MB   | 5.1 MB |
| librustc      |  8.6 MB   | 9.2 MB |
| libsyntax     |  7.8 MB   | 8.4 MB |

At least this should make up for the size increase caused recently by also storing MIR in crate metadata.

Can this be a breaking change for anyone?
cc @rust-lang/compiler
2015-12-31 18:52:20 +02:00
Michael Woerister
e3c89943ac Forward attributes of translated function/closure to trans_fn/trans_closure. 2015-12-31 08:06:23 -05:00
bors
19a351c776 Auto merge of #30586 - nagisa:mir-cast, r=arielb1
I think that should pretty much conclude all of https://github.com/rust-lang/rust/issues/29576.
2015-12-31 03:01:00 +00:00
bors
5892852168 Auto merge of #30585 - Ms2ger:ExplicitSelfCategory, r=brson 2015-12-31 01:12:38 +00:00
bors
176ee349a7 Auto merge of #30542 - nrc:errs-base, r=nagisa
As discussed [here](https://internals.rust-lang.org/t/more-structured-errors/3005)

r? @nikomatsakis or anyone else on the @rust-lang/compiler team
2015-12-30 12:27:10 +00:00
Nick Cameron
aaa02b3ff9 Refactoring 2015-12-30 14:27:59 +13:00
Nick Cameron
95dc7efad0 use structured errors 2015-12-30 14:27:59 +13:00
Simonas Kazlauskas
feab2ae77e Implement as casting (Misc cast kind) 2015-12-29 20:47:18 +02:00
Simonas Kazlauskas
e137c2ad0a [MIR] Translate ConstVal::Function
This moves back (essentially reverts #30265) into MIR-specific translation code, but keeps the
funcition split out, since it is expected to eventually become recursive.
2015-12-28 21:27:10 +02:00
Brian Anderson
34dc0e0739 Link with ld.gold by default
To disable, pass `-C disable-gold`
2015-12-28 18:08:16 +00:00
Michael Woerister
fa2a7411e4 Use a more efficient encoding for opaque data in RBML. 2015-12-28 12:15:44 -05:00
Simonas Kazlauskas
e7cab13037 [MIR] Fix setting discriminant for unit enums 2015-12-28 15:48:01 +02:00
Ms2ger
b2c370370e Rename ExplicitSelfCategory's variants and stop re-exporting them. 2015-12-28 12:52:43 +01:00
bors
0e9f6ecd0e Auto merge of #30579 - dotdash:30478, r=arielb1
`auto_ref()` currently returns an Rvalue datum for the ref'd value,
which is fine for thin pointers, but for fat pointers this means that
once the pointer is moved out of that datum, its memory will be marked
as dead. And because there is not necessarily an intermediate temporary
involved we can end up marking memory as dead that is actually still
used.

As I don't want to break the micro-optimization for thin pointers by
always returning an Lvalue datum, I decided to only do so for fat
pointers.

Fix #30478
2015-12-28 02:29:14 +00:00
Björn Steinbrink
575f690b39 Fix auto_ref() for fat pointers
`auto_ref()` currently returns an Rvalue datum for the ref'd value,
which is fine for thin pointers, but for fat pointers this means that
once the pointer is moved out of that datum, its memory will be marked
as dead. And because there is not necessarily an intermediate temporary
involved we can end up marking memory as dead that is actually still
used.

As I don't want to break the micro-optimization for thin pointers by
always returning an Lvalue datum, I decided to only do so for fat
pointers.

Fix #30478
2015-12-27 17:57:49 +01:00
Steffen
9af75d2bec llvm: Add support for vectorcall (X86_VectorCall) convention 2015-12-26 21:40:40 +01:00
Simonas Kazlauskas
7b68b5fc2a Also fix MIRification of unit enum variants 2015-12-26 14:44:36 +02:00
Simonas Kazlauskas
75e8f4afca Properly translate unit structs in MIR 2015-12-25 01:02:34 +02:00
Peter Atashian
e77ab57aae Fix Universal CRT detection on weird setups
Checks for a `10.` prefix on the subfolder

Signed-off-by: Peter Atashian <retep998@gmail.com>
2015-12-21 20:44:48 -05:00
bors
2343a92a90 Auto merge of #30352 - alexcrichton:new-snashots, r=nikomatsakis
Lots of cruft to remove!
2015-12-21 21:37:26 +00:00
bors
709d00a231 Auto merge of #30460 - Ms2ger:BindingMode, r=alexcrichton 2015-12-21 19:10:51 +00:00
Alex Crichton
cd1848a1a6 Register new snapshots
Lots of cruft to remove!
2015-12-21 09:26:21 -08:00
bors
c6079d0586 Auto merge of #30486 - nagisa:mir-fix-geps, r=luqmana
Fixes https://github.com/rust-lang/rust/issues/30474
2015-12-21 02:26:10 +00:00
bors
2b8e96dad2 Auto merge of #30482 - luqmana:const-fat-ptr, r=dotdash
Fixes #30479.
2015-12-21 00:39:24 +00:00
Ms2ger
143b9d80d0 Stop re-exporting the ast::BindingMode variants. 2015-12-20 22:15:26 +01:00
bors
712eccee29 Auto merge of #30394 - geofft:dt-runpath, r=alexcrichton
This causes the linker to emit DT_RUNPATH instead of DT_RPATH, which fixes #30378. See that bug for rationale.
2015-12-19 19:39:25 +00:00
Simonas Kazlauskas
2b2f983523 Fix GEPs for MIR indexing translation
Fixes #30474
2015-12-19 20:30:13 +02:00
Luqman Aden
0f860c2977 [MIR] Handle FatPtr in mir::constant::trans_constval. 2015-12-19 09:58:11 -05:00
bors
440ef8b154 Auto merge of #30184 - petrochenkov:ascr, r=nikomatsakis
This PR is a rebase of the original PR by @eddyb https://github.com/rust-lang/rust/pull/21836 with some unrebasable parts manually reapplied, feature gate added + type equality restriction added as described below.

This implementation is partial because the type equality restriction is applied to all type ascription expressions and not only those in lvalue contexts. Thus, all difficulties with detection of these contexts and translation of coercions having effect in runtime are avoided.
So, you can't write things with coercions like `let slice = &[1, 2, 3]: &[u8];`. It obviously makes type ascription less useful than it should be, but it's still much more useful than not having type ascription at all.
In particular, things like `let v = something.iter().collect(): Vec<_>;` and `let u = t.into(): U;` work as expected and I'm pretty happy with these improvements alone.

Part of https://github.com/rust-lang/rust/issues/23416
2015-12-19 02:45:15 +00:00
bors
9e278950c2 Auto merge of #30364 - luqmana:mir-calls, r=nikomatsakis 2015-12-18 23:06:24 +00:00
Luqman Aden
a6b861b197 [MIR] Initial implementation for translating calls. 2015-12-18 17:33:29 -05:00
bors
ef91cdb140 Auto merge of #29973 - petrochenkov:privinpub, r=nikomatsakis
Some notes:
This patch enforces the rules from [RFC 136](https://github.com/rust-lang/rfcs/blob/master/text/0136-no-privates-in-public.md) and makes "private in public" a module-level concept and not crate-level. Only `pub` annotations are used by the new algorithm, crate-level exported node set produced by `EmbargoVisitor` is not used. The error messages are tweaked accordingly and don't use the word "exported" to avoid confusing people (https://github.com/rust-lang/rust/issues/29668).

The old algorithm tried to be extra smart with impls, but it mostly led to unpredictable behavior and bugs like https://github.com/rust-lang/rust/issues/28325.
The new algorithm tries to be as simple as possible - an impl is considered public iff its type is public and its trait is public (if presents).
A type or trait is considered public if all its components are public, [complications](https://internals.rust-lang.org/t/limits-of-type-inference-smartness/2919) with private types leaking to other crates/modules through trait impls and type inference are deliberately ignored so far.

The new algorithm is not recursive and uses the nice new facility `Crate::visit_all_items`!

Obsolete pre-1.0 feature `visible_private_types` is removed.

This is a [breaking-change].
The two main vectors of breakage are type aliases (https://github.com/rust-lang/rust/issues/28450) and impls (https://github.com/rust-lang/rust/issues/28325).
I need some statistics from a crater run (cc @alexcrichton) to decide on the breakage mitigation strategy.
UPDATE: All the new errors are reported as warnings controlled by a lint `private_in_public` and lint group `future_incompatible`, but the intent is to make them hard errors eventually.

Closes https://github.com/rust-lang/rust/issues/28325
Closes https://github.com/rust-lang/rust/issues/28450
Closes https://github.com/rust-lang/rust/issues/29524
Closes https://github.com/rust-lang/rust/issues/29627
Closes https://github.com/rust-lang/rust/issues/29668
Closes https://github.com/rust-lang/rust/issues/30055

r? @nikomatsakis
2015-12-18 18:54:52 +00:00
Vadim Petrochenkov
785cbe0200 Do not substitute type aliases during error reporting
Type aliases are still substituted when determining impl publicity
2015-12-18 20:57:36 +03:00
Manish Goregaokar
a8e424685c Rollup merge of #30452 - dotdash:24876_take_2, r=alexcrichton
LLVM doesn't really support reusing the same module to emit more than
one file. One bug this causes is that the IR is invalidated by the stack
coloring pass when emitting the first file, and then the IR verifier
complains by the time we try to emit the second file. Also, we get
different binaries with --emit=asm,link than with just --emit=link. In
some cases leading to segfaults.

Unfortunately, it seems that at this point in time, the most sensible
option to circumvent this problem is to just clone the whole llvm module
for the asm output if we need both, asm and obj file output.

Fixes #24876
Fixes #26235
2015-12-18 20:02:14 +05:30
Manish Goregaokar
9e953df6f0 Rollup merge of #30420 - petrochenkov:owned2, r=nrc
Part of https://github.com/rust-lang/rust/pull/30095 not causing mysterious segfaults.

r? @nrc
2015-12-18 20:02:12 +05:30
Manish Goregaokar
7eb7bc2e04 Rollup merge of #30398 - jwworth:pull-request-1450205451, r=sanxiyn
This fixes a double word typo, 'the'.
2015-12-18 16:47:38 +05:30
Manish Goregaokar
c2902965cb Rollup merge of #30384 - nrc:diagnostics, r=@nikomatsakis
Should make it possible to add JSON or HTML errors. Also tidies up a lot.
2015-12-18 16:47:37 +05:30
Björn Steinbrink
88ffb26cf5 Fix emitting asm and object file output at the same time
LLVM doesn't really support reusing the same module to emit more than
one file. One bug this causes is that the IR is invalidated by the stack
coloring pass when emitting the first file, and then the IR verifier
complains by the time we try to emit the second file. Also, we get
different binaries with --emit=asm,link than with just --emit=link. In
some cases leading to segfaults.

Unfortunately, it seems that at this point in time, the most sensible
option to circumvent this problem is to just clone the whole llvm module
for the asm output if we need both, asm and obj file output.

Fixes #24876
Fixes #26235
2015-12-18 04:14:52 +01:00
Vadim Petrochenkov
fcbd553f0f Substitute type aliases before checking for privacy 2015-12-18 04:14:46 +03:00
Vadim Petrochenkov
26a2f852be Fix the fallout 2015-12-18 04:12:31 +03:00
bors
4eadabd9f8 Auto merge of #29907 - nagisa:mir-moar-constants, r=nikomatsakis
Still will not translate references to items like `X` or `Y::V` where

```
struct X;
enum Y { V }
```

but I must go work on university things so I’m PRing what I have.

r? @nikomatsakis
2015-12-18 00:24:05 +00:00
Vadim Petrochenkov
6c87b19158 Abstract away differences between Vec and ptr::P in HIR 2015-12-18 00:52:56 +03:00
Vadim Petrochenkov
0d298f9904 Deprecate name OwnedSlice and don't use it 2015-12-18 00:52:56 +03:00
Simonas Kazlauskas
7dd95799c2 Test generic methods 2015-12-17 21:00:27 +02:00
bors
6734dccc31 Auto merge of #30325 - jseyfried:fixes_30078, r=nrc
This fixes a bug in which unused imports can get wrongly marked as used when checking for unused qualifications in `resolve_path` (issue #30078), and it removes unused imports that were previously undetected because of the bug.
2015-12-17 18:21:25 +00:00
Jeffrey Seyfried
8364a6feef Remove unused imports 2015-12-17 05:43:27 +00:00
bors
9687a8a969 Auto merge of #30354 - petrochenkov:defuse, r=sanxiyn
A relic of some old resolution algorithm?
2015-12-17 01:22:53 +00:00
Nick Cameron
a478811822 Move a bunch of stuff from Session to syntax::errors
The intention here is that Session is a very thin wrapper over the error handling infra.
2015-12-17 09:35:51 +13:00
Nick Cameron
6309b0f5bb move error handling from libsyntax/diagnostics.rs to libsyntax/errors/*
Also split out emitters into their own module.
2015-12-17 09:35:50 +13:00
bors
073b0f9b85 Auto merge of #30337 - wesleywiser:mir_switch, r=nikomatsakis
Fixes #29574
2015-12-16 16:10:26 +00:00
Vadim Petrochenkov
0cc69f0ea3 rustc: Remove def::DefUse 2015-12-16 18:19:11 +03:00
Vadim Petrochenkov
e0ceef5a9e Add ExprType to HIR and make everything compile
+ Apply parser changes manually
+ Add feature gate
2015-12-16 17:13:16 +03:00
Eduard Burtescu
b8157cc67f Implement type ascription. 2015-12-16 17:12:35 +03:00
Manish Goregaokar
ee24bddfc5 Rollup merge of #30320 - nrc:err-names, r=@nikomatsakis
We can now handle name resolution errors and get past type checking (if we're a bit lucky). This is the first step towards doing code completion for partial programs (we need error recovery in the parser and early access to save-analysis).
2015-12-16 17:46:29 +05:30
Geoffrey Thomas
cec2d144a1 Pass --enable-new-dtags to GNU ld
This causes the linker to emit DT_RUNPATH instead of DT_RPATH, which
fixes #30378.
2015-12-15 21:20:44 -05:00
Jake Worth
2a1efca2f3 Fix typo 2015-12-15 12:51:08 -06:00
Simonas Kazlauskas
b3720ea933 Implement translation for ConstVal::{Array,Repeat} 2015-12-15 12:25:09 +02:00
Simonas Kazlauskas
a5e7a61c49 Implement references to functions and constants 2015-12-15 12:25:05 +02:00
bors
9e63cecb10 Auto merge of #30233 - retep998:where-in-the-world-is-windows-sdk, r=alexcrichton
What I've done here is try to make the code match what vcvars does much more closely. It now chooses which SDK to find based on the version of MSVC that it found. It also bases the decision of whether to find all the things on whether `VCINSTALLDIR` has been set, which is more likely to have only been set by an invocation of vcvars, unlike previously where it would do some things only if `LIB` wasn't set even though there was a valid use case for libraries to add themselves to `LIB` without having invoked vcvars.

There are still some debug `println!`s so people can test the PR and make sure it works correctly on various setups.

It supports VS 2015, 2013, and 2012. People who want to use versions of VS older (or newer) than that will have to manually invoke the appropriate vcvars bat file to set the proper environment variables themselves.

Do not merge yet.

Fixes https://github.com/rust-lang/rust/issues/30229
2015-12-15 04:21:53 +00:00
bors
8f031bf962 Auto merge of #30105 - faineance:master, r=nrc
Issue: #30058
Updated for:
 - Stmt
 - BinOp_
 - UnOp
 - UintTy, IntTy and FloatTy
 - Lit
 - Generics

A possible inconsistancy?
The `Stmt` methods are on the spanned varient:
```rust
pub type Stmt = Spanned<Stmt_>;

impl Stmt {
    pub fn id(s: &Stmt) -> Option<NodeId> {
        match s.node {
          StmtDecl(_, id) => Some(id),
          StmtExpr(_, id) => Some(id),
          StmtSemi(_, id) => Some(id),
          StmtMac(..) => None,
      }
  }
}
```
Whilst the methods for BinOp are on the non spanned version.
````rust
impl BinOp_ {
    pub fn to_string(op: BinOp_) -> &'static str { ... }
    pub fn lazy(b: BinOp_) -> bool { ... }

    pub fn is_shift(b: BinOp_) -> bool { ... }
    pub fn is_comparison(b: BinOp_) -> bool { ... }
    /// Returns `true` if the binary operator takes its arguments by value
    pub fn is_by_value(b: BinOp_) -> bool { ... }

}
pub type BinOp = Spanned<BinOp_>;
````
r? @Manishearth
2015-12-15 01:18:01 +00:00
Wesley Wiser
2b15361298 Implement trans for the MIR Switch terminator
Fixes #29574
2015-12-14 19:00:10 -05:00
Peter Atashian
915cb376e9 Overhaul MSVC linker and Windows SDK detection code
Fixes https://github.com/rust-lang/rust/issues/30229

Signed-off-by: Peter Atashian <retep998@gmail.com>
2015-12-14 18:04:35 -05:00
faineance
ec8ea22c7f [breaking-change] move ast_util functions to methods 2015-12-14 21:15:01 +00:00
bors
f150c178ea Auto merge of #27937 - DiamondLovesYou:llvm-root-and-shared, r=alexcrichton
This handles cases when the LLVM used isn't configured will the 'usual' targets. Also, cases where LLVM is shared are also handled (ie with `LD_LIBRARY_PATH` etc).
2015-12-14 19:14:37 +00:00
bors
50a02b43ba Auto merge of #29735 - Amanieu:asm_indirect_constraint, r=pnkfelix
This PR reverts #29543 and instead implements proper support for "=*m" and "+*m" indirect output operands. This provides a framework on top of which support for plain memory operands ("m", "=m" and "+m") can be implemented.

This also fixes the liveness analysis pass not handling read/write operands correctly.
2015-12-14 13:48:41 +00:00
Richard Diamond
7bd69f2248 Better support for --llvm-root.
This handles cases when the LLVM used isn't configured will the 'usual'
targets. Also, cases where LLVM is shared are also handled (ie with
`LD_LIBRARY_PATH` etc).
2015-12-13 15:05:43 -06:00
bors
45a73c8c0c Auto merge of #30110 - oli-obk:pretty_const_trans, r=pnkfelix
turned some `match`es into `if let`s.
2015-12-12 14:35:43 +00:00
bors
e583ab6281 Auto merge of #30279 - Aatch:dst-ref-binding, r=pnkfelix
We shouldn't load DSTs when recursing into the sub-pattern of `& ref ident`.

Fixes #30277
2015-12-12 11:01:12 +00:00
bors
81dd3824ff Auto merge of #30265 - oli-obk:const_val_trans, r=pnkfelix
r? @nagisa

I'm going to need the `ConstVal` -> `ValueRef` translation to start removing trans/consts piece by piece. If you need anything implemented in the translation, feel free to assign an issue to me.
2015-12-11 08:12:41 +00:00
Nick Cameron
18b4fe0e3e Make name resolution errors non-fatal 2015-12-11 21:00:15 +13:00
Michael Woerister
5addc31adb Make MIR encodable and store it in crate metadata. 2015-12-10 16:59:31 -05:00
Michael Woerister
70398d5ad0 MIR: Make Mir take ownership of InlineAsm values. 2015-12-10 16:39:17 -05:00
Michael Woerister
33d29700b3 MIR: Refactor mir::Terminator to use tuples instead of a fixed-size arrays. 2015-12-10 15:46:40 -05:00
James Miller
93154dd29c Fix & ref ident patterns for DSTs
We shouldn't load DSTs when recursing into the sub-pattern of `& ref ident`.

Fixes #30277
2015-12-10 00:35:55 +13:00
bors
4005d43765 Auto merge of #30245 - Aatch:dynamic-align-dst, r=pnkfelix
Fixes #26403

This adjusts the pointer, if needed, to the correct alignment by using the alignment information in the vtable.

Handling zero might not be necessary, as it shouldn't actually occur. I've left it as it's own commit so it can be removed fairly easily if people don't think it's worth doing. The way it's handled though means that there shouldn't be much impact on performance.
2015-12-09 04:22:05 +00:00
bors
462ec05764 Auto merge of #30145 - petrochenkov:hyg, r=nrc
Instead of `ast::Ident`, bindings, paths and labels in HIR now keep a new structure called `hir::Ident` containing mtwt-renamed `name` and the original not-renamed `unhygienic_name`. `name` is supposed to be used by default, `unhygienic_name` is rarely used.

This is not ideal, but better than the status quo for two reasons:
- MTWT tables can be cleared immediately after lowering to HIR
- This is less bug-prone, because it is impossible now to forget applying `mtwt::resolve` to a name. It is still possible to use `name` instead of `unhygienic_name` by mistake, but `unhygienic_name`s are used only in few very special circumstances, so it shouldn't be a problem.

Besides name resolution `unhygienic_name` is used in some lints and debuginfo. `unhygienic_name` can be very well approximated by "reverse renaming" `token::intern(name.as_str())` or even plain string `name.as_str()`, except that it would break gensyms like `iter` in desugared `for` loops. This approximation is likely good enough for lints and debuginfo, but not for name resolution, unfortunately (see https://github.com/rust-lang/rust/issues/27639), so `unhygienic_name` has to be kept.

cc https://github.com/rust-lang/rust/issues/29782

r? @nrc
2015-12-09 00:41:26 +00:00
Oliver Schneider
b85311506d prettify some statements 2015-12-08 16:00:35 +01:00
Oliver Schneider
9a63bb6661 move ConstVal -> ValueRef translation to trans::consts 2015-12-08 14:59:45 +01:00
James Miller
d6eb063fe8 Fix unsized structs with destructors
The presence of the drop flag caused the offset calculation to be
incorrect, leading to the pointer being incorrect. This has been fixed
by calculating the offset based on the field index (and not assuming
that the field is always the last one).

However, I've also stopped the drop flag from being added to the end of
unsized structs to begin with. Since it's not actually accessed for
unsized structs, and isn't actually where we would say it is, this made
more sense.
2015-12-08 15:55:00 +13:00
bors
acf4e0be22 Auto merge of #30087 - petrochenkov:indi, r=nrc
I've measured the time/memory consumption before and after - the difference is lost in statistical noise, so it's mostly a code simplification.
Sizes of `enum`s are not affected.

r? @nrc

I wonder if AST/HIR visitors could run faster if `P`s are systematically removed (except for cases where they control `enum` sizes). Theoretically they should.
Remaining unnecessary `P`s can't be easily removed because many folders accept `P<X>`s as arguments, but these folders can be converted to accept `X`s instead without loss of efficiency.
When I have a mood for some mindless refactoring again, I'll probably try to convert the folders, remove remaining `P`s and measure again.
2015-12-07 22:28:45 +00:00
Vadim Petrochenkov
ca88e9c536 Remove some unnecessary indirection from HIR structures 2015-12-07 17:17:41 +03:00
James Miller
a2557d472e Align pointers to DST fields properly
DST fields, being of an unknown type, are not automatically aligned
properly, so a pointer to the field needs to be aligned using the
information in the vtable.

Fixes #26403 and a number of other DST-related bugs discovered while
implementing this.
2015-12-08 00:03:45 +13:00
Alex Crichton
464cdff102 std: Stabilize APIs for the 1.6 release
This commit is the standard API stabilization commit for the 1.6 release cycle.
The list of issues and APIs below have all been through their cycle-long FCP and
the libs team decisions are listed below

Stabilized APIs

* `Read::read_exact`
* `ErrorKind::UnexpectedEof` (renamed from `UnexpectedEOF`)
* libcore -- this was a bit of a nuanced stabilization, the crate itself is now
  marked as `#[stable]` and the methods appearing via traits for primitives like
  `char` and `str` are now also marked as stable. Note that the extension traits
  themeselves are marked as unstable as they're imported via the prelude. The
  `try!` macro was also moved from the standard library into libcore to have the
  same interface. Otherwise the functions all have copied stability from the
  standard library now.
* The `#![no_std]` attribute
* `fs::DirBuilder`
* `fs::DirBuilder::new`
* `fs::DirBuilder::recursive`
* `fs::DirBuilder::create`
* `os::unix::fs::DirBuilderExt`
* `os::unix::fs::DirBuilderExt::mode`
* `vec::Drain`
* `vec::Vec::drain`
* `string::Drain`
* `string::String::drain`
* `vec_deque::Drain`
* `vec_deque::VecDeque::drain`
* `collections::hash_map::Drain`
* `collections::hash_map::HashMap::drain`
* `collections::hash_set::Drain`
* `collections::hash_set::HashSet::drain`
* `collections::binary_heap::Drain`
* `collections::binary_heap::BinaryHeap::drain`
* `Vec::extend_from_slice` (renamed from `push_all`)
* `Mutex::get_mut`
* `Mutex::into_inner`
* `RwLock::get_mut`
* `RwLock::into_inner`
* `Iterator::min_by_key` (renamed from `min_by`)
* `Iterator::max_by_key` (renamed from `max_by`)

Deprecated APIs

* `ErrorKind::UnexpectedEOF` (renamed to `UnexpectedEof`)
* `OsString::from_bytes`
* `OsStr::to_cstring`
* `OsStr::to_bytes`
* `fs::walk_dir` and `fs::WalkDir`
* `path::Components::peek`
* `slice::bytes::MutableByteVector`
* `slice::bytes::copy_memory`
* `Vec::push_all` (renamed to `extend_from_slice`)
* `Duration::span`
* `IpAddr`
* `SocketAddr::ip`
* `Read::tee`
* `io::Tee`
* `Write::broadcast`
* `io::Broadcast`
* `Iterator::min_by` (renamed to `min_by_key`)
* `Iterator::max_by` (renamed to `max_by_key`)
* `net::lookup_addr`

New APIs (still unstable)

* `<[T]>::sort_by_key` (added to mirror `min_by_key`)

Closes #27585
Closes #27704
Closes #27707
Closes #27710
Closes #27711
Closes #27727
Closes #27740
Closes #27744
Closes #27799
Closes #27801
cc #27801 (doesn't close as `Chars` is still unstable)
Closes #28968
2015-12-05 15:09:44 -08:00
Amanieu d'Antras
65707dfc00 Use a struct instead of a tuple for inline asm output operands 2015-12-05 10:11:20 +00:00
Amanieu d'Antras
9d7b113b44 Add proper support for indirect output constraints in inline asm 2015-12-05 08:18:30 +00:00
Vadim Petrochenkov
eb789de803 Do MTWT resolution during lowering to HIR 2015-12-05 00:40:21 +03:00
Tobias Bucher
57dad535f5 s/isize/i32 2015-12-02 09:06:28 +00:00
Steve Klabnik
8fd7f1e614 Rollup merge of #30136 - fhahn:remove-int-from-doc-examples, r=steveklabnik
This PR replaces uses of int/uint in some doc examples in various crates.
2015-12-01 19:01:41 -05:00
Florian Hahn
e48030d7d1 Replace uses of int/uint with isize/uzsize in doc examples 2015-12-01 21:21:45 +01:00
bors
eb1d018c01 Auto merge of #25570 - oli-obk:const_indexing, r=nikomatsakis
This PR allows the constant evaluation of index operations on constant arrays and repeat expressions. This allows index expressions to appear in the expression path of the length expression of a repeat expression or an array type.

An example is

```rust
const ARR: [usize; 5] = [1, 2, 3, 4, 5];
const ARR2: [usize; ARR[1]] = [42, 99];
```

In most other locations llvm's const evaluator figures it out already. This is not specific to index expressions and could be remedied in the future.
2015-12-01 19:47:38 +00:00
Michael Woerister
f28a4e93b4 Also move the MIR visitor to librustc. 2015-11-30 10:03:33 +01:00
Michael Woerister
bbe1d28496 Move the core MIR datastructures to librustc.
This is done mostly so that we can refer to MIR types in csearch and other metadata related area.
2015-11-30 10:03:33 +01:00
bors
e9ac44026d Auto merge of #29383 - petrochenkov:empstr, r=pnkfelix
Fixes https://github.com/rust-lang/rust/issues/28692
Fixes https://github.com/rust-lang/rust/issues/28992
Fixes some other similar issues (see the tests)

[breaking-change], needs crater run (cc @brson or @alexcrichton )

The pattern with parens `UnitVariant(..)` for unit variants seems to be popular in rustc (see the second commit), but mostly used by one person (@nikomatsakis), according to git blame. If it causes breakage on crates.io I'll add an exceptional case for it.
2015-11-28 00:45:34 +00:00
bors
1727dee167 Auto merge of #30077 - nrc:save-abs-crate, r=eddyb 2015-11-26 22:04:06 +00:00
Ariel Ben-Yehuda
0a8bb4c509 split the metadata code into rustc_metadata
tests & rustdoc still broken
2015-11-26 18:22:40 +02:00
Ariel Ben-Yehuda
d45dd9423e make CrateStore a trait object
rustdoc still broken
2015-11-26 18:21:17 +02:00
Ariel Ben-Yehuda
11dbb69bd1 remove csearch from the rest of rustc 2015-11-26 18:21:17 +02:00
Nick Cameron
befa29e0dc save-analysis: use absolute paths for file names 2015-11-26 18:05:32 +13:00
Vadim Petrochenkov
be8ace8cac Remove all uses of #[staged_api] 2015-11-25 21:55:26 +03:00
bors
edf2198f5f Auto merge of #30034 - brson:rust_path, r=alexcrichton
This was to support rustpkg but is unused now.
2015-11-25 08:14:39 +00:00
Brian Anderson
1b7b2fe36b Remove RUST_PATH from compiler
This was to support rustpkg but is unused now.
2015-11-24 19:37:40 +00:00
Michael Woerister
3be1d8ca7d Avoid some code duplication around getting names of numeric types. 2015-11-23 15:59:36 +01:00
Manish Goregaokar
352853c18b Register diagnostics for rustc_privacy and rustc_trans properly
fixes #29665
2015-11-22 10:26:22 +05:30
bors
eb19d024a9 Auto merge of #29963 - dotdash:fat_copy, r=eddyb
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-11-21 22:08:26 +00:00
Björn Steinbrink
6741f3315a Avoid FCA loads and extractvalue when copying fat pointers
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-11-20 21:42:13 +01:00
bors
20cbba71d4 Auto merge of #29945 - nrc:save-crate-name, r=alexcrichton
r? @alexcrichton

This prevents outputting csv files with the same name and thus overwriting each other when indexing Cargo projects with a bin crate (and some other cases).
2015-11-20 20:03:16 +00:00
bors
2228bacd62 Auto merge of #29943 - brson:inline-threshold, r=nrc
Corresponds directly to llvm's inline-threshold.

I want this so I can experiment out-of-tree with tweaking optimization settings, and this is the most important value that isn't exposed. I can't get it to work either via `-C llvm-args`.

cc @rust-lang/compiler
2015-11-20 05:09:24 +00:00
Nick Cameron
de8467cf42 save-analysis: make the dump file's name closer to the crate file's name 2015-11-20 15:44:53 +13:00
Brian Anderson
5c88a1cd54 Add -C inline-threshold
Corresponds directly to llvm's inline-threshold
2015-11-19 17:01:07 -08:00
Brian Anderson
99741700e5 Remove segmented stack option from LLVMRustCreateTargetMachine. Unused. 2015-11-19 16:58:23 -08:00
Ms2ger
83b636930d Avoid a string allocation. 2015-11-19 12:37:13 +01:00
Ms2ger
3ccef0fdc5 Rustfmt trans/base.rs. 2015-11-19 12:36:31 +01:00
Vadim Petrochenkov
35749923ee Fix the fallout 2015-11-19 11:41:09 +03:00
Niko Matsakis
06f2d9da87 Modify trans to use an outer walk and ensure that we rotate as we
encounter each module. This is somewhat different than how it used to
work; it should ensure a more equitable distribution of work than
before. The reason is that, before, when we rotated, we would rotate
before we had seen the full contents of the current module. So e.g.  if
we have `mod a { mod b { .. } .. }`, then we rotate when we encounter
`b`, but we haven't processed the remainder of `a` yet. Unclear if this
makes any difference in practice, but it seemed suboptimal. Also, this
structure (with an outer walk over modules) is closer to what we will
want for an incremental setting.
2015-11-18 19:23:29 -05:00
Niko Matsakis
1e941f8e97 Port trans to use visit_all_items: this was mostly straight-forward, but
noteworthy because trans got mildly simpler, since it doesn't have to
ensure that we walk the contents of all things just to find all the
hidden items.
2015-11-18 19:23:29 -05:00
Michael Woerister
c533902285 MIR: Add pass that erases all regions right before trans 2015-11-18 17:26:24 +01:00
Oliver Schneider
6683fa4d42 allow indexing into constant arrays 2015-11-18 10:57:52 +01:00
Oliver Schneider
d09220de13 rename ast::ImplItem_::*ImplItem to ast::ImplItemKind::* 2015-11-16 10:35:30 +01:00
Oliver Schneider
e36872da5b ImplItem_ -> ImplItemKind rename 2015-11-16 10:35:30 +01:00
Oliver Schneider
eaaa60dbea rename ImplItem_::*ImplItem to ImplItem_::*
[breaking change]
2015-11-16 10:34:45 +01:00
Eli Friedman
82ab7079dd Consistently normalize fn types after erasing lifetimes.
Fixes #23406.
Fixes #23958.
Fixes #29832.
2015-11-14 14:47:49 -08:00
Ariel Ben-Yehuda
b9b45a0e96 address review comments 2015-11-14 00:09:36 +02:00
Ariel Ben-Yehuda
e82f5d4f54 implement coercions in MIR 2015-11-14 00:09:36 +02:00
Ariel Ben-Yehuda
c1bfd0ca6b implement lvalue_len
no tests - sorry
2015-11-13 22:47:02 +02:00
Ariel Ben-Yehuda
dcb64b52a2 represent fat ptr operands as 2 separate pointers
this does add some complexity, but to do otherwise would require unsized
lvalues to have their own allocas, which would be ugly.
2015-11-13 22:47:02 +02:00
Ariel Ben-Yehuda
602cf7ec3c MIR: implement fat raw pointer comparisons
The implementation itself only requires changes to trans, but
a few additional bugs concerning the handling of fat pointers
had to be fixed.
2015-11-13 22:47:02 +02:00
bors
3beb159809 Auto merge of #29759 - nagisa:mir-static, r=nikomatsakis
Fixes #29578

r? @nikomatsakis

My own observations are posted inline as comments.
2015-11-13 17:10:25 +00:00
bors
35decad781 Auto merge of #29616 - nagisa:mir-repeat, r=nikomatsakis
r? @nikomatsakis

I went ahead and replaced repeat count with a `Constant`, because it cannot be non-constant to the best of my knowledge.
2015-11-12 02:24:06 +00:00
Vadim Petrochenkov
fba1926a2f Fix hygiene regression in patterns 2015-11-12 01:49:23 +03:00
Simonas Kazlauskas
f1342ffb3c Simplify trans/exprs.rs DefStatic considerably 2015-11-11 00:42:09 +02:00
Simonas Kazlauskas
21deb18bfd [MIR trans] Translate statics
Fixes #29578
2015-11-11 00:15:16 +02:00
Simonas Kazlauskas
db89a75a80 use Constant for repetition count in mir::Repeat 2015-11-10 23:52:23 +02:00
bors
e9aa32ac72 Auto merge of #29697 - dotdash:mir_trans_switchint, r=nikomatsakis 2015-11-10 13:17:15 +00:00
Alex Crichton
3d28b8b98e std: Migrate to the new libc
* Delete `sys::unix::{c, sync}` as these are now all folded into libc itself
* Update all references to use `libc` as a result.
* Update all references to the new flat namespace.
* Moves all windows bindings into sys::c
2015-11-09 22:55:50 -08:00
Björn Steinbrink
b0d7338d6d [MIR trans] Add support for SwitchInt 2015-11-09 16:54:58 +01:00
arcnmx
892b50ba74 Preserve public static items across LTO 2015-11-06 05:04:43 -05:00
bors
98fa2ac1bc Auto merge of #29588 - nikomatsakis:mir-switch, r=aatch
Introduce a `SwitchInt` and restructure pattern matching to collect integers and characters into one master switch. This is aimed at #29227, but is not a complete fix. Whereas before we generated an if-else-if chain and, at least on my machine, just failed to compile, we now spend ~9sec compiling `rustc_abuse`. AFAICT this is basically just due to a need for more micro-optimization of the matching process: perf shows a fair amount of time just spent iterating over the candidate list. Still, it seemed worth opening a PR with this step alone, since it's a big step forward.
2015-11-06 06:13:59 +00:00
bors
96c95f160f Auto merge of #29583 - dotdash:mir_small_agg, r=nikomatsakis
Fix handling of small aggregate function arguments and assignments of temporaries to lvalues.
2015-11-05 20:06:13 +00:00
Björn Steinbrink
3235b22ee3 Fix handling of fat pointer function arguments
The store for the "extra" data went to the wrong destination.
2015-11-05 16:18:45 +01:00
Simonas Kazlauskas
cba6561de2 Translate MIR Repeat (arrays) 2015-11-05 17:17:47 +02:00
Jonathan S
b1788ef8e1 Remove use of RefCell<DefMap> in the simpler parts of pat_util 2015-11-04 20:38:03 -06:00
Jonathan S
8a69a00941 Unwrap the RefCell around DefMap 2015-11-04 20:38:03 -06:00
Niko Matsakis
3e6b4545f9 Introduce a SwitchInt and restructure pattern matching to collect
integers and characters into one master switch.
2015-11-04 15:38:43 -05:00
Björn Steinbrink
5a35f498f3 [MIR-trans] Fix handling of non-alloca temps in trans_operand_into() 2015-11-04 19:30:04 +01:00
Björn Steinbrink
fe3a609b0b [MIR-trans] Fix handling of small aggregate arguments
Function arguments that are small aggregates get passed as integer types
instead. To correctly handle that, we need to use store_ty instead of
plain Store.
2015-11-04 16:20:23 +01:00
bors
1ad89e0de6 Auto merge of #29550 - nrc:save-root, r=alexcrichton 2015-11-04 08:39:44 +00:00
Niko Matsakis
e78786315b remove unused import 2015-11-03 20:38:02 -05:00
Niko Matsakis
b46c0fc497 address nits from dotdash 2015-11-03 18:00:35 -05:00
Niko Matsakis
9c9f4be9df correct typos 2015-11-03 18:00:30 -05:00
Niko Matsakis
6a5b263503 Add (and use) an analysis to determine which temps can forgo an alloca. 2015-11-03 18:00:30 -05:00
Nick Cameron
6252af9ce1 save-analysis: emit the crate root 2015-11-04 10:16:06 +13:00
Niko Matsakis
e84829d51d Plumbing to omit allocas for temps when possible (currently unused) 2015-11-03 04:35:00 -05:00
Niko Matsakis
02017b30eb New trans codepath that builds fn body from MIR instead. 2015-11-03 04:35:00 -05:00
Niko Matsakis
877b93add2 Move shifting code out of expr and into somewhere more accessible 2015-11-03 04:35:00 -05:00
Niko Matsakis
81ff2c2f8e Change adt case handling fn to be less tied to match 2015-11-03 04:35:00 -05:00
Niko Matsakis
3c07b46118 Pass the mir map to trans 2015-11-03 04:34:59 -05:00