about summary refs log tree commit diff
path: root/src/librustc_codegen_llvm
AgeCommit message (Collapse)AuthorLines
2020-05-18Add RISC-V target featuresAmanieu d'Antras-0/+11
2020-05-17Auto merge of #72248 - petrochenkov:codemodel, r=Amanieubors-26/+15
Cleanup and document `-C code-model` r? @Amanieu
2020-05-16rustc_target: Stop using "string typing" for code modelsVadim Petrochenkov-26/+15
Introduce `enum CodeModel` instead.
2020-05-14Consistently use LLVM lifetime markers during codegenTomasz Miąsko-11/+5
Ensure that inliner inserts lifetime markers if they have been emitted during codegen. Otherwise if allocas from inlined functions are merged together, lifetime markers from one function might invalidate load & stores performed by the other one.
2020-05-09Rollup merge of #71555 - cjgillot:nameless, r=matthewjasperRalf Jung-6/+4
Remove ast::{Ident, Name} reexports. The reexport of `Symbol` into `Name` confused me.
2020-05-09Rollup merge of #71508 - oli-obk:alloc_map_unlock, r=RalfJungRalf Jung-6/+4
Simplify the `tcx.alloc_map` API This PR changes all functions that require manually locking the `alloc_map` to functions on `TyCtxt` that lock the map internally. In the same step we make the `TyCtxt::alloc_map` field private. r? @RalfJung
2020-05-09Rollup merge of #71234 - maurer:init-array, r=cuviperRalf Jung-0/+9
rustllvm: Use .init_array rather than .ctors LLVM TargetMachines default to using the (now-legacy) .ctors representation of init functions. Mixing .ctors and .init_array representations can cause issues when linking with lld. This happens in practice for: * Our profiling runtime which is currently implicitly built with .init_array since it is built by clang, which sets this field. * External C/C++ code that may be linked into the same process. Fixes: #71233
2020-05-08Remove ast::{Ident, Name} reexports.Camille GILLOT-6/+4
2020-05-08Create a convenience wrapper for `get_global_alloc(id).unwrap()`Oliver Scherer-5/+4
2020-05-08Simplify the `tcx.alloc_map` APIOliver Scherer-2/+1
2020-05-08Simplify bitcode embedding - either None or FullTom Karpiniec-5/+3
2020-05-07Provide configurable LLVM cmdline section via target specTom Karpiniec-6/+8
The App Store performs certain sanity checks on bitcode, including that an acceptable set of command line arguments was used when compiling a given module. For Rust code to be distributed on the app store with bitcode rustc must pretend to have the same command line arguments.
2020-05-05Rollup merge of #69984 - lenary:lenary/force-uwtables, r=hanna-kruppeDylan DPC-5/+2
Add Option to Force Unwind Tables When panic != unwind, `nounwind` is added to all functions for a target. This can cause issues when a panic happens with RUST_BACKTRACE=1, as there needs to be a way to reconstruct the backtrace. There are three possible sources of this information: forcing frame pointers (for which an option exists already), debug info (for which an option exists), or unwind tables. Especially for embedded devices, forcing frame pointers can have code size overheads (RISC-V sees ~10% overheads, ARM sees ~2-3% overheads). In production code, it can be the case that debug info is not kept, so it is useful to provide this third option, unwind tables, that users can use to reconstruct the call stack. Reconstructing this stack is harder than with frame pointers, but it is still possible. --- This came up in discussion on #69890, and turned out to be a fairly simple addition. r? @hanna-kruppe
2020-05-04Correctly handle UEFI targets as Windows-like when emitting sections for ↵Isaac Woods-1/+3
LLVM bitcode
2020-05-04Add Option to Force Unwind TablesSam Elliott-5/+2
When panic != unwind, `nounwind` is added to all functions for a target. This can cause issues when a panic happens with RUST_BACKTRACE=1, as there needs to be a way to reconstruct the backtrace. There are three possible sources of this information: forcing frame pointers (for which an option exists already), debug info (for which an option exists), or unwind tables. Especially for embedded devices, forcing frame pointers can have code size overheads (RISC-V sees ~10% overheads, ARM sees ~2-3% overheads). In code, it can be the case that debug info is not kept, so it is useful to provide this third option, unwind tables, that users can use to reconstruct the call stack. Reconstructing this stack is harder than with frame pointers, but it is still possible. This commit adds a compiler option which allows a user to force the addition of unwind tables. Unwind tables cannot be disabled on targets that require them for correctness, or when using `-C panic=unwind`.
2020-05-02Rollup merge of #71787 - tshepang:rustdoc-warnings, r=varkorDylan DPC-3/+4
fix rustdoc warnings
2020-05-02cleanup: `config::CrateType` -> `CrateType`Vadim Petrochenkov-11/+9
2020-05-02fix rustdoc warningsTshepang Lekhonkhobe-3/+4
2020-05-01Auto merge of #70674 - cjgillot:query-arena-all, r=matthewjasperbors-10/+7
Have the per-query caches store the results on arenas This PR leverages the cache for each query to serve as storage area for the query results. It introduces a new cache `ArenaCache`, which moves the result to an arena, and only stores the reference in the hash map. This allows to remove a sizeable part of the usage of the global `TyCtxt` arena. I only migrated queries that already used arenas before.
2020-04-30Add a convenience function for testing whether a static is `#[thread_local]`Oliver Scherer-0/+1
2020-04-30Auto merge of #70175 - Amanieu:remove_nlp, r=pnkfelixbors-2/+6
Remove -Z no-landing-pads flag Since #67502, `-Z no-landing-pads` will cause all attempted unwinds to abort since we don't generate a `try` / `catch`. This previously worked because `__rust_try` was located in libpanic_unwind which is always compiled with `-C panic=unwind`, but `__rust_try` is now directly inline into the crate that uses `catch_unwind`. As such, `-Z no-landing-pads` is now mostly useless and people should use `-C panic=abort` instead.
2020-04-29Auto merge of #71528 - alexcrichton:no-more-bitcode, r=nnethercotebors-177/+90
Store LLVM bitcode in object files, not compressed This commit is an attempted resurrection of #70458 where LLVM bitcode emitted by rustc into rlibs is stored into object file sections rather than in a separate file. The main rationale for doing this is that when rustc emits bitcode it will no longer use a custom compression scheme which makes it both easier to interoperate with existing tools and also cuts down on compile time since this compression isn't happening. The blocker for this in #70458 turned out to be that native linkers didn't handle the new sections well, causing the sections to either trigger bugs in the linker or actually end up in the final linked artifact. This commit attempts to address these issues by ensuring that native linkers ignore the new sections by inserting custom flags with module-level inline assembly. Note that this does not currently change the API of the compiler at all. The pre-existing `-C bitcode-in-rlib` flag is co-opted to indicate whether the bitcode should be present in the object file or not. Finally, note that an important consequence of this commit, which is also one of its primary purposes, is to enable rustc's `-Clto` bitcode loading to load rlibs produced with `-Clinker-plugin-lto`. The goal here is that when you're building with LTO Cargo will tell rustc to skip codegen of all intermediate crates and only generate LLVM IR. Today rustc will generate both object code and LLVM IR, but the object code is later simply thrown away, wastefully.
2020-04-29Use .init_array rather than .ctorsMatthew Maurer-0/+9
LLVM TargetMachines default to using the (now-legacy) .ctors representation of init functions. Mixing .ctors and .init_array representations can cause issues when linking with lld. This happens in practice for: * Our profiling runtime which is currently implicitly built with .init_array since it is built by clang, which sets this field. * External C/C++ code that may be linked into the same process. To support legacy systems which may use .ctors, targets may now specify that they use .ctors via the use_ctors attribute which defaults to false. For debugging and manual control, -Z use-ctors-section=yes/no will allow manual override. Fixes: #71233
2020-04-29Store LLVM bitcode in object files, not compressedAlex Crichton-177/+90
This commit is an attempted resurrection of #70458 where LLVM bitcode emitted by rustc into rlibs is stored into object file sections rather than in a separate file. The main rationale for doing this is that when rustc emits bitcode it will no longer use a custom compression scheme which makes it both easier to interoperate with existing tools and also cuts down on compile time since this compression isn't happening. The blocker for this in #70458 turned out to be that native linkers didn't handle the new sections well, causing the sections to either trigger bugs in the linker or actually end up in the final linked artifact. This commit attempts to address these issues by ensuring that native linkers ignore the new sections by inserting custom flags with module-level inline assembly. Note that this does not currently change the API of the compiler at all. The pre-existing `-C bitcode-in-rlib` flag is co-opted to indicate whether the bitcode should be present in the object file or not. Finally, note that an important consequence of this commit, which is also one of its primary purposes, is to enable rustc's `-Clto` bitcode loading to load rlibs produced with `-Clinker-plugin-lto`. The goal here is that when you're building with LTO Cargo will tell rustc to skip codegen of all intermediate crates and only generate LLVM IR. Today rustc will generate both object code and LLVM IR, but the object code is later simply thrown away, wastefully.
2020-04-29Remove Session::no_landing_pads()Amanieu d'Antras-2/+6
2020-04-28Move a few queries to using an arena.Camille GILLOT-1/+1
2020-04-28Use the query system to allocate.Camille GILLOT-9/+6
2020-04-28Auto merge of #71292 - marmeladema:queries-local-def-id, r=eddybbors-1/+1
Convert more queries to use `LocalDefId` This PR is based on commits in https://github.com/rust-lang/rust/pull/71215 and should partially solve #70853
2020-04-27Change return type of `entry_fn` query to return a `LocalDefId`marmeladema-1/+1
2020-04-26rustc_target: Stop using "string typing" for TLS modelsVadim Petrochenkov-23/+9
Introduce `enum TlsModel` instead.
2020-04-26codegen_llvm: Simplify logic for relaxing PIC into PIEVadim Petrochenkov-31/+21
2020-04-26codegen_llvm: `RelocMode` -> `RelocModel`Vadim Petrochenkov-9/+9
2020-04-26rustc_target: Stop using "string typing" for relocation modelsVadim Petrochenkov-37/+21
Introduce `enum RelocModel` instead.
2020-04-23Address comments from reviewmarmeladema-3/+2
2020-04-23Modify `as_local_hir_id` to return a bare `HirId`marmeladema-1/+1
2020-04-23Modify `as_local_hir_id` to accept a `LocalDefId` instead of a `DefId`marmeladema-2/+4
2020-04-22Rollup merge of #70970 - eddyb:trait-vs-impl-mismatch, r=oli-obkDylan DPC-0/+1
Detect mistyped associated consts in `Instance::resolve`. *Based on #71049 to prevent redundant/misleading downstream errors.* Fixes #70942 by refusing to resolve an associated `const` if it doesn't have the same type in the `impl` that it does in the `trait` (which we assume had errored, and `delay_span_bug` guards against bugs).
2020-04-21Auto merge of #71267 - pnkfelix:issue-71248-dont-need-exports-all-green, ↵bors-10/+22
r=nagisa attempt to recover perf by removing `exports_all_green` attempt to recover perf by removing `exports_all_green` flag. cc #71248 (My hypothesis is that my use of this flag was an overly conservative generalization of PR #67020.)
2020-04-20Expand comment to justify not checking if all the exports are green.Felix S. Klock II-0/+17
2020-04-20Auto merge of #70729 - nnethercote:a-big-options-clean-up, r=petrochenkovbors-1/+1
A big options clean-up Lots of improvements here. r? @Centril
2020-04-19Dogfood more or_patterns in the compilerJosh Stone-3/+4
2020-04-19Replace uses of `parse_opt_*` with `parse_*` where possible.Nicholas Nethercote-1/+1
This lets us specify the default at the options declaration point, instead of using `.unwrap(default)` or `None | Some(default)` at some use point far away. It also makes the code more concise.
2020-04-18Detect mistyped associated consts in `Instance::resolve`.Eduard-Mihai Burtescu-0/+1
2020-04-18Auto merge of #71147 - cuviper:min-llvm8, r=Mark-Simulacrumbors-83/+27
Update the minimum external LLVM to 8 LLVM 8 was released on March 20, 2019, over a year ago.
2020-04-17Issue #71248: attempt to recover perf by removing `exports_all_green` flag.Felix S. Klock II-10/+5
(My hypothesis is that my use of this flag was an overly conservative generalization of PR 67020.)
2020-04-17Auto merge of #70629 - anyska:fields-variant, r=oli-obkbors-2/+2
rustc_target::abi: add Primitive variant to FieldsShape. Originally suggested by @eddyb.
2020-04-16rustc_target::abi: add Primitive variant to FieldsShape.Ana-Maria Mihalache-2/+2
2020-04-15Incorporated review feedback:Felix S. Klock II-22/+40
Renamed the struct to make it a little clearer that it doesn't just hold one imports map. (I couldn't bring myself to write it as `ThinLTOImportsExports` though, mainly since the exports map is literally derived from the imports map data.) Added some doc to the struct too. Revised comments to add link to the newer issue that discusses why the exports are relevant. Renamed a few of the methods so that the two character difference is more apparent (because 1. the method name is shorter and, perhaps more importantly, the changed characters now lie at the beginning of the method name.)
2020-04-14Update the minimum external LLVM to 8Josh Stone-83/+27
LLVM 8 was released on March 20, 2019, over a year ago.
2020-04-14If an LLVM module's exports change, cannot reuse its post-LTO object file inFelix S. Klock II-4/+33
incremental compilation. This is symmetric to PR #67020, which handled the case where the LLVM module's *imports* changed. This commit builds upon the infrastructure added there; the export map is just the inverse of the import map, so we can build the export map at the same time that we load the serialized import map. Fix #69798