about summary refs log tree commit diff
path: root/src/librustc_codegen_ssa
AgeCommit message (Collapse)AuthorLines
2019-01-28Auto merge of #55704 - Nemo157:pinned-generators, r=Zoxcbors-0/+7
Use pinning for generators to make trait safe I'm unsure whether there needs to be any changes to the actual generator transform. Tests are passing so the fact that `Pin<&mut T>` is fundamentally the same as `&mut T` seems to allow it to still work, but maybe there's something subtle here that could go wrong. This is specified in [RFC 2349 § Immovable generators](https://github.com/rust-lang/rfcs/blob/master/text/2349-pin.md#immovable-generators) (although, since that RFC it has become safe to create an immovable generator, and instead it's unsafe to resume any generator; with these changes both are now safe and instead the unsafety is moved to creating a `Pin<&mut [static generator]>` which there are safe APIs for). CC #43122
2019-01-27Update generator upvar debug infoWim Looman-0/+7
2019-01-27`ConstValue::ScalarPair` only needs to represent slicesOliver Scherer-8/+4
2019-01-27Create `nvptx64-nvidia-cuda` target specificationDenys Zariaiev-0/+126
2019-01-26Auto merge of #55641 - nagisa:optimize-attr, r=pnkfelixbors-5/+40
Implement optimize(size) and optimize(speed) attributes This PR implements both `optimize(size)` and `optimize(speed)` attributes. While the functionality itself works fine now, this PR is not yet complete: the code might be messy in places and, most importantly, the compiletest must be improved with functionality to run tests with custom optimization levels. Otherwise the new attribute cannot be tested properly. Oh, and not all of the RFC is implemented – attribute propagation is not implemented for example. # TODO * [x] Improve compiletest so that tests can be written; * [x] Assign a proper error number (E9999 currently, no idea how to allocate a number properly); * [ ] Perhaps reduce the duplication in LLVM attribute assignment code…
2019-01-25Rollup merge of #57865 - Aaron1011:fix/debug-ice, r=estebankMazdak Farrokhzad-4/+4
Don't ICE when logging unusual types MonoItemExt#to_string is used for both debug logging and LLVM symbol name generation. When debugging, we want to print out any type we encounter, even if it's something weird like GeneratorWitness. However, during codegen, we still want to error if we encounter an unexpected type when generating a name. To resolve this issue, this commit introduces a new 'debug' parameter to the relevant methods. When set to 'true', it allows any type to be printed - when set to 'false', it 'bug!'s when encountering an unexpected type. This prevents an ICE when enabling debug logging (via RUST_LOG) while running rustc on generator-related code.
2019-01-24Auto merge of #57879 - Centril:rollup, r=Centrilbors-4/+0
Rollup of 9 pull requests Successful merges: - #57380 (Fix Instant/Duration math precision & associativity on Windows) - #57606 (Get rid of the fake stack frame for reading from constants) - #57803 (Several changes to libunwind for SGX target) - #57846 (rustdoc: fix ICE from loading proc-macro stubs) - #57860 (Add os::fortanix_sgx::ffi module) - #57861 (Don't export table by default in wasm) - #57863 (Add suggestion for incorrect field syntax.) - #57867 (Fix std::future::from_generator documentation) - #57873 (Stabilize no_panic_pow) Failed merges: r? @ghost
2019-01-24Implement optimize(size) and optimize(speed)Simonas Kazlauskas-5/+40
2019-01-24Rollup merge of #57861 - pepyakin:wasm-dont-export-table, r=alexcrichtonMazdak Farrokhzad-3/+0
Don't export table by default in wasm Revert of https://github.com/rust-lang/rust/pull/53237 As per discussion here https://github.com/rustwasm/team/issues/251
2019-01-24Remove quote_*! macros and associated APIsMark Simulacrum-1/+0
2019-01-23Don't ICE when logging unusual typesAaron Hill-4/+4
MonoItemExt#to_string is used for both debug logging and LLVM symbol name generation. When debugging, we want to print out any type we encounter, even if it's something weird like GeneratorWitness. However, during codegen, we still want to error if we encounter an unexpected type when generating a name. To resolve this issue, this commit introduces a new 'debug' parameter to the relevant methods. When set to 'true', it allows any type to be printed - when set to 'false', it 'bug!'s when encountering an unexpected type. This prevents an ICE when enabling debug logging (via RUST_LOG) while running rustc on generator-related code.
2019-01-23Don't export table by default in wasmSergey Pepyakin-3/+0
2019-01-22Get rid of the fake stack frameOliver Scherer-1/+0
2019-01-19Rollup merge of #57573 - Xanewok:querify-entry-fn, r=ZoxcMazdak Farrokhzad-6/+4
Querify `entry_fn` Analogous to https://github.com/rust-lang/rust/pull/57570 but this will also require few fixups in Miri so I decided to separate that (and it seems [CI doesn't let us break tools anymore](https://github.com/rust-lang/rust/pull/57392#issuecomment-453801540)? Or was that because it was a rollup PR?) r? @nikomatsakis
2019-01-19Rollup merge of #57268 - peterhj:peterhj-optmergefunc, r=nagisaMazdak Farrokhzad-2/+19
Add a target option "merge-functions", and a corresponding -Z flag (works around #57356) This commit adds a target option "merge-functions", which takes values in ("disabled", "trampolines", or "aliases" (default is "aliases")), to allow targets to opt out of the MergeFunctions LLVM pass. Additionally, the latest commit also adds an optional -Z flag, "merge-functions", which takes the same values and has precedence over the target option when both are specified. This works around https://github.com/rust-lang/rust/issues/57356. cc @eddyb @japaric @oli-obk @nox @nagisa Also thanks to @denzp and @gnzlbg for discussing this on rust-cuda! ### Motivation Basically, the problem is that the MergeFunctions pass, which rustc currently enables by default at -O2 and -O3 [1], and `extern "ptx-kernel"` functions (specific to the NVPTX target) are currently not compatible with each other. If the MergeFunctions pass is allowed to run, rustc can generate invalid PTX assembly (i.e. a PTX file that is not accepted by the native PTX assembler `ptxas`). Therefore we would like a way to opt out of the MergeFunctions pass, which is what our target option does. ### Related work The current behavior of rustc is to enable MergeFunctions at -O2 and -O3 [1], and also to enable the use of function aliases within MergeFunctions [2] [3]. MergeFunctions seems to have some benefits, such as reducing code size and fixing a crash [4], which is why it is enabled. However, MergeFunctions both with and without function aliases is incompatible with the NVPTX target; a more detailed example for both cases is given below. clang's "solution" is to have a "-fmerge-functions" flag that opts in to the MergeFunctions pass, but it is not enabled by default. ### Examples/more details Consider an example Rust lib using `extern "ptx-kernel"` functions: https://github.com/peterhj/nvptx-mergefunc-bug/blob/master/nocore.rs. If we try to compile this with nightly rustc, we get the following compiler error: LLVM ERROR: Module has aliases, which NVPTX does not support. This error happens because: (1) functions `foo` and `bar` have the same body, so are candidates to be merged by MergeFunctions; and (2) rustc configures MergeFunctions to generate function aliases using the "mergefunc-use-aliases" LLVM option [2] [3], but the NVPTX backend does not support those aliases. Okay, so we can try omitting "mergefunc-use-aliases", and then rustc will happily emit PTX assembly: https://github.com/peterhj/nvptx-mergefunc-bug/blob/master/nocore-mergefunc-nousealiases-bad.ptx. However, this PTX is invalid! When we try to assemble it with `ptxas` (I'm on the CUDA 9.2 toolchain), we get an assembler error: ptxas nocore-mergefunc-nousealiases-bad.ptx, line 38; error : Illegal call target, device function expected ptxas fatal : Ptx assembly aborted due to errors What's happening is that MergeFunctions rewrites the `bar` function to call `foo`. However, directly calling an `extern "ptx-kernel"` function from another `extern "ptx-kernel"` is wrong. If we disable the MergeFunctions pass from running at all, rustc generates correct PTX assembly: https://github.com/peterhj/nvptx-mergefunc-bug/blob/master/nocore-nomergefunc-ok.ptx [1] https://github.com/rust-lang/rust/blob/a36b960df626cbb8bea74f01243318b73f0bd201/src/librustc_codegen_ssa/back/write.rs#L155 [2] https://github.com/rust-lang/rust/blob/a36b960df626cbb8bea74f01243318b73f0bd201/src/librustc_codegen_llvm/llvm_util.rs#L64 [3] https://github.com/rust-lang/rust/pull/56358 [4] https://github.com/rust-lang/rust/pull/49479
2019-01-15Querify entry_fnIgor Matuszewski-6/+4
2019-01-13Querify local plugin_registrar_fnIgor Matuszewski-3/+2
2019-01-13Querify local proc_macro_decls_staticIgor Matuszewski-3/+2
2019-01-13Rollup merge of #57337 - alexcrichton:prioritize-another, r=fitzgenMazdak Farrokhzad-60/+62
rustc: Place wasm linker args first instead of last This ensures that arguments passed via `-C link-arg` can override the first ones on the command line, for example allowing configuring of the stack size.
2019-01-05Add a target option "merge-functions" taking values in ("disabled",Peter Jin-2/+19
"trampolines", or "aliases (the default)) to allow targets to opt out of the MergeFunctions LLVM pass. Also add a corresponding -Z option with the same name and values. This works around: https://github.com/rust-lang/rust/issues/57356 Motivation: Basically, the problem is that the MergeFunctions pass, which rustc currently enables by default at -O2 and -O3, and `extern "ptx-kernel"` functions (specific to the NVPTX target) are currently not compatible with each other. If the MergeFunctions pass is allowed to run, rustc can generate invalid PTX assembly (i.e. a PTX file that is not accepted by the native PTX assembler ptxas). Therefore we would like a way to opt out of the MergeFunctions pass, which is what our target option does. Related work: The current behavior of rustc is to enable MergeFunctions at -O2 and -O3, and also to enable the use of function aliases within MergeFunctions. MergeFunctions both with and without function aliases is incompatible with the NVPTX target. clang's "solution" is to have a "-fmerge-functions" flag that opts in to the MergeFunctions pass, but it is not enabled by default.
2019-01-05Auto merge of #57145 - RalfJung:panic-if-uninhabited, r=alexcrichtonbors-46/+50
panic when calling MaybeUninhabited::into_inner on uninhabited type I do this by adding an internal-only intrinsic `panic_if_uninhabited`. I have no idea what I am doing here, just mindlessly copying code around, so please review carefully!
2019-01-05Auto merge of #56837 - arielb1:nonprincipal-trait-objects, r=nikomatsakisbors-4/+11
Add support for trait-objects without a principal The hard-error version of #56481 - should be merged after we do something about the `traitobject` crate. Fixes #33140. Fixes #57057. r? @nikomatsakis
2019-01-04rustc: Place wasm linker args first instead of lastAlex Crichton-60/+62
This ensures that arguments passed via `-C link-arg` can override the first ones on the command line, for example allowing configuring of the stack size.
2019-01-04add support for principal-less trait object typesAriel Ben-Yehuda-4/+11
should be a pure refactoring.
2019-01-01`<&'tcx ty::Const as Deref>::deref`Oliver Scherer-4/+4
2019-01-01Add `unwrap_usize` to `LazyConst`, tooOliver Scherer-3/+3
2019-01-01Move the `Unevaluated` constant arm upwards in the type structureOliver Scherer-9/+8
2018-12-27use a better way to get at the type parameterRalf Jung-6/+1
2018-12-27panic when calling MaybeUninhabited::into_inner on uninhabited typeRalf Jung-46/+55
2018-12-25Remove licensesMark Rousskov-379/+0
2018-12-24Rollup merge of #57074 - Zoxc:pq-rec-limits, r=oli-obkMazdak Farrokhzad-0/+2
Fix recursion limits r? @michaelwoerister
2018-12-23Fix recursion limitsJohn Kåre Alsaker-0/+2
2018-12-21Fix alignment for array indexingNikita Popov-3/+13
We need to reduce the alignment with the used offset. If the offset isn't known, we need to reduce with the element size to support arbitrary offsets.
2018-12-18treat ref-to-raw cast like a reborrow: do a special kind of retagRalf Jung-1/+0
2018-12-17Auto merge of #56642 - nikic:llvm-6, r=alexcrichtonbors-25/+2
Bump minimum required LLVM version to 6.0 Based on the discussion in #55842, while the overall position of Rust wrt LLVM continues to be contentious, there does seem to be a consensus that there is no need for continued support of LLVM 5. This PR bumps our version requirement to LLVM 6.0 and makes Travis run against that. I hope that this is going to unblock #52694. If I understand correctly, while this issue still exists in LLVM 6, Ubuntu has backported the relevant patch. r? @alexcrichton
2018-12-14Rollup merge of #56562 - pnkfelix:issue-55465-update-libc-version, ↵kennytm-1/+1
r=alexcrichton Update libc version required by rustc This is meant to be an easy-to-backport fix for #55465
2018-12-14Auto merge of #56351 - davidtwco:issue-55396-stabilize-linker-flavor, r=nagisabors-5/+1
Stabilize `linker-flavor` flag. Part of #55396. This commit moves the linker-flavor flag from a debugging option to a codegen option, thus stabilizing it. There are no feature flags associated with this flag. r? @nagisa
2018-12-13Stabilize `linker-flavor` flag.David Wood-5/+1
This commit moves the linker-flavor flag from a debugging option to a codegen option, thus stabilizing it. There are no feature flags associated with this flag.
2018-12-12Increase required version for crates.io `libc` to get fix from PR ↵Felix S. Klock II-1/+1
rust-lang/libc#1057. Part of issue #55465
2018-12-12Remove `Session::sysroot()`.Nicholas Nethercote-2/+1
Instead of maybe storing its own sysroot and maybe deferring to the one in `Session::opts`, just clone the latter when necessary so one is always directly available. This removes the need for the getter.
2018-12-11Remove env_alloca hackNikita Popov-25/+2
This is no longer necessary for LLVM >= 6.
2018-12-07Various minor/cosmetic improvements to codeAlexander Regueiro-16/+16
2018-12-07Auto merge of #56502 - Zoxc:hir-func, r=eddybbors-11/+11
Use a function to access the Hir map to be able to turn it into a query later r? @eddyb
2018-12-07Auto merge of #56487 - nikic:discard-modules-earlier, r=alexcrichtonbors-94/+139
Discard LLVM modules earlier when performing ThinLTO Currently ThinLTO is performed by first compiling all modules (and keeping them in memory), and then serializing them into ThinLTO buffers in a separate, synchronized step. Modules are later read back from ThinLTO buffers when running the ThinLTO optimization pipeline. We can also find the following comment in `lto.rs`: // FIXME: right now, like with fat LTO, we serialize all in-memory // modules before working with them and ThinLTO. We really // shouldn't do this, however, and instead figure out how to // extract a summary from an in-memory module and then merge that // into the global index. It turns out that this loop is by far // the most expensive portion of this small bit of global // analysis! I don't think that what is suggested here is the right approach: One of the primary benefits of using ThinLTO over ordinary LTO is that it's not necessary to keep all the modules (merged or not) in memory for the duration of the linking step. However, we currently don't really make use of this (at least for crate-local ThinLTO), because we keep all modules in memory until the start of the LTO step. This PR changes the implementation to instead perform the serialization into ThinLTO buffers directly after the initial optimization step. Most of the changes here are plumbing to separate out fat and thin lto handling in `write.rs`, as these now use different intermediate artifacts. For fat lto this will be in-memory modules, for thin lto it will be ThinLTO buffers. r? @alexcrichton
2018-12-06Use a function to access the Hir map to be able to turn it into a query laterJohn Kåre Alsaker-11/+11
2018-12-06Rollup merge of #56500 - ljedrz:cleanup_rest_of_const_lifetimes, r=zackmdavisPietro Albini-1/+1
cleanup: remove static lifetimes from consts A follow-up to https://github.com/rust-lang/rust/pull/56497.
2018-12-04Serialize modules into ThinBuffer after initial optimizationNikita Popov-16/+24
Instead of keeping all modules in memory until thin LTO and only serializing them then, serialize the module immediately after it finishes optimizing.
2018-12-04Remove unnecessary parts of run_fat_lto signatureNikita Popov-4/+5
Fat LTO merges into one module, so only return one module.
2018-12-04Separate out methods for running thin and fat LTONikita Popov-8/+14
2018-12-04Separate codepaths for fat and thin LTO in write.rsNikita Popov-27/+56
These are going to have different intermediate artifacts, so create separate codepaths for them.