about summary refs log tree commit diff
path: root/src/librustc_codegen_llvm
AgeCommit message (Collapse)AuthorLines
2018-11-10codegen_llvm_back: simplify a conversion to charljedrz-1/+1
2018-11-10codegen_llvm_back: remove a redundant continueljedrz-1/+0
2018-11-10codegen_llvm_back: possible minor speedup in logicljedrz-1/+1
2018-11-10codegen_llvm_back: remove 'static from constsljedrz-3/+3
2018-11-10codegen_llvm_back: use to_owned instead of to_string with string literalsljedrz-4/+4
2018-11-10codegen_llvm_back: improve common patternsljedrz-46/+23
2018-11-10codegen_llvm_back: remove explicit returnsljedrz-12/+15
2018-11-10codegen_llvm_back: use Cow<'static, str> where applicableljedrz-22/+21
2018-11-10codegen_llvm_back: whitespace & formatting fixesljedrz-50/+43
2018-11-10Auto merge of #55626 - nikic:update-emscripten, r=alexcrichtonbors-1/+2
Update emscripten This updates emscripten to 1.38.15, which is based on LLVM 6.0.1 and would allow us to drop code for handling LLVM 4. The main issue I ran into is that exporting statics through `EXPORTED_FUNCTIONS` no longer works. As far as I understand exporting non-functions doesn't really make sense under emscripten anyway, so I've modified the symbol export code to not even try. Closes #52323.
2018-11-08Rollup merge of #55633 - nikic:memcpy-align, r=nagisaMark Rousskov-47/+60
Support memcpy/memmove with differing src/dst alignment If LLVM 7 is used, generate memcpy/memmove with differing src/dst alignment. I've added new FFI functions to construct these through the builder API, which is more convenient than dealing with differing intrinsic signatures depending on the LLVM version. Fixes #49740.
2018-11-08Support for the program data address space optionTim Neumann-3/+13
of LLVM's Target Datalayout. https://llvm.org/docs/LangRef.html#data-layout
2018-11-08Disable wasm32 features on emscriptenNikita Popov-1/+2
These are only supported by the native wasm32 backend.
2018-11-08Allow unsized types in mem::drop and mem::forgetStjepan Glavina-1/+1
2018-11-07no more action on ref or cast, but add new MIR statement for escaping a ptr ↵Ralf Jung-1/+2
to raw
2018-11-07Rollup merge of #55734 - teresy:shorthand-fields, r=davidtwcokennytm-2/+2
refactor: use shorthand fields refactor: use shorthand for single fields everywhere (excluding tests).
2018-11-07Rollup merge of #55609 - nikic:fix-51947, r=nagisakennytm-2/+13
Run name-anon-globals after LTO passes as well If we're going to emit bitcode (through ThinLTOBuffer), then we need to ensure that anon globals are named. This was already done after optimization passes, but also has to happen after LTO passes, as we always emit the final result in a ThinLTO-compatible manner. I added the test as `run-make`. The important bit is that we emit bitcode in some way (e.g. `--crate-type rlib` or `--emit=llvm-bc`). Please tell me if there is a better way to test for that. Fixes #51947
2018-11-06refactor: use shorthand fieldsteresy-2/+2
2018-11-06Run name-anon-globals after LTO passes as wellNikita Popov-2/+13
If we're going to emit bitcode (through ThinLTOBuffer), then we need to ensure that anon globals are named. This was already done after optimization passes, but also has to happen after LTO passes, as we always emit the final result in a ThinLTO-compatible manner. Fixes #51947.
2018-11-05Auto merge of #55410 - nagisa:atomic-align, r=pnkfelixbors-13/+10
Correct alignment of atomic types and (re)add Atomic{I,U}128 This is a updated https://github.com/rust-lang/rust/pull/53514 to also make atomic types `repr(C)` as per comment in https://github.com/rust-lang/rust/pull/53514#issuecomment-431042767. Fixes #39590 Closes #53514 r? @pnkfelix
2018-11-05Fix emission of niche-filling discriminant valuesTom Tromey-4/+4
Bug #55606 points out a regression introduced by #54004; namely that an assertion can erroneously fire when a niche-filling discriminant value is emitted. This fixes the bug by removing the assertion, and furthermore by arranging for the discriminant value to be masked according to the size of the niche. This makes handling the discriminant a bit simpler for debuggers. The test case is from Jonathan Turner. Closes #55606
2018-11-05Remove support for building against LLVM 4Nikita Popov-59/+26
With emscripten removed in #55626, we no longer need to support building against LLVM 4.
2018-11-05Auto merge of #55593 - nikic:remove-llvm-4-checks, r=rkruppebors-32/+6
Remove checks for LLVM < 4.0 While we still have to support LLVM 4.0 for Emscripten, we can drop checks for LLVM >= 4.0 and < 4.0.
2018-11-04rustc_target: pass contexts by reference, not value.Eduard-Mihai Burtescu-9/+9
2018-11-04Support memcpy/memmove with differing src/dst alignmentNikita Popov-47/+60
If LLVM 7 is used, generate memcpy/memmove with differing src/dst alignment. I've added new FFI functions to construct these through the builder API, which is more convenient than dealing with differing intrinsic signatures depending on the LLVM version.
2018-11-04Auto merge of #55349 - bjorn3:rustc_mir_collect_and_partition_mono_items, ↵bors-1873/+20
r=oli-obk Move collect_and_partition_mono_items to rustc_mir Most of the logic of it is inside rustc_mir anyway. Also removes the single function crate rustc_metadata_utils. Based on #55225
2018-11-03Implement rotate using funnel shift on LLVM >= 7Nikita Popov-5/+45
Implement the rotate_left and rotate_right operations using llvm.fshl and llvm.fshr if they are available (LLVM >= 7). Originally I wanted to expose the funnel_shift_left and funnel_shift_right intrinsics and implement rotate_left and rotate_right on top of them. However, emulation of funnel shifts requires emitting a conditional to check for zero shift amount, which is not necessary for rotates. I was uncomfortable doing that here, as I don't want to rely on LLVM to optimize away that conditional (and for variable rotates, I'm not sure it can). We should revisit that question when we raise our minimum version requirement to LLVM 7 and don't need emulation code anymore.
2018-11-03Move collect_and_partition_mono_items to rustc_mirbjorn3-153/+6
2018-11-03Move cg_llvm::back::linker to cg_utilsbjorn3-1720/+14
2018-11-03Auto merge of #55330 - scalexm:bound-ty, r=nikomatsakisbors-3/+4
Add support for bound types This PR may have some slight performance impacts, I don't know how hot is the code I touched. Also, this breaks clippy and miri. r? @nikomatsakis
2018-11-03Rename `Binder::no_late_bound_regions` to `Binder::no_bound_vars`scalexm-1/+1
2018-11-03Shift both late bound regions and bound typesscalexm-2/+2
2018-11-03Move `BoundTy` to `ty::TyKind`scalexm-0/+1
2018-11-03Auto merge of #55238 - alexcrichton:rm-jemalloc, r=estebankbors-10/+104
Remove the `alloc_jemalloc` crate This commit removes the `alloc_jemalloc` crate from the standard library and all related configuration. We will no longer be shipping this unstable crate. Rationale for this is provided on https://github.com/rust-lang/rust/issues/36963 and the many linked issues, but I can inline rationale here if desired! We currently rely on jemalloc for increased perf in the Rust compiler, however. [This perf run shows](https://perf.rust-lang.org/compare.html?start=74ff7dcb1388e60a613cd6050bcd372a3cc4998b&end=7e7928dc0340d79b404e93f0c79eb4b946c1d669&stat=wall-time) that if we switch to glibc 2.23's allocator that it's slower than jemalloc across many benchmarks. [This perf run, however](https://perf.rust-lang.org/compare.html?start=22cc2ae8057d14e980b7c784e1eb2eee26b59e7d&end=10c95ccfa7a7adc12f4e608621ca29f9b98eed29), shows that if we use `jemalloc-sys` from crates.io then rustc actually gets faster across all benchmarks! (presumably because it has a more recent version of jemalloc than our submodule). As a result, it's expected that this doesn't regress any code (as it's just removing an unstable crate) and it should actually improve rustc performance because it updates jemalloc. Closes #36963
2018-11-03Auto merge of #54383 - mikeyhew:custom-receivers-object-safety, r=nikomatsakisbors-19/+79
Take 2: Implement object-safety and dynamic dispatch for arbitrary_self_types This replaces #50173. Over the months that that PR was open, we made a lot of changes to the way this was going to be implemented, and the long, meandering comment thread and commit history would have been confusing to people reading it in the future. So I decided to package everything up with new, straighforward commits and open a new PR. Here are the main points. Please read the commit messages for details. - To simplify codegen, we only support receivers that have the ABI of a pointer. That means they are builtin pointer types, or newtypes thereof. - We introduce a new trait: `DispatchFromDyn<T>`, similar to `CoerceUnsized<T>`. `DispatchFromDyn` has extra requirements that `CoerceUnsized` does not: when you implement `DispatchFromDyn` for a struct, there cannot be any extra fields besides the field being coerced and `PhantomData` fields. This ensures that the struct's ABI is the same as a pointer. - For a method's receiver (e.g. `self: Rc<Self>`) to be object-safe, it needs to have the following property: - let `DynReceiver` be the receiver when `Self = dyn Trait` - let `ConcreteReceiver` be the receiver when `Self = T`, where `T` is some unknown `Sized` type that implements `Trait`, and is the erased type of the trait object. - `ConcreteReceiver` must implement `DispatchFromDyn<DynReceiver>` In the case of `Rc<Self>`, this requires `Rc<T>: DispatchFromDyn<Rc<dyn Trait>>` These rules are explained more thoroughly in the doc comment on `receiver_is_dispatchable` in object_safety.rs. r? @nikomatsakis and @eddyb cc @arielb1 @cramertj @withoutboats Special thanks to @nikomatsakis for getting me un-stuck when implementing the object-safety checks, and @eddyb for helping with the codegen parts. EDIT 2018-11-01: updated because CoerceSized has been replaced with DispatchFromDyn
2018-11-02Auto merge of #55087 - levex:e0669-improve-span, r=nagisabors-8/+5
rustc: improve E0669 span E0669 refers to an operand that cannot be coerced into a single LLVM value, unfortunately right now this uses the Span for the entire inline assembly statement, which is less than ideal. This commit preserves the Span from HIR, which lets us emit the error using the Span for the operand itself in MIR. r? @nagisa cc/ @parched
2018-11-02rustc: Wait for all codegen threads to exitAlex Crichton-10/+104
This commit updates rustc to wait for all codegen threads to exit before allowing the main thread to exit. This is a stab in the dark to fix the mysterious segfaults appearing on #55238, and hopefully we'll see whether this actually fixes things in practice...
2018-11-02Auto merge of #55316 - RalfJung:retagging, r=oli-obkbors-2/+3
Add Retagging statements This adds a `Retag` statement kind to MIR, used to perform the retagging operation from [Stacked Borrows](https://www.ralfj.de/blog/2018/08/07/stacked-borrows.html). It also kills the old `Validate` statements that I added last year. NOTE: This includes https://github.com/rust-lang/rust/pull/55270. Only [these commits are new](https://github.com/RalfJung/rust/compare/stacked-borrows-ng...RalfJung:retagging).
2018-11-01Add comments explaining how codegen works for `dyn Trait` methodsMichael Hewson-2/+11
2018-11-01Implement object-safety for arbitrary_self_types: part 2Michael Hewson-19/+70
For now, all of the receivers that we care about are just a newtyped pointer — i.e. `Box<Self>`, `Rc<Self>`, `Pin<Box<Self>>`, `Pin<&mut Self>`. This is much simpler to implement in codeine than the more general case, because the ABI is the same as a pointer. So we add some checks in typeck/coherence/builtin.rs to make sure that implementors of CoerceSized are just newtyped pointers. In this commit, we also implement the codegen bits.
2018-11-01Remove checks for LLVM < 4.0Nikita Popov-32/+6
While we still have to support LLVM 4.0 for Emscripten, we can drop checks for LLVM >= 4.0 and < 4.0.
2018-10-30Avoid possible integer overflow in niche value computationTom Tromey-2/+5
@eddyb pointed out in review that the niche value computation had a possible integer overflow problem, fixed here as he suggested.
2018-10-30Address review commentsTom Tromey-11/+11
This fixes the issues pointed out in review.
2018-10-30Fix DWARF generation for enumsTom Tromey-145/+407
The DWARF generated for Rust enums was always somewhat unusual. Rather than using DWARF constructs directly, it would emit magic field names like "RUST$ENCODED$ENUM$0$Name" and "RUST$ENUM$DISR". Since PR #45225, though, even this has not worked -- the ad hoc scheme was not updated to handle the wider variety of niche-filling layout optimizations now available. This patch changes the generated DWARF to use the standard tags meant for this purpose; namely, DW_TAG_variant and DW_TAG_variant_part. The patch to implement this went in to LLVM 7. In order to work with older versions of LLVM, and because LLVM doesn't do anything here for PDB, the existing code is kept as a fallback mode. Support for this DWARF is in the Rust lldb and in gdb 8.2. Closes #32920 Closes #32924 Closes #52762 Closes #53153
2018-10-29Emit Retag statements, kill Validate statementsRalf Jung-2/+3
Also "rename" -Zmir-emit-validate to -Zmir-emit-retag, which is just a boolean (yes or no).
2018-10-28inline-asm: emit as many E0669 errors as we canLevente Kurusa-8/+5
Signed-off-by: Levente Kurusa <lkurusa@acm.org>
2018-10-27Auto merge of #54183 - qnighy:by-value-object-safety, r=oli-obkbors-90/+58
Implement by-value object safety This PR implements **by-value object safety**, which is part of unsized rvalues #48055. That means, with `#![feature(unsized_locals)]`, you can call a method `fn foo(self, ...)` on trait objects. One aim of this is to enable `Box<FnOnce>` in the near future. The difficulty here is this: when constructing a vtable for a trait `Foo`, we can't just put the function `<T as Foo>::foo` into the table. If `T` is no larger than `usize`, `self` is usually passed directly. However, as the caller of the vtable doesn't know the concrete `Self` type, we want a variant of `<T as Foo>::foo` where `self` is always passed by reference. Therefore, when the compiler encounters such a method to be generated as a vtable entry, it produces a newly introduced instance called `InstanceDef::VtableShim(def_id)` (that wraps the original instance). the shim just derefs the receiver and calls the original method. We give different symbol names for the shims by appending `::{{vtable-shim}}` to the symbol path (and also adding vtable-shimness as an ingredient to the symbol hash). r? @eddyb
2018-10-27Correct alignment of atomic types and (re)add Atomic{I,U}128Oliver Middleton-13/+10
LLVM requires that atomic loads and stores be aligned to at least the size of the type.
2018-10-27Refactor and add `PlaceContext::AscribeUserTy`.David Wood-17/+32
This commit refactors `PlaceContext` to split it into four different smaller enums based on if the context represents a mutating use, non-mutating use, maybe-mutating use or a non-use (this is based on the recommendation from @oli-obk on Zulip[1]). This commit then introduces a `PlaceContext::AscribeUserTy` variant. `StatementKind::AscribeUserTy` is now correctly mapped to `PlaceContext::AscribeUserTy` instead of `PlaceContext::Validate`. `PlaceContext::AscribeUserTy` can also now be correctly categorized as a non-use which fixes an issue with constant promotion in statics after a cast introduces a `AscribeUserTy` statement. [1]: https://rust-lang.zulipchat.com/#narrow/stream/122657-wg-nll/subject/.2355288.20cast.20fails.20to.20promote.20to.20'static/near/136536949
2018-10-26Add the actual chain of projections to `UserTypeProjection`.Felix S. Klock II-2/+5
Update the existing NLL `patterns.rs` test accordingly. includes changes addressing review feedback: * Added example to docs for `UserTypeProjections` illustrating how we build up multiple projections when descending into a pattern with type ascriptions. * Adapted niko's suggested docs for `UserTypeProjection`. * Factored out `projection_ty` from more general `projection_ty_core` (as a drive-by, made its callback an `FnMut`, as I discovered later that I need that). * Add note to docs that `PlaceTy.field_ty(..)` does not normalize its result. * Normalize as we project out `field_ty`.