about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm
AgeCommit message (Collapse)AuthorLines
2023-10-22coverage: Encapsulate local-to-global file mappingsZalathar-5/+29
2023-10-22coverage: Build the global file table ahead of timeZalathar-25/+50
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-15Removes the useless DisableSimplifyLibCalls parameter.DianQK-12/+4
After applying no_builtins to the function attributes, we can remove the DisableSimplifyLibCalls parameter.
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/+18
r=wesleywiser allow LTO on `proc-macro` crates with `-Zdylib-lto` ref https://github.com/rust-lang/rust/pull/115986#issuecomment-1732316361 Fixes #110296
2023-09-26Auto merge of #116144 - lcnr:subst-less, r=oli-obkbors-2/+2
subst -> instantiate continues #110793, there are still quite a few uses of `subst` and `substitute`, but changing them all in the same PR was a bit too much, so I've stopped here for now.
2023-09-26subst -> instantiatelcnr-2/+2
2023-09-25Pass name of object file to LLVM so it can correctly emit S_OBJNAMEFlorian Schmiderer-5/+17
2023-09-24Add OwnedTargetMachine to manage llvm:TargetMachine. Uses pointersFlorian Schmiderer-40/+142
instead of &'static mut and provides safe interface to create/dispose it.
2023-09-23allow LTO on `proc-macro` crates with `-Zdylib-lto`onur-ozkan-3/+18
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2023-09-22Have a single struct for queries and hookOli Scherer-3/+2
2023-09-22Add a way to decouple the implementation and the declaration of a TyCtxt method.Oli Scherer-1/+2
2023-09-21coverage: Don't bother renumbering expressions on the Rust sideZalathar-156/+64
The LLVM API that we use to encode coverage mappings already has its own code for removing unused coverage expressions and renumbering the rest. This lets us get rid of our own complex renumbering code, making it easier to change our coverage code in other ways.
2023-09-21coverage: Explicitly simplify coverage expressions in codegenZalathar-1/+57
After coverage instrumentation and MIR transformations, we can sometimes end up with coverage expressions that always have a value of zero. Any expression operand that refers to an always-zero expression can be replaced with a literal `Operand::Zero`, making the emitted coverage mapping data smaller and simpler. This simplification step is mostly redundant with the simplifications performed inline in `expressions_with_regions`, except that it does a slightly more thorough job in some cases (because it checks for always-zero expressions *after* other simplifications). However, adding this simplification step will then let us greatly simplify that code, without affecting the quality of the emitted coverage maps.
2023-09-21coverage: Make the zero counter a constantZalathar-15/+12
2023-09-18Prototype using const generic for simd_shuffle IDX arrayOli Scherer-2/+55
2023-09-15cannot have Direct for unsized typesRalf Jung-0/+5
2023-09-15clarify PassMode::Indirect as wellRalf Jung-15/+20
2023-09-15explain PassMode::CastRalf Jung-10/+12
2023-09-14Auto merge of #115817 - fee1-dead-contrib:fix-codegen, r=oli-obkbors-1/+3
treat host effect params as erased in codegen This fixes the changes brought to codegen tests when effect params are added to libcore, by not attempting to monomorphize functions that get the host param by being `const fn`. r? `@oli-obk`