Commit graph

2450 commits

Author SHA1 Message Date
Zalathar
d34c365eb0 coverage: Pull function source hash out of map_data.rs 2024-12-17 13:55:20 +11:00
Zalathar
527f8127bb coverage: Pull region conversion out of map_data.rs 2024-12-17 13:55:20 +11:00
Zalathar
252276a53d coverage: Pull expression conversion out of map_data.rs 2024-12-17 13:55:20 +11:00
Zalathar
154fae1e8d coverage: Build the global file table on the fly 2024-12-17 13:55:19 +11:00
Zalathar
fe412af4fc coverage: Use is_eligible_for_coverage to filter unused functions
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-17 13:30:11 +11:00
Jonathan Dönszelmann
efb98b6552
rename rustc_attr to rustc_attr_parsing and create rustc_attr_data_structures 2024-12-16 19:08:19 +01:00
bors
d18506299b Auto merge of #133417 - RalfJung:aarch64-float-abi, r=workingjubilee
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-15 16:32:03 +00:00
Ralf Jung
eb2e928250 target_features: control separately whether enabling and disabling a target feature is allowed 2024-12-14 08:24:18 +01:00
Matthias Krüger
704102c0f0
Rollup merge of #134208 - Zalathar:covmap-covfun, r=compiler-errors
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-14 05:01:07 +01:00
bors
327c7ee436 Auto merge of #133099 - RalfJung:forbidden-hardfloat-features, r=workingjubilee
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-13 19:43:00 +00:00
Zalathar
5f5745beb0 coverage: Tidy up creation of covfun records 2024-12-12 22:13:07 +11:00
Zalathar
de53fe245d coverage: Tidy up creation of covmap records 2024-12-12 22:10:42 +11:00
Zalathar
f7c6a2cf11 Fix our llvm::Bool typedef to be signed, to match LLVMBool
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-12 20:54:33 +11:00
bors
903d2976fd Auto merge of #129181 - beetrees:asm-spans, r=pnkfelix,compiler-errors
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-12 02:34:06 +00:00
bors
1daec069fb Auto merge of #128004 - folkertdev:naked-fn-asm, r=Amanieu
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-11 21:51:07 +00:00
Ralf Jung
60eca2c575 apply review feedback 2024-12-11 22:18:51 +01:00
Ralf Jung
2d887a5c5c generalize 'forbidden feature' concept so that even (un)stable feature can be invalid to toggle
Also rename some things for extra clarity
2024-12-11 22:11:15 +01:00
Matthias Krüger
eefefbea2f
Rollup merge of #134165 - durin42:wasm-target-string, r=jieyouxu
wasm(32|64): update alignment string

See llvm/llvm-project@c5ab70c508

`@rustbot` label: +llvm-main
2024-12-11 20:00:21 +01:00
Matthias Krüger
13c13ee4ec
Rollup merge of #134163 - Zalathar:covfun, r=SparrowLii,jieyouxu
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-11 20:00:18 +01:00
Augie Fackler
48b883287a wasm(32|64): update alignment string
See llvm/llvm-project@c5ab70c508

@rustbot label: +llvm-main
2024-12-11 05:52:59 -05:00
Zalathar
3f3a9bf7f5 coverage: Store intermediate region tables in CovfunRecord
This defers the call to `llvm_cov::write_function_mappings_to_buffer` until
just before its enclosing global variable is created.
2024-12-11 21:35:45 +11:00
Zalathar
512f3fdebe coverage: Only generate a CGU's covmap record if it has covfun records 2024-12-11 21:35:44 +11:00
Zalathar
6a8c016266 coverage: Reify CovfunRecord as an intermediate step 2024-12-11 18:25:10 +11:00
Zalathar
7c4ac71ad1 coverage: Extract function metadata handling to a covfun submodule 2024-12-11 17:49:44 +11:00
Folkert
bd8f8e0631
codegen #[naked] functions using global_asm! 2024-12-10 21:41:03 +01:00
León Orell Valerian Liehr
6d17cb833d
Rollup merge of #134115 - durin42:ppc64-target-string, r=jieyouxu
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 9caced7bad, e985396145, and
a10e744faf.

