about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
AgeCommit message (Collapse)AuthorLines
2024-12-17Rollup merge of #134323 - Zalathar:dismantle-map-data, r=jieyouxuMatthias Krüger-204/+129
coverage: Dismantle `map_data.rs` by moving its responsibilities elsewhere This is a series of incremental changes that combine to let us get rid of `coverageinfo/map_data.rs`, by moving all of its responsibilities into more appropriate places. Some of the notable consequences are: - We once again build the per-CGU file table on the fly while preparing individual covfun records, instead of building the whole table up-front. The up-front approach was introduced by #117042 to work around various other problems in generating the covmap/covfun records, but subsequent cleanups have made that approach no longer necessary. - Expression conversion and mapping-region conversion are now performed directly in `mapgen::covfun`, which should make future changes easier. - We no longer insert unused function instances into the same map that is also used to track used function instances. This helps to decouple the handling of used vs unused functions. --- There should be no meaningful change to compiler output. The file table is no longer sorted, because reordering it would invalidate the file indices stored in individual covfun records, but the table order should still be deterministic (albeit arbitrary). There are some subsequent cleanups that I intend to investigate, but this is enough change for one PR.
2024-12-17coverage: Track used functions in a set instead of a mapZalathar-90/+37
This patch dismantles what was left of `FunctionCoverage` in `map_data.rs`, replaces `function_coverage_map` with a set, and overhauls how we prepare covfun records for unused functions.
2024-12-17coverage: Pull function source hash out of `map_data.rs`Zalathar-12/+7
2024-12-17coverage: Pull region conversion out of `map_data.rs`Zalathar-37/+14
2024-12-17coverage: Pull expression conversion out of `map_data.rs`Zalathar-33/+44
2024-12-17coverage: Build the global file table on the flyZalathar-33/+29
2024-12-17coverage: Use `is_eligible_for_coverage` to filter unused functionsZalathar-8/+7
The checks in `is_eligible_for_coverage` include `is_fn_like`, but will also exclude various function-like things that cannot possibly have coverage instrumentation.
2024-12-16rename rustc_attr to rustc_attr_parsing and create rustc_attr_data_structuresJonathan Dönszelmann-2/+2
2024-12-15Auto merge of #133417 - RalfJung:aarch64-float-abi, r=workingjubileebors-3/+3
reject aarch64 target feature toggling that would change the float ABI ~~Stacked on top of https://github.com/rust-lang/rust/pull/133099. Only the last two commits are new.~~ The first new commit lays the groundwork for separately controlling whether a feature may be enabled or disabled. The second commit uses that to make it illegal to *disable* the `neon` feature (which is only possible via `-Ctarget-feature`, and so the new check just adds a warning). Enabling the `neon` feature remains allowed on targets that don't disable `neon` or `fp-armv8`, which is all our built-in targets. This way, the entire PR is not a breaking change. Fixes https://github.com/rust-lang/rust/issues/131058 for hardfloat targets (together with https://github.com/rust-lang/rust/pull/133102 which fixed it for softfloat targets). Part of https://github.com/rust-lang/rust/issues/116344.
2024-12-14target_features: control separately whether enabling and disabling a target ↵Ralf Jung-3/+3
feature is allowed
2024-12-14Rollup merge of #134208 - Zalathar:covmap-covfun, r=compiler-errorsMatthias Krüger-65/+61
coverage: Tidy up creation of covmap and covfun records This is a small follow-up to #134163 that mostly just inlines and renames some variables, and adds a few comments. It also slightly defers the creation of the LLVM value that holds the filename table, to just before the value is needed. --- try-job: x86_64-mingw-2 try-job: dist-x86_64-linux
2024-12-13Auto merge of #133099 - RalfJung:forbidden-hardfloat-features, r=workingjubileebors-16/+20
forbid toggling x87 and fpregs on hard-float targets Part of https://github.com/rust-lang/rust/issues/116344, follow-up to https://github.com/rust-lang/rust/pull/129884: The `x87` target feature on x86 and the `fpregs` target feature on ARM must not be disabled on a hardfloat target, as that would change the float ABI. However, *enabling* `fpregs` on ARM is [explicitly requested](https://github.com/rust-lang/rust/issues/130988) as it seems to be useful. Therefore, we need to refine the distinction of "forbidden" target features and "allowed" target features: all (un)stable target features can determine on a per-target basis whether they should be allowed to be toggled or not. `fpregs` then checks whether the current target has the `soft-float` feature, and if yes, `fpregs` is permitted -- otherwise, it is not. (Same for `x87` on x86). Also fixes https://github.com/rust-lang/rust/issues/132351. Since `fpregs` and `x87` can be enabled on some builds and disabled on others, it would make sense that one can query it via `cfg`. Therefore, I made them behave in `cfg` like any other unstable target feature. The first commit prepares the infrastructure, but does not change behavior. The second commit then wires up `fpregs` and `x87` with that new infrastructure. r? `@workingjubilee`
2024-12-12coverage: Tidy up creation of covfun recordsZalathar-32/+34
2024-12-12coverage: Tidy up creation of covmap recordsZalathar-33/+27
2024-12-12Fix our `llvm::Bool` typedef to be signed, to match `LLVMBool`Zalathar-1/+3
In the LLVM-C API, boolean values are passed as `typedef int LLVMBool`, but our Rust-side typedef was using `c_uint` instead. Signed and unsigned integers have the same ABI on most platforms, but that isn't universally true, so we should prefer to be consistent with LLVM.
2024-12-12Auto merge of #129181 - beetrees:asm-spans, r=pnkfelix,compiler-errorsbors-19/+29
Pass end position of span through inline ASM cookie Before this PR, only the start position of the span was passed though the inline ASM cookie to diagnostics. LLVM 19 has full support for 64-bit inline ASM cookies; this PR uses that to pass the end position of the span in the upper 32 bits, meaning inline ASM diagnostics now point at the entire line the error occurred on, not just the first character of it.
2024-12-11Auto merge of #128004 - folkertdev:naked-fn-asm, r=Amanieubors-11/+11
codegen `#[naked]` functions using global asm tracking issue: https://github.com/rust-lang/rust/issues/90957 Fixes #124375 This implements the approach suggested in the tracking issue: use the existing global assembly infrastructure to emit the body of `#[naked]` functions. The main advantage is that we now have full control over what gets generated, and are no longer dependent on LLVM not sneakily messing with our output (inlining, adding extra instructions, etc). I discussed this approach with `@Amanieu` and while I think the general direction is correct, there is probably a bunch of stuff that needs to change or move around here. I'll leave some inline comments on things that I'm not sure about. Combined with https://github.com/rust-lang/rust/pull/127853, if both accepted, I think that resolves all steps from the tracking issue. r? `@Amanieu`
2024-12-11apply review feedbackRalf Jung-3/+5
2024-12-11generalize 'forbidden feature' concept so that even (un)stable feature can ↵Ralf Jung-16/+18
be invalid to toggle Also rename some things for extra clarity
2024-12-11Rollup merge of #134165 - durin42:wasm-target-string, r=jieyouxuMatthias Krüger-0/+5
wasm(32|64): update alignment string See llvm/llvm-project@c5ab70c508457eaece5d7ff4ab79a2f90bc67f06 `@rustbot` label: +llvm-main
2024-12-11Rollup merge of #134163 - Zalathar:covfun, r=SparrowLii,jieyouxuMatthias Krüger-182/+263
coverage: Rearrange the code for embedding per-function coverage metadata This is a series of refactorings to the code that prepares and embeds per-function coverage metadata records (“covfun records”) in the `__llvm_covfun` linker section of the final binary. The `llvm-cov` tool reads this metadata from the binary when preparing a coverage report. Beyond general cleanup, a big motivation behind these changes is to pave the way for re-landing an updated version of #133418. --- There should be no change in compiler output, as demonstrated by the absence of (meaningful) changes to coverage tests. The first patch is just moving code around, so I suggest looking at the other patches to see the actual changes. --- try-job: x86_64-gnu try-job: x86_64-msvc try-job: aarch64-apple
2024-12-11wasm(32|64): update alignment stringAugie Fackler-0/+5
See llvm/llvm-project@c5ab70c508457eaece5d7ff4ab79a2f90bc67f06 @rustbot label: +llvm-main
2024-12-11coverage: Store intermediate region tables in `CovfunRecord`Zalathar-55/+77
This defers the call to `llvm_cov::write_function_mappings_to_buffer` until just before its enclosing global variable is created.
2024-12-11coverage: Only generate a CGU's covmap record if it has covfun recordsZalathar-4/+14
2024-12-11coverage: Reify `CovfunRecord` as an intermediate stepZalathar-36/+45
2024-12-11coverage: Extract function metadata handling to a `covfun` submoduleZalathar-166/+206
2024-12-10codegen `#[naked]` functions using `global_asm!`Folkert-11/+11
2024-12-10Rollup merge of #134115 - durin42:ppc64-target-string, r=jieyouxuLeón Orell Valerian Liehr-0/+5
rustc_target: ppc64 target string fixes for LLVM 20 LLVM continues to clean these up, and we continue to make this consistent. This is similar to 9caced7badc337ced7ad89eb614621c39bd996e9, e9853961452b56997cc127b51308879b9cd09482, and a10e744fafa7eb3afef9a938097509bf4b225f84. ```@rustbot``` label: +llvm-main
2024-12-10Rollup merge of #134042 - sayantn:power8-crypto, r=jieyouxuLeón Orell Valerian Liehr-0/+3
Add the `power8-crypto` target feature Add the `power8-crypto` target feature. This will enable adding some new PPC intrinsics in stdarch (specifically AES, SHA and CLMUL intrinsics). The implied target feature is from [here](https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/PowerPC/PPC.td) ```@rustbot``` label A-target-feature O-PowerPC
2024-12-10rustc_target: ppc64 target string fixes for LLVM 20Augie Fackler-0/+5
LLVM continues to clean these up, and we continue to make this consistent. This is similar to 9caced7badc337ced7ad89eb614621c39bd996e9, e9853961452b56997cc127b51308879b9cd09482, and a10e744fafa7eb3afef9a938097509bf4b225f84. `@rustbot` label: +llvm-main
2024-12-10Rollup merge of #134029 - Zalathar:zero, r=oli-obkLeón Orell Valerian Liehr-188/+26
coverage: Use a query to find counters/expressions that must be zero As of #133446, this query (`coverage_ids_info`) determines which counter/expression IDs are unused. So with only a little extra work, we can take the code that was using that information to determine which coverage counters/expressions must be zero, and move that inside the query as well. There should be no change in compiler output.
2024-12-09Auto merge of #134052 - matthiaskrgr:rollup-puxwqrk, r=matthiaskrgrbors-8/+3
Rollup of 7 pull requests Successful merges: - #133567 (A bunch of cleanups) - #133789 (Add doc alias 'then_with' for `then` method on `bool`) - #133880 (Expand home_dir docs) - #134036 (crash tests: use individual mir opts instead of mir-opt-level where easily possible) - #134045 (Fix some triagebot mentions paths) - #134046 (Remove ignored tests for hangs w/ new solver) - #134050 (Miri subtree update) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-09Rollup merge of #133567 - bjorn3:various_cleanups, r=cjgillotMatthias Krüger-8/+3
A bunch of cleanups These are all extracted from a branch I have to get rid of driver queries. Most of the commits are not directly necessary for this, but were found in the process of implementing the removal of driver queries. Previous PR: https://github.com/rust-lang/rust/pull/132410
2024-12-09Add the `power8-crypto` target featureSayantan Chakraborty-0/+3
2024-12-08coverage: Unused functions don't need to store `CoverageIdsInfo`Zalathar-13/+13
2024-12-08coverage: Remove FunctionCoverageCollectorZalathar-70/+17
The information that was being collected by this builder type is now collected by the `coverage_ids_info` query instead.
2024-12-08coverage: Use a query to find counters/expressions that must be zeroZalathar-112/+4
This query (`coverage_ids_info`) already determines which counter/expression IDs are unused, so it only takes a little extra effort to also determine which counters/expressions must have a value of zero.
2024-12-08coverage: Move `CoverageIdsInfo` into `mir::coverage`Zalathar-3/+2
2024-12-07Remove unnecessary `int_type_width_signed` functionScott McMurray-91/+75
2024-12-06Remove polymorphizationBen Kimock-26/+3
2024-12-06Remove all threading through of ErrorGuaranteed from the driverbjorn3-8/+3
It was inconsistently done (sometimes even within a single function) and most of the rest of the compiler uses fatal errors instead, which need to be caught using catch_with_exit_code anyway. Using fatal errors instead of ErrorGuaranteed everywhere in the driver simplifies things a bit.
2024-12-05Rollup merge of #127565 - esp-rs:xtensa-vaargs, r=workingjubileeJacob Pratt-2/+111
Teach rustc about the Xtensa VaListImpl Following on from the target Xtensa target PRs (https://github.com/rust-lang/rust/pull/125141, https://github.com/rust-lang/rust/pull/126380), this PR teaches rustc about the structure of the VA list on the Xtensa arch, as well as adding the required lowering to be able to actually use it.
2024-12-03Auto merge of #104342 - mweber15:add_file_location_to_more_types, r=wesleywiserbors-27/+228
Require `type_map::stub` callers to supply file information This change attaches file information (`DIFile` reference and line number) to struct debug info nodes. Before: ``` ; foo.ll ... !5 = !DIFile(filename: "<unknown>", directory: "") ... !16 = !DICompositeType(tag: DW_TAG_structure_type, name: "MyType", scope: !2, file: !5, size: 32, align: 32, elements: !17, templateParams: !19, identifier: "4cb373851db92e732c4cb5651b886dd0") ... ``` After: ``` ; foo.ll ... !3 = !DIFile(filename: "foo.rs", directory: "/home/matt/src/rust98678", checksumkind: CSK_SHA1, checksum: "bcb9f08512c8f3b8181ef4726012bc6807bc9be4") ... !16 = !DICompositeType(tag: DW_TAG_structure_type, name: "MyType", scope: !2, file: !3, line: 3, size: 32, align: 32, elements: !17, templateParams: !19, identifier: "9e5968c7af39c148acb253912b7f409f") ... ``` Fixes #98678 r? `@wesleywiser`
2024-12-03Teach rust core about Xtensa VaListImpl and add a custom lowering of vaarg ↵Brian J. Tarricone-2/+111
for xtensa. LLVM does not include an implementation of the va_arg instruction for Xtensa. From what I understand, this is a conscious decision and instead language frontends are encouraged to implement it themselves. The rationale seems to be that loading values correctly requires language and ABI-specific knowledge that LLVM lacks. This is true of most architectures, and rustc already provides implementation for a number of them. This commit extends the support to include Xtensa. See https://lists.llvm.org/pipermail/llvm-dev/2017-August/116337.html for some discussion on the topic. Unfortunately there does not seem to be a reference document for the semantics of the va_list and va_arg on Xtensa. The most reliable source is the GCC implementation, which this commit tries to follow. Clang also provides its own compatible implementation. This was tested for all the types that rustc allows in variadics. Co-authored-by: Brian Tarricone <brian@tarricone.org> Co-authored-by: Jonathan Bastien-Filiatrault <joe@x2a.org> Co-authored-by: Paul Lietar <paul@lietar.net>
2024-12-03Rollup merge of #133395 - calebzulawski:simd_relaxed_fma, r=workingjubileeMatthias Krüger-0/+2
Add simd_relaxed_fma intrinsic Adds compiler support for https://github.com/rust-lang/portable-simd/issues/387#issuecomment-2337169786 r? `@workingjubilee` cc `@RalfJung` is this kind of nondeterminism a problem for miri/opsem?
2024-12-02Use c"lit" for CStrings without unwrapKornel-2/+2
2024-12-01Rollup merge of #133446 - Zalathar:querify, r=cjgillotJacob Pratt-91/+55
coverage: Use a query to identify which counter/expression IDs are used Given that we already have a query to identify the highest-numbered counter ID in a MIR body, we can extend that query to also build bitsets of used counter/expression IDs. That lets us avoid some messy coverage bookkeeping during the main MIR traversal for codegen. This does mean that we fail to treat some IDs as used in certain MIR-inlining scenarios, but I think that's fine, because it means that the results will be consistent across all instantiations of a function. --- There's some more cleanup I want to do in the function coverage collector, since it isn't really collecting anything any more, but I'll leave that for future work.
2024-12-01Auto merge of #133499 - nikic:no-backend-verify, r=Mark-Simulacrumbors-0/+5
Respect verify-llvm-ir option in the backend We are currently unconditionally verifying the LLVM IR in the backend (twice), ignoring the value of the verify-llvm-ir option. This has substantial compile-time impact for debug builds.
2024-11-30Rollup merge of #131551 - taiki-e:ppc-asm-vreg-inout, r=Amanieu许杰友 Jieyou Xu (Joe)-6/+46
Support input/output in vector registers of PowerPC inline assembly This extends currently clobber-only vector registers (`vreg`) support to allow passing `#[repr(simd)]` types as input/output. | Architecture | Register class | Target feature | Allowed types | | ------------ | -------------- | -------------- | -------------- | | PowerPC | `vreg` | `altivec` | `i8x16`, `i16x8`, `i32x4`, `f32x4` | | PowerPC | `vreg` | `vsx` | `f32`, `f64`, `i64x2`, `f64x2` | In addition to floats and `core::simd` types listed above, `core::arch` types and custom `#[repr(simd)]` types of the same size and type are also allowed. All allowed types and relevant target features are currently unstable. r? `@Amanieu` `@rustbot` label +O-PowerPC +A-inline-assembly
2024-11-30coverage: Use a query to identify which counter/expression IDs are usedZalathar-72/+34