about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src
AgeCommit message (Collapse)AuthorLines
2020-11-18Rollup merge of #78361 - DevJPM:master, r=workingjubileeMara Bos-0/+13
Updated the list of white-listed target features for x86 This PR both adds in-source documentation on what to look out for when adding a new (X86) feature set and [adds all that are detectable at run-time in Rust stable as of 1.27.0](https://github.com/rust-lang/stdarch/blob/master/crates/std_detect/src/detect/arch/x86.rs). This should only enable the use of the corresponding LLVM intrinsics. Actual intrinsics need to be added separately in rust-lang/stdarch. It also re-orders the run-time-detect test statements to be more consistent with the actual list of intrinsics whitelisted and removes underscores not present in the actual names (which might be mistaken as being part of the name) The reference for LLVM's feature names used is [this file](https://github.com/llvm/llvm-project/blob/master/llvm/include/llvm/Support/X86TargetParser.def). This PR was motivated as the compiler end's part for allowing #67329 to be adressed over on rust-lang/stdarch
2020-11-16compiler: fold by valueBastian Kauschke-29/+29
2020-11-15Re-enable LLVM 9 target features with LLVM 9 being the minimum nowDevJPM-2/+2
With #78848 merged, the minimum supported LLVM version is now 9 which means we can actually use the target features introduced in LLVM 9
2020-11-12rustc_target: Mark UEFI targets as `is_like_windows`/`is_like_msvc`Vadim Petrochenkov-0/+2
Document what `is_like_windows` and `is_like_msvc` mean in more detail.
2020-11-10Rollup merge of #78875 - petrochenkov:cleantarg, r=Mark-SimulacrumJonas Schievink-92/+84
rustc_target: Further cleanup use of target options Follow up to https://github.com/rust-lang/rust/pull/77729. Implements items 2 and 4 from the list in https://github.com/rust-lang/rust/pull/77729#issue-500228243. The first commit collapses uses of `target.options.foo` into `target.foo`. The second commit renames some target options to avoid tautology: `target.target_endian` -> `target.endian` `target.target_c_int_width` -> `target.c_int_width` `target.target_os` -> `target.os` `target.target_env` -> `target.env` `target.target_vendor` -> `target.vendor` `target.target_family` -> `target.os_family` `target.target_mcount` -> `target.mcount` r? `@Mark-Simulacrum`
2020-11-09Rollup merge of #78844 - tmiasko:monomorphize-sizeof, r=oli-obkDylan DPC-0/+1
Monomorphize a type argument of size-of operation during codegen This wasn't necessary until MIR inliner started to consider drop glue as a candidate for inlining; introducing for the first time a generic use of size-of operation. No test at this point since this only happens with a custom inlining threshold.
2020-11-09Rollup merge of #78674 - tmiasko:inline-substs-for-mir-body, r=oli-obkDylan DPC-9/+5
inliner: Use substs_for_mir_body Changes from 68965 extended the kind of instances that are being inlined. For some of those, the `instance_mir` returns a MIR body that is already expressed in terms of the types found in substitution array, and doesn't need further substitution. Use `substs_for_mir_body` to take that into account. Resolves #78529. Resolves #78560.
2020-11-08rustc_target: Rename some target options to avoid tautologyVadim Petrochenkov-8/+8
`target.target_endian` -> `target.endian` `target.target_c_int_width` -> `target.c_int_width` `target.target_os` -> `target.os` `target.target_env` -> `target.env` `target.target_vendor` -> `target.vendor` `target.target_family` -> `target.os_family` `target.target_mcount` -> `target.mcount`
2020-11-08Collapse all uses of `target.options.foo` into `target.foo`Vadim Petrochenkov-84/+76
with an eye on merging `TargetOptions` into `Target`. `TargetOptions` as a separate structure is mostly an implementation detail of `Target` construction, all its fields logically belong to `Target` and available from `Target` through `Deref` impls.
2020-11-07Monomorphize a type argument of size-of operation during codegenTomasz Miąsko-0/+1
This wasn't necessary until MIR inliner started to consider drop glue as a candidate for inlining; introducing for the first time a generic use of size-of operation. No test at this point since this only happens with a custom inlining threshold.
2020-11-05Addressed all feedback to dateRich Kadel-24/+15
2020-11-05Added comments on remapping expression IDs, and URL to spanviewsRich Kadel-1/+19
2020-11-05Injecting expressions in place of counters where helpfulRich Kadel-5/+9
Implementing the Graph traits for the BasicCoverageBlock graph. optimized replacement of counters with expressions plus new BCB graphviz * Avoid adding coverage to unreachable blocks. * Special case for Goto at the end of the body. Make it non-reportable. Improved debugging and formatting options (from env) Don't automatically add counters to BCBs without CoverageSpans. They may still get counters but only if there are dependencies from other BCBs that have spans, I think. Make CodeRegions optional for Counters too. It is possible to inject counters (`llvm.instrprof.increment` intrinsic calls without corresponding code regions in the coverage map. An expression can still uses these counter values. Refactored instrument_coverage.rs -> instrument_coverage/mod.rs, and then broke up the mod into multiple files. Compiling with coverage, with the expression optimization, works on the json5format crate and its dependencies. Refactored debug features from mod.rs to debug.rs
2020-11-05Rust coverage before splitting instrument_coverage.rsRich Kadel-51/+107
2020-11-06inliner: Use substs_for_mir_bodyTomasz Miąsko-9/+5
Changes from 68965 extended the kind of instances that are being inlined. For some of those, the `instance_mir` returns a MIR body that is already expressed in terms of the types found in substitution array, and doesn't need further substitution. Use `substs_for_mir_body` to take that into account.
2020-11-04Auto merge of #78280 - bugadani:span, r=lcnrbors-9/+4
Codegen: Query span as late as possible
2020-11-03Auto merge of #78448 - rylev:cache-foreign_modules, r=wesleywiserbors-2/+0
foreign_modules query hash table lookups When compiling a large monolithic crate we're seeing huge times in the `foreign_modules` query due to repeated iteration over foreign modules (in order to find a module by its id). This implements hash table lookups so that which massively reduces time spent in that query in this particular case. We'll need to see if the overhead of creating the hash table has a negative impact on performance in more normal compilation scenarios. I'm working with `@wesleywiser` on this.
2020-10-27Remove some cruft from foreign_modules refactorRyan Levick-2/+0
2020-10-27Cache foreign_modules queryRyan Levick-1/+1
2020-10-27Query span as late as possibleDániel Buga-9/+4
2020-10-27Rollup merge of #78396 - josephlr:ermsb, r=petrochenkovYuki Okushi-0/+1
Add compiler support for LLVM's x86_64 ERMSB feature This change is needed for compiler-builtins to check for this feature when implementing memcpy/memset. See: https://github.com/rust-lang/compiler-builtins/pull/365 Without this change, the following code compiles, but does nothing: ```rust #[cfg(target_feature = "ermsb")] pub unsafe fn ermsb_memcpy() { ... } ``` The change just does compile-time detection. I think that runtime detection will have to come in a follow-up CL to std-detect. Like all the CPU feature flags, this just references #44839 Signed-off-by: Joe Richey <joerichey@google.com>
2020-10-26Auto merge of #68965 - eddyb:mir-inline-scope, r=nagisa,oli-obkbors-116/+158
rustc_mir: track inlined callees in SourceScopeData. We now record which MIR scopes are the roots of *other* (inlined) functions's scope trees, which allows us to generate the correct debuginfo in codegen, similar to what LLVM inlining generates. This PR makes the `ui` test `backtrace-debuginfo` pass, if the MIR inliner is turned on by default. Also, `#[track_caller]` is now correct in the face of MIR inlining (cc `@anp).` Fixes #76997. r? `@rust-lang/wg-mir-opt`
2020-10-26Deduplicate span and dbg_scope adjustmentoli-18/+19
2020-10-26Prefer `bug!` over `unwrap()`oli-1/+3
2020-10-26Add compiler support for LLVM's x86 ERMSB featureJoe Richey-0/+1
This change is needed for compiler-builtins to check for this feature when implementing memcpy/memset. See: https://github.com/rust-lang/compiler-builtins/pull/365 The change just does compile-time detection. I think that runtime detection will have to come in a follow-up CL to std-detect. Like all the CPU feature flags, this just references #44839 Signed-off-by: Joe Richey <joerichey@google.com>
2020-10-26Updated documentation, x86 feature detection testing, and removed LLVM 9 ↵DevJPM-2/+2
exclusive features Updated the added documentation in llvm_util.rs to note which copies of LLVM need to be inspected. Removed avx512bf16 and avx512vp2intersect because they are unsupported before LLVM 9 with the build with external LLVM 8 being supported Re-introduced detection testing previously removed for un-requestable features tsc and mmx
2020-10-25Updated the list of white-listed target features for x86DevJPM-0/+13
This PR both adds in-source documentation on what to look out for when adding a new (X86) feature set and adds all that are detectable at run-time in Rust stable as of 1.27.0. This should only enable the use of the corresponding LLVM intrinsics. Actual intrinsics need to be added separately in rust-lang/stdarch. It also re-orders the run-time-detect test statements to be more consistent with the actual list of intrinsics whitelisted and removes underscores not present in the actual names (which might be mistaken as being part of the name)
2020-10-23Make codegen coverage_context optional, and checkRich Kadel-15/+21
Addresses Issue #78286 Libraries compiled with coverage and linked with out enabling coverage would fail when attempting to add the library's coverage statements to the codegen coverage context (None). Now, if coverage statements are encountered while compiling / linking with `-Z instrument-coverage` disabled, codegen will *not* attempt to add code regions to a coverage map, and it will not inject the LLVM instrprof_increment intrinsic calls.
2020-10-21rustc_codegen_llvm: add support for inlined function debuginfo.Eduard-Mihai Burtescu-37/+71
2020-10-21rustc_codegen_llvm: expose DILocation to rustc_codegen_ssa.Eduard-Mihai Burtescu-72/+55
2020-10-21rustc_codegen_llvm: move DISubprogram creation to a dbg_scope_fn method.Eduard-Mihai Burtescu-0/+9
2020-10-21rustc_codegen_llvm: create `DIFile`s from just `SourceFile`s.Eduard-Mihai Burtescu-29/+5
2020-10-21rustc_mir: support MIR-inlining #[track_caller] functions.Eduard-Mihai Burtescu-14/+51
2020-10-17Make set_span take mut selfkhyperia-1/+1
2020-10-16Auto merge of #77972 - Mark-Simulacrum:side-effect-loop, r=nagisabors-4/+22
Prevent miscompilation in trivial loop {} Ideally, we would want to handle a broader set of cases to fully fix the underlying bug here. That is currently relatively expensive at compile and runtime, so we don't do that for now. Performance results indicate this is not a major regression, if at all, so it should be safe to land. cc #28728
2020-10-15Prevent miscompilation in trivial loop {}Mark Rousskov-4/+22
Ideally, we would want to handle a broader set of cases to fully fix the underlying bug here. That is currently relatively expensive at compile and runtime, so we don't do that for now.
2020-10-15Remove rustc_session::config::Configest31-7/+3
The wrapper type led to tons of target.target across the compiler. Its ptr_width field isn't required any more, as target_pointer_width is already present in parsed form.
2020-10-15Replace target.target with target and target.ptr_width with target.pointer_widthest31-103/+102
Preparation for a subsequent change that replaces rustc_target::config::Config with its wrapped Target. On its own, this commit breaks the build. I don't like making build-breaking commits, but in this instance I believe that it makes review easier, as the "real" changes of this PR can be seen much more easily. Result of running: find compiler/ -type f -exec sed -i -e 's/target\.target\([)\.,; ]\)/target\1/g' {} \; find compiler/ -type f -exec sed -i -e 's/target\.target$/target/g' {} \; find compiler/ -type f -exec sed -i -e 's/target.ptr_width/target.pointer_width/g' {} \; ./x.py fmt
2020-10-15Rename target_pointer_width to pointer_width and turn it into an u32est31-2/+2
Rename target_pointer_width to pointer_width because it is already member of the Target struct. The compiler supports only three valid values for target_pointer_width: 16, 32, 64. Thus it can safely be turned into an int. This means less allocations and clones as well as easier handling of the type.
2020-10-15Rollup merge of #77739 - est31:remove_unused_code, r=petrochenkov,varkorYuki Okushi-4/+0
Remove unused code Rustc has a builtin lint for detecting unused code inside a crate, but when an item is marked `pub`, the code, even if unused inside the entire workspace, is never marked as such. Therefore, I've built [warnalyzer](https://github.com/est31/warnalyzer) to detect unused items in a cross-crate setting. Closes https://github.com/est31/warnalyzer/issues/2
2020-10-14Remove unused code from rustc_codegen_*est31-4/+0
2020-10-14Rollup merge of #77795 - bjorn3:codegen_backend_interface_refactor, r=oli-obkDylan DPC-21/+21
Codegen backend interface refactor This moves several things away from the codegen backend to rustc_interface. There are a few behavioral changes where previously the incremental cache (incorrectly) wouldn't get finalized, but now it does. See the individual commit messages.
2020-10-13Replace absolute paths with relative onesest31-5/+5
Modern compilers allow reaching external crates like std or core via relative paths in modules outside of lib.rs and main.rs.
2020-10-13Auto merge of #76830 - Artoria2e5:tune, r=nagisabors-0/+1
Pass tune-cpu to LLVM I think this is how it should work... See https://internals.rust-lang.org/t/expose-tune-cpu-from-llvm/13088 for the background. Or the documentation diff.
2020-10-13Auto merge of #77796 - jonas-schievink:switchint-refactor, r=oli-obkbors-26/+19
Refactor how SwitchInt stores jump targets Closes https://github.com/rust-lang/rust/issues/65693
2020-10-12Remove dump_incremental_databjorn3-9/+0
2020-10-12Fix -Clinker-plugin-lto with opt-levels s and zJonas Schievink-3/+1
2020-10-11Use SmallVec in SwitchTargetsJonas Schievink-1/+1
This allows building common SwitchTargets (eg. for `if`s) without allocation.
2020-10-10Refactor how SwitchInt stores jump targetsJonas Schievink-26/+19
2020-10-10Use fixed type for CodegenResultsbjorn3-3/+3
This also moves the -Zno-link implementation to rustc_interface