about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
AgeCommit message (Collapse)AuthorLines
2023-11-06warn when using an unstable feature with -Ctarget-featureRalf Jung-19/+35
2023-11-04Rollup merge of #117554 - durin42:llvm-delete-dead-zext-code, r=nikicTakayuki Maeda-10/+1
consts: remove dead code around `i1` constant values `LLVMConstZext` recently got deleted, and it turns out (thanks to `@nikic` for knowing!) that this is dead code. Tests all pass for me without this logic, and per nikic: > We always generate constants in "relocatable bag of bytes" > representation, so you're never going to get a plain bool. So this should be a safe thing to do. r? `@nikic` `@rustbot` label: +llvm-main
2023-11-03consts: remove dead code around `i1` constant valuesAugie Fackler-10/+1
`LLVMConstZext` recently got deleted, and it turns out (thanks to @nikic for knowing!) that this is dead code. Tests all pass for me without this logic, and per nikic: > We always generate constants in "relocatable bag of bytes" > representation, so you're never going to get a plain bool. So this should be a safe thing to do. r? @nikic @rustbot label: +llvm-main
2023-11-02Minimize `pub` usage in `source_map.rs`.Nicholas Nethercote-1/+1
Most notably, this commit changes the `pub use crate::*;` in that file to `use crate::*;`. This requires a lot of `use` items in other crates to be adjusted, because everything defined within `rustc_span::*` was also available via `rustc_span::source_map::*`, which is bizarre. The commit also removes `SourceMap::span_to_relative_line_string`, which is unused.
2023-10-31Merge simd size and type extraction into checking whether a type is simd, as ↵Oli Scherer-48/+26
these always go together.
2023-10-31Simplify all `require_simd` invocations by moving all of the shared ↵Oli Scherer-37/+19
invocation arguments into the macro
2023-10-31don't use the moral equivalent of `assert!(false, "foo")`Oli Scherer-33/+22
2023-10-28Auto merge of #117123 - Zalathar:bad-counter-ids, r=petrochenkovbors-31/+41
coverage: Consistently remove unused counter IDs from expressions/mappings If some coverage counters were removed by MIR optimizations, we need to take care not to refer to those counter IDs in coverage mappings, and instead replace them with a constant zero value. If we don't, `llvm-cov` might see a too-large counter ID and silently discard the entire function from its coverage reports. Fixes #117012.
2023-10-28coverage: Consistently remove unused counter IDs from expressions/mappingsZalathar-31/+41
2023-10-27Link to correct issue in PassMode::Direct ptx-kernel exceptionKjetil Kjeka-1/+1
2023-10-27Documentation and error message improvements related to PassMode::Direct assertKjetil Kjeka-2/+2
Co-authored-by: Jubilee <46493976+workingjubilee@users.noreply.github.com>
2023-10-26NVPTX: Allow PassMode::Direct for ptx kernels for nowKjetil Kjeka-1/+6
2023-10-23Auto merge of #116033 - bvanjoi:fix-116032, r=petrochenkovbors-2/+0
report `unused_import` for empty reexports even it is pub Fixes #116032 An easy fix. r? `@petrochenkov` (Discovered this issue while reviewing #115993.)
2023-10-22use visibility to check unused imports and delete some stmtsbohan-2/+0
2023-10-22coverage: Emit the filenames section before encoding per-function mappingsZalathar-21/+15
Most coverage metadata is encoded into two sections in the final executable. The `__llvm_covmap` section mostly just contains a list of filenames, while the `__llvm_covfun` section contains encoded coverage maps for each instrumented function. The catch is that each per-function record also needs to contain a hash of the filenames list that it refers to. Historically this was handled by assembling most of the per-function data into a temporary list, then assembling the filenames buffer, then using the filenames hash to emit the per-function data, and then finally emitting the filenames table itself. However, now that we build the filenames table up-front (via a separate traversal of the per-function data), we can hash and emit that part first, and then emit each of the per-function records immediately after building. This removes the awkwardness of having to temporarily store nearly-complete per-function records.
2023-10-22coverage: Encode function mappings without re-sorting themZalathar-13/+15
The main change here is that `VirtualFileMapping` now uses an internal hashmap to de-duplicate incoming global file IDs. That removes the need for `encode_mappings_for_function` to re-sort its mappings by filename in order to de-duplicate them. (We still de-duplicate runs of identical filenames to save work, but this is not load-bearing for correctness, so a sort is not necessary.)
2023-10-22coverage: Encapsulate local-to-global file mappingsZalathar-5/+29
2023-10-22coverage: Build the global file table ahead of timeZalathar-25/+49
2023-10-22coverage: Fetch expressions and mappings separatelyZalathar-28/+14
The combined `get_expressions_and_counter_regions` method was an artifact of having to prepare the expressions and mappings at the same time, to avoid ownership/lifetime problems with temporary data used by both. Now that we have an explicit transition from `FunctionCoverageCollector` to the final `FunctionCoverage`, we can prepare any shared data during that step and store it in the final struct.
2023-10-22coverage: Split `FunctionCoverage` into distinct collector/finished phasesZalathar-24/+40
This gives us a clearly-defined place to run code after the instance's MIR has been traversed by codegen, but before we emit its `__llvm_covfun` record.
2023-10-21coverage: Change query `codegened_and_inlined_items` to a plain functionZalathar-3/+34
This query has a name that sounds general-purpose, but in fact it has coverage-specific semantics, and (fortunately) is only used by coverage code. Because it is only ever called once (from one designated CGU), it doesn't need to be a query, and we can change it to a regular function instead.
2023-10-21coverage: Move unused-function helpers closer to where they are usedZalathar-43/+39
2023-10-21coverage: Emit mappings for unused functions without generating stubsZalathar-74/+37
2023-10-20s/generator/coroutine/Oli Scherer-112/+112
2023-10-20s/Generator/Coroutine/Oli Scherer-18/+18
2023-10-19Auto merge of #115214 - Urgau:rfc-3127-trim-paths, r=compiler-errorsbors-40/+84
Implement rustc part of RFC 3127 trim-paths This PR implements (or at least tries to) [RFC 3127 trim-paths](https://github.com/rust-lang/rust/issues/111540), the rustc part. That is `-Zremap-path-scope` with all of it's components/scopes. `@rustbot` label: +F-trim-paths
2023-10-18coverage: Explicitly note that counter/expression IDs are function-localZalathar-0/+7
2023-10-18coverage: Store expression data in function coverage infoZalathar-78/+42
Even though expression details are now stored in the info structure, we still need to inject `ExpressionUsed` statements into MIR, because if one is missing during codegen then we know that it was optimized out and we can remap all of its associated code regions to zero.
2023-10-18coverage: Store all of a function's mappings in function coverage infoZalathar-69/+39
Previously, mappings were attached to individual coverage statements in MIR. That necessitated special handling in MIR optimizations to avoid deleting those statements, since otherwise codegen would be unable to reassemble the original list of mappings. With this change, a function's list of mappings is now attached to its MIR body, and survives intact even if individual statements are deleted by optimizations.
2023-10-18coverage: Make expression simplification non-destructiveZalathar-22/+58
Instead of modifying the accumulated expressions in-place, we now build a set of expressions that are known to be zero, and then consult that set on the fly when converting the expression data for FFI. This will be necessary when moving mappings and expression data into function coverage info, which can't be mutated during codegen.
2023-10-18coverage: Collect a function's coverage mappings into a single listZalathar-75/+51
This is an intermediate step towards being able to store all of a function's mappings in function coverage info.
2023-10-18coverage: Rename `Operand` to `CovTerm`Zalathar-22/+22
Later patches in this PR will use `CovTerm` to represent things that are not expression operands.
2023-10-18coverage: Store the number of counters/expressions in function coverage infoZalathar-15/+22
Coverage codegen can now allocate arrays based on the number of counters/expressions originally used by the instrumentor. The existing query that inspects coverage statements is still used for determining the number of counters passed to `llvm.instrprof.increment`. If some high-numbered counters were removed by MIR optimizations, the instrumented binary can potentially use less memory and disk space at runtime.
2023-10-18coverage: Attach an optional `FunctionCoverageInfo` to `mir::Body`Zalathar-49/+48
This allows coverage information to be attached to the function as a whole when appropriate, instead of being smuggled through coverage statements in the function's basic blocks. As an example, this patch moves the `function_source_hash` value out of individual `CoverageKind::Counter` statements and into the per-function info. When synthesizing unused functions for coverage purposes, the absence of this info is taken to indicate that a function was not eligible for coverage and should not be synthesized.
2023-10-17[RFC 3127 - Trim Paths]: Condition remapped filepath on remap scopesUrgau-40/+84
2023-10-16docs: add Rust logo to more compiler cratesMichael Howell-0/+3
c6e6ecb1afea9695a42d0f148ce153536b279eb5 added it to some of the compiler's crates, but avoided adding it to all of them to reduce bit-rot. This commit adds to more.
2023-10-13Format all the let chains in compilerMichael Goulet-28/+59
2023-10-13Auto merge of #115964 - bjorn3:cgu_reuse_tracker_global_state, r=cjgillotbors-2/+0
Remove cgu_reuse_tracker from Session This removes a bit of global mutable state. It will now miss post-lto cgu reuse when ThinLTO determines that a cgu doesn't get changed, but there weren't any tests for this anyway and a test for it would be fragile to the exact implementation of ThinLTO in LLVM.
2023-10-12Auto merge of #116510 - scottmcm:no-1-simd-v2, r=compiler-errorsbors-1/+6
Copy 1-element arrays as scalars, not vectors For `[T; 1]` it's silly to copy as `<1 x T>` when we can just copy as `T`. Inspired by https://github.com/rust-lang/rust/issues/101210#issuecomment-1732470941, which pointed out that `Option<[u8; 1]>` was codegenning worse than `Option<u8>`. (I'm not sure *why* LLVM doesn't optimize out `<1 x u8>`, but might as well just not emit it in the first place in this codepath.) --- I think I bit off too much in #116479; let me try just the scalar case first. r? `@ghost`
2023-10-09Remove an LTO dependent cgu_reuse_tracker.set_actual_reuse callbjorn3-2/+0
2023-10-08Make FnDef 1-ZST in LLVM debuginfo.Camille GILLOT-2/+10
2023-10-07Copy 1-element arrays as scalars, not vectorsScott McMurray-1/+6
For `[T; 1]` it's silly to copy as `<1 x T>` when we can just copy as `T`.
2023-10-05Rollup merge of #116223 - catandcoder:master, r=cjgillotJubilee-1/+1
Fix misuses of a vs an Fixes the misuse of "a" vs "an", according to English grammatical expectations and using https://www.a-or-an.com/
2023-10-04Fix misuses of a vs ancui fliter-1/+1
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-10-03coverage: Let each coverage statement hold a vector of code regionsZalathar-61/+65
This makes it possible for a `StatementKind::Coverage` to hold more than one code region, but that capability is not yet used.
2023-10-03coverage: Mappings for unused functions can all be zeroZalathar-11/+3
There is no need to include a dummy counter reference in the coverage mappings for an unused function.
2023-10-02Limit to LLVM 17.0.2 to work around WinEH codegen bugNikita Popov-4/+10
2023-10-02Reapply: Mark drop calls in landing pads cold instead of noinlineErik Desjardins-3/+5
Co-authored-by: Max Fan <git@max.fan> Co-authored-by: Nikita Popov <npopov@redhat.com>
2023-09-30Auto merge of #115933 - oli-obk:simd_shuffle_const, r=workingjubileebors-2/+55
Prototype using const generic for simd_shuffle IDX array cc https://github.com/rust-lang/rust/issues/85229 r? `@workingjubilee` on the design TLDR: there is now a `fn simd_shuffle_generic<T, U, const IDX: &'static [u32]>(x: T, y: T) -> U;` intrinsic that allows replacing ```rust simd_shuffle(a, b, const { stuff }) ``` with ```rust simd_shuffle_generic::<_, _, {&stuff}>(a, b) ``` which makes the compiler implementations much simpler, if we manage to at some point eliminate `simd_shuffle`. There are some issues with this today though (can't do math without bubbling it up in the generic arguments). With this change, we can start porting the simple cases and get better data on the others.
2023-09-29Auto merge of #115986 - onur-ozkan:fix-cross-compilation-lto-problem, ↵bors-3/+16
r=wesleywiser allow LTO on `proc-macro` crates with `-Zdylib-lto` ref https://github.com/rust-lang/rust/pull/115986#issuecomment-1732316361 Fixes #110296