summary refs log tree commit diff
path: root/src/librustc_trans
AgeCommit message (Collapse)AuthorLines
2016-01-19Auto merge of #30845 - nagisa:mir-extern-calls, r=dotdashbors-13/+51
Supersedes https://github.com/rust-lang/rust/pull/30517 Fixes https://github.com/rust-lang/rust/issues/29575 cc @luqmana r? @nikomatsakis
2016-01-19[MIR] Implement extern call supportSimonas Kazlauskas-13/+51
2016-01-18revert using `trans::Disr` in `LoadRangeAssert`Oliver Schneider-10/+8
it makes no sense here, accidentally introduced in #30931
2016-01-17Auto merge of #30975 - Manishearth:rollup, r=Manishearthbors-10/+6
- Successful merges: #30938, #30940, #30943, #30949, #30952, #30957, #30959 - Failed merges:
2016-01-17Rollup merge of #30943 - alexcrichton:stabilize-1.7, r=aturonManish Goregaokar-5/+3
This commit stabilizes and deprecates the FCP (final comment period) APIs for the upcoming 1.7 beta release. The specific APIs which changed were: Stabilized * `Path::strip_prefix` (renamed from `relative_from`) * `path::StripPrefixError` (new error type returned from `strip_prefix`) * `Ipv4Addr::is_loopback` * `Ipv4Addr::is_private` * `Ipv4Addr::is_link_local` * `Ipv4Addr::is_multicast` * `Ipv4Addr::is_broadcast` * `Ipv4Addr::is_documentation` * `Ipv6Addr::is_unspecified` * `Ipv6Addr::is_loopback` * `Ipv6Addr::is_unique_local` * `Ipv6Addr::is_multicast` * `Vec::as_slice` * `Vec::as_mut_slice` * `String::as_str` * `String::as_mut_str` * `<[T]>::clone_from_slice` - the `usize` return value is removed * `<[T]>::sort_by_key` * `i32::checked_rem` (and other signed types) * `i32::checked_neg` (and other signed types) * `i32::checked_shl` (and other signed types) * `i32::checked_shr` (and other signed types) * `i32::saturating_mul` (and other signed types) * `i32::overflowing_add` (and other signed types) * `i32::overflowing_sub` (and other signed types) * `i32::overflowing_mul` (and other signed types) * `i32::overflowing_div` (and other signed types) * `i32::overflowing_rem` (and other signed types) * `i32::overflowing_neg` (and other signed types) * `i32::overflowing_shl` (and other signed types) * `i32::overflowing_shr` (and other signed types) * `u32::checked_rem` (and other unsigned types) * `u32::checked_shl` (and other unsigned types) * `u32::saturating_mul` (and other unsigned types) * `u32::overflowing_add` (and other unsigned types) * `u32::overflowing_sub` (and other unsigned types) * `u32::overflowing_mul` (and other unsigned types) * `u32::overflowing_div` (and other unsigned types) * `u32::overflowing_rem` (and other unsigned types) * `u32::overflowing_neg` (and other unsigned types) * `u32::overflowing_shl` (and other unsigned types) * `u32::overflowing_shr` (and other unsigned types) * `ffi::IntoStringError` * `CString::into_string` * `CString::into_bytes` * `CString::into_bytes_with_nul` * `From<CString> for Vec<u8>` * `From<CString> for Vec<u8>` * `IntoStringError::into_cstring` * `IntoStringError::utf8_error` * `Error for IntoStringError` Deprecated * `Path::relative_from` - renamed to `strip_prefix` * `Path::prefix` - use `components().next()` instead * `os::unix::fs` constants - moved to the `libc` crate * `fmt::{radix, Radix, RadixFmt}` - not used enough to stabilize * `IntoCow` - conflicts with `Into` and may come back later * `i32::{BITS, BYTES}` (and other integers) - not pulling their weight * `DebugTuple::formatter` - will be removed * `sync::Semaphore` - not used enough and confused with system semaphores Closes #23284 cc #27709 (still lots more methods though) Closes #27712 Closes #27722 Closes #27728 Closes #27735 Closes #27729 Closes #27755 Closes #27782 Closes #27798
2016-01-17Rollup merge of #30938 - dotdash:zst_void, r=eddybManish Goregaokar-5/+3
The only way to get a value for a zero-sized type is `undef`, so there's really no point in actually having a return type other than void for such types. Also, while the comment in return_type_is_void mentioned something about aiding C ABI support, @eddyb correctly pointed out on IRC that there is no such thing as a zero-sized type in C. And even with clang, which allows empty structs, those get translated as void return types as well. Fixes #28766
2016-01-17Auto merge of #30931 - oli-obk:trans_disr_newtype, r=arielb1bors-100/+172
This is groundwork for #30587 (typestrong constant integrals), but imo it's a change that in itself is good, too, since we don't just juggle `u64`s around anymore. `ty::Disr` will be changed to a `ConstInt` in #30587
2016-01-16Auto merge of #30567 - steffengy:master, r=alexcrichtonbors-1/+3
Add support to use functions exported using vectorcall. This essentially only allows to pass a new LLVM calling convention from rust to LLVM. ```rust extern "vectorcall" fn abc(param: c_void); ``` references ---- http://llvm.org/docs/doxygen/html/CallingConv_8h_source.html https://msdn.microsoft.com/en-us/library/dn375768.aspx
2016-01-16std: Stabilize APIs for the 1.7 releaseAlex Crichton-5/+3
This commit stabilizes and deprecates the FCP (final comment period) APIs for the upcoming 1.7 beta release. The specific APIs which changed were: Stabilized * `Path::strip_prefix` (renamed from `relative_from`) * `path::StripPrefixError` (new error type returned from `strip_prefix`) * `Ipv4Addr::is_loopback` * `Ipv4Addr::is_private` * `Ipv4Addr::is_link_local` * `Ipv4Addr::is_multicast` * `Ipv4Addr::is_broadcast` * `Ipv4Addr::is_documentation` * `Ipv6Addr::is_unspecified` * `Ipv6Addr::is_loopback` * `Ipv6Addr::is_unique_local` * `Ipv6Addr::is_multicast` * `Vec::as_slice` * `Vec::as_mut_slice` * `String::as_str` * `String::as_mut_str` * `<[T]>::clone_from_slice` - the `usize` return value is removed * `<[T]>::sort_by_key` * `i32::checked_rem` (and other signed types) * `i32::checked_neg` (and other signed types) * `i32::checked_shl` (and other signed types) * `i32::checked_shr` (and other signed types) * `i32::saturating_mul` (and other signed types) * `i32::overflowing_add` (and other signed types) * `i32::overflowing_sub` (and other signed types) * `i32::overflowing_mul` (and other signed types) * `i32::overflowing_div` (and other signed types) * `i32::overflowing_rem` (and other signed types) * `i32::overflowing_neg` (and other signed types) * `i32::overflowing_shl` (and other signed types) * `i32::overflowing_shr` (and other signed types) * `u32::checked_rem` (and other unsigned types) * `u32::checked_neg` (and other unsigned types) * `u32::checked_shl` (and other unsigned types) * `u32::saturating_mul` (and other unsigned types) * `u32::overflowing_add` (and other unsigned types) * `u32::overflowing_sub` (and other unsigned types) * `u32::overflowing_mul` (and other unsigned types) * `u32::overflowing_div` (and other unsigned types) * `u32::overflowing_rem` (and other unsigned types) * `u32::overflowing_neg` (and other unsigned types) * `u32::overflowing_shl` (and other unsigned types) * `u32::overflowing_shr` (and other unsigned types) * `ffi::IntoStringError` * `CString::into_string` * `CString::into_bytes` * `CString::into_bytes_with_nul` * `From<CString> for Vec<u8>` * `From<CString> for Vec<u8>` * `IntoStringError::into_cstring` * `IntoStringError::utf8_error` * `Error for IntoStringError` Deprecated * `Path::relative_from` - renamed to `strip_prefix` * `Path::prefix` - use `components().next()` instead * `os::unix::fs` constants - moved to the `libc` crate * `fmt::{radix, Radix, RadixFmt}` - not used enough to stabilize * `IntoCow` - conflicts with `Into` and may come back later * `i32::{BITS, BYTES}` (and other integers) - not pulling their weight * `DebugTuple::formatter` - will be removed * `sync::Semaphore` - not used enough and confused with system semaphores Closes #23284 cc #27709 (still lots more methods though) Closes #27712 Closes #27722 Closes #27728 Closes #27735 Closes #27729 Closes #27755 Closes #27782 Closes #27798
2016-01-16use a newtype for the variant discriminant instead of u64Oliver 'ker' Schneider-100/+172
2016-01-15Auto merge of #30446 - michaelwu:associated-const-type-params-pt1, ↵bors-10/+15
r=nikomatsakis This provides limited support for using associated consts on type parameters. It generally works on things that can be figured out at trans time. This doesn't work for array lengths or match arms. I have another patch to make it work in const expressions. CC @eddyb @nikomatsakis
2016-01-15Fix type retrieval for Switch translationSimonas Kazlauskas-5/+4
Previously it would go through def_id and retrieve a type that’s not always correct, monomorphized, etc.
2016-01-15Fix translation for all other discriminated ADTsSimonas Kazlauskas-4/+10
Again.
2016-01-15Translate zero-sized return types as voidBjörn Steinbrink-5/+3
The only way to get a value for a zero-sized type is `undef`, so there's really no point in actually having a return type other than void for such types. Also, while the comment in return_type_is_void mentioned something about aiding C ABI support, @eddyb correctly pointed out on IRC that there is no such thing as a zero-sized type in C. And even with clang, which allows empty structs, those get translated as void return types as well. Fixes #28766
2016-01-15Rollup merge of #30776 - antonblanchard:powerpc64_merge, r=alexcrichtonManish Goregaokar-0/+262
This adds support for big endian and little endian PowerPC64. make check runs clean apart from one big endian backtrace issue.
2016-01-15Auto merge of #30711 - nrc:json-errs, r=huonwbors-15/+15
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-14Support generic associated constsMichael Wu-10/+15
2016-01-15Add an --output option for specifying an error emitterNick Cameron-15/+15
2016-01-14Revert "Link with ld.gold by default"Brian Anderson-55/+0
This reverts commit 34dc0e0739e19811850f82f1e45b61ba97adc96e.
2016-01-14Auto merge of #30848 - nagisa:mir-no-store-zsts, r=nikomatsakisbors-5/+14
Fixes #30831 r? @nikomatsakis
2016-01-14Rollup merge of #30851 - jonas-schievink:unneeded-dropflags, r=pnkfelixManish Goregaokar-5/+16
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-13add doc for new `fn alloc_ty_init`.Felix S. Klock II-0/+12
(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-13revise lifetime handling for alloca's that are initialized as "dropped."Felix S. Klock II-1/+10
(This can/should be revisited when drop flags are stored out of band.)
2016-01-13Factored out private routine for emitting LLVM lifetime intrinsic calls.Felix S. Klock II-30/+45
(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-13bug fixes for issues 30018 and 30822.Felix S. Klock II-4/+11
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-13Add powerpc64 and powerpc64le supportAnton Blanchard-0/+262
This adds support for big endian and little endian PowerPC64. make check runs clean apart from one big endian backtrace issue.
2016-01-12[MIR] Avoid some code generation for stores of ZSTSimonas Kazlauskas-5/+14
Fixes #30831
2016-01-12Don't use dropflag hints when the type is droplessJonas Schievink-5/+16
2016-01-12debug instrumentation (can remove)Felix S. Klock II-3/+31
2016-01-12Issue 30530: initialize allocas for `Datum::to_lvalue_datum_in_scope`.Felix S. Klock II-6/+70
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-11Rollup merge of #30774 - nagisa:mir-fix-constval-adts, r=arielb1Simonas Kazlauskas-10/+5
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-08Change destination accessor to return referencesSimonas Kazlauskas-1/+1
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[MIR] Fix translation of ConstVal::{Struct, Tuple}Simonas Kazlauskas-10/+5
Fixes #30772
2016-01-07Auto merge of #30317 - jseyfried:refactor_type_folder, r=nikomatsakisbors-14/+14
`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-07Auto merge of #30724 - nikomatsakis:feature-gate-defaulted-type-parameters, ↵bors-0/+1
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-07Refactor away extension traits RegionEscape and HasTypeFlagsJeffrey Seyfried-11/+11
2016-01-07Create a visitor for `TypeFoldable`s and use it to implement RegionEscape ↵Jeffrey Seyfried-3/+3
and HasTypeFlags (fixes #20298)
2016-01-06Auto merge of #30532 - nikomatsakis:cross-item-dependencies, r=mwbors-6/+465
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-06Create personality slot when translating ResumeSimonas Kazlauskas-38/+26
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-06Merge Call and DivergingCall diffs into CallKindSimonas Kazlauskas-75/+96
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-06Don’t generate landing-pads if -Z no-landing-padsSimonas Kazlauskas-30/+55
2016-01-06Fix ReturnPointer generation for void return typesSimonas Kazlauskas-4/+19
Fixes #30480
2016-01-06Refine call terminator translationSimonas Kazlauskas-45/+96
* Implement landing pads; and * Implement DivergingCall translation; and * Modernise previous implementation of Call somewhat.
2016-01-06Have a cached unreachable block inside MIR stateSimonas Kazlauskas-6/+23
It is useful for various cases where direct unreachable cannot be translated and a separate block is necessary.
2016-01-06Remove diverge terminatorSimonas Kazlauskas-15/+6
Unreachable terminator can be contained all within the trans.
2016-01-06Remove the Panic block terminatorSimonas Kazlauskas-4/+0
2016-01-06Add Resume Terminator which corresponds to resumeSimonas Kazlauskas-5/+5
Diverge should eventually go away
2016-01-06Split Call into Call and DivergingCallSimonas Kazlauskas-0/+4
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-06Auto merge of #30692 - michaelwoerister:mir-overloaded-fn-calls, r=nikomatsakisbors-3/+31
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-05Add assert-dep-graph testing mechanism and testsNiko Matsakis-0/+435