```@rustbot``` label: +llvm-main
2024-12-10 20:16:05 +01:00
León Orell Valerian Liehr
0064e731a6
Rollup merge of #134042 - sayantn:power8-crypto, r=jieyouxu
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-10 20:16:01 +01:00
Augie Fackler
0680155a17 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 9caced7bad,
e985396145, and
a10e744faf.

`@rustbot` label: +llvm-main
2024-12-10 05:54:08 -05:00
León Orell Valerian Liehr
bb8a20678c
Rollup merge of #134029 - Zalathar:zero, r=oli-obk
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-10 08:55:59 +01:00
bors
1b3fb31675 Auto merge of #134052 - matthiaskrgr:rollup-puxwqrk, r=matthiaskrgr
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-09 03:24:24 +00:00
Matthias Krüger
d2881e4eb5
Rollup merge of #133567 - bjorn3:various_cleanups, r=cjgillot
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-09 01:56:32 +01:00
Sayantan Chakraborty
1220f393cc
Add the power8-crypto target feature 2024-12-09 00:41:35 +05:30
Zalathar
3a35fb6938 coverage: Unused functions don't need to store CoverageIdsInfo 2024-12-08 21:00:53 +11:00
Zalathar
4d2bfece41 coverage: Remove FunctionCoverageCollector
The information that was being collected by this builder type is now collected
by the `coverage_ids_info` query instead.
2024-12-08 20:53:57 +11:00
Zalathar
2022ef7f12 coverage: Use a query to find counters/expressions that must be zero
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-08 20:53:39 +11:00
Zalathar
f3f7c20f7b coverage: Move CoverageIdsInfo into mir::coverage 2024-12-08 17:50:42 +11:00
Scott McMurray
18d7b9a12f Remove unnecessary int_type_width_signed function 2024-12-07 19:01:00 -08:00
Ben Kimock
711c8cc690 Remove polymorphization 2024-12-06 16:42:09 -05:00
bjorn3
401dd840ff Remove all threading through of ErrorGuaranteed from the driver
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-06 18:42:31 +00:00
Jacob Pratt
b5a7f41a87
Rollup merge of #127565 - esp-rs:xtensa-vaargs, r=workingjubilee
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-05 05:50:50 -05:00
bors
8575f8f91b Auto merge of #104342 - mweber15:add_file_location_to_more_types, r=wesleywiser
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-03 12:49:57 +00:00
Brian J. Tarricone
059f6272c3 Teach rust core about Xtensa VaListImpl and add a custom lowering of vaarg 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-03 10:54:08 +00:00
Matthias Krüger
9709334061
Rollup merge of #133395 - calebzulawski:simd_relaxed_fma, r=workingjubilee
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-03 07:48:33 +01:00
Kornel
eadea7764e
Use c"lit" for CStrings without unwrap 2024-12-02 18:16:36 +00:00
klensy
694950d73c replace copypasted ModuleLlvm::parse 2024-12-02 16:02:46 +03:00
Jacob Pratt
fa2edee758
Rollup merge of #133446 - Zalathar:querify, r=cjgillot
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-01 21:38:25 -05:00
bors
8ac313bdbe Auto merge of #133499 - nikic:no-backend-verify, r=Mark-Simulacrum
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-12-01 04:54:02 +00:00
许杰友 Jieyou Xu (Joe)
1aa01927d3
Rollup merge of #131551 - taiki-e:ppc-asm-vreg-inout, r=Amanieu
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-30 12:57:32 +08:00
Zalathar
6fc0fe76e8 coverage: Use a query to identify which counter/expression IDs are used 2024-11-30 00:58:48 +11:00
Zalathar
121a17ccc3 coverage: All counter terms in an unused function are zero
This is currently handled automatically by the fact that codegen doesn't visit
coverage statements in unused functions, but that will no longer be the case
when unused IDs are identified by a separate query instead.
2024-11-30 00:54:53 +11:00