about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src
AgeCommit message (Collapse)AuthorLines
2024-05-10Rollup merge of #124797 - beetrees:primitive-float, r=davidtwcoMatthias Krüger-6/+14
Refactor float `Primitive`s to a separate `Float` type Now there are 4 of them, it makes sense to refactor `F16`, `F32`, `F64` and `F128` out of `Primitive` and into a separate `Float` type (like integers already are). This allows patterns like `F16 | F32 | F64 | F128` to be simplified into `Float(_)`, and is consistent with `ty::FloatTy`. As a side effect, this PR also makes the `Ty::primitive_size` method work with `f16` and `f128`. Tracking issue: #116909 `@rustbot` label +F-f16_and_f128
2024-05-09Make builtin_deref just return a TyMichael Goulet-8/+5
2024-05-08Make SSA aggregates without needing an allocaScott McMurray-12/+99
2024-05-08Aggregating arrays can always take the place pathScott McMurray-2/+5
2024-05-08Auto merge of #124858 - alexcrichton:some-wasi-changes, r=michaelwoeristerbors-1/+7
rustc: Some small changes for the wasm32-wasip2 target This commit has a few changes for the wasm32-wasip2 target. The first two are aimed at improving the compatibility of using `clang` as an external linker driver on this target. The default target to LLVM is updated to match the Rust target and additionally the `-fuse-ld=lld` argument is dropped since that otherwise interferes with clang's own linker detection. The only linker on wasm targets is LLD but on the wasip2 target a wrapper around LLD, `wasm-component-ld`, is used to drive the process and perform steps necessary for componentization. The final commit changes the output of all objects on the wasip2 target to being PIC by default. This improves compatibilty with shared libaries but notably does not mean that there's a turnkey solution for shared libraries. The hope is that by having the standard libray work both with and without dynamic libraries will make experimentation easier.
2024-05-06Refactor float `Primitive`s to a separate `Float` typebeetrees-6/+14
2024-05-05Auto merge of #124606 - scottmcm:less-expect, r=cjgillotbors-2/+2
Stop `llvm.expect`ing assert terminators We're putting `llvm.expect` calls before the <https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/enum.TerminatorKind.html#variant.Assert> terminators. But we don't need them. One of the arms is always to a panic function that's marked `#[cold]`, which is `cold` <https://llvm.org/docs/LangRef.html#function-attributes> in LLVM, which > When computing edge weights, basic blocks post-dominated by a cold function call are also considered to be cold; and, thus, given low weight. So even without us emitting the extra intrinsic call, LLVM knows what to expect for the `br`. Thus we can save the (small) effort of emitting it and then LLVM optimizing it out. r? compiler
2024-05-04some comments or dynamic drop handlingRalf Jung-2/+2
2024-05-03rustc: Don't pass `-fuse-ld=lld` on wasm targetsAlex Crichton-1/+7
This argument isn't necessary for WebAssembly targets since `wasm-ld` is the only linker for the targets. Passing it otherwise interferes with Clang's linker selection on `wasm32-wasip2` so avoid it altogether.
2024-05-03Rollup merge of #124555 - Zalathar:init-coverage, r=nnethercoteMatthias Krüger-0/+9
coverage: Clean up creation of MC/DC condition bitmaps This PR improves the code for creating and initializing [MC/DC](https://en.wikipedia.org/wiki/Modified_condition/decision_coverage) condition bitmap variables, as introduced by #123409 and modified by #124255. - The condition bitmap variables are now created eagerly at the start of per-function codegen, via a new `init_coverage` method in `CoverageInfoBuilderMethods`. This avoids having to retroactively create the bitmaps while doing codegen for an individual coverage statement. - As a result, we can now create and initialize those bitmaps using existing safe APIs, instead of having to perform our own unsafe call to `llvm::LLVMBuildAlloca`. - This PR also tweaks the way we count the number of condition bitmaps needed, by tracking the total number of bitmaps needed (max depth + 1), instead of only tracking the maximum depth. This reduces the potential for subtle off-by-one confusion.
2024-05-02Rollup merge of #124414 - lqd:subdiagnostics, r=davidtwcoMatthias Krüger-1/+0
remove extraneous note on `UnableToRunDsymutil` diagnostic If I understand [this FIXME](https://github.com/rust-lang/rust/blob/1367827eac3d813a261a4c444037af9736996daa/compiler/rustc_macros/src/diagnostics/diagnostic.rs#L205) correctly, it seems we don't yet validate subdiagnostics, so `#[note]` and co in the `#[derive(Diagnostic]` item could be out-of-sync with the fluent message, without causing compile errors. It was the case for `rustc_codegen_ssa::errors::UnableToRunDsymutil`, causing the ICE in #124392. I've grepped and scripted my way through most of our diagnostics structs and fluent bundles and the above was the only such extraneous `#[note]`/`#[note(name)]`/`#[help]`/`#[warning]` I could find, so hopefully there aren't many others like it. I haven't checked if the opposite can happen, a `.note = ` in a fluent message that is lacking a corresponding `#[note]` on the struct and not causing an error, but maybe it's possible? r? ``@davidtwco`` fixes #124392
2024-05-01Stop `llvm.expect`ing assert terminatorsScott McMurray-2/+2
2024-05-01Step bootstrap cfgsMark Rousskov-1/+0
2024-05-01coverage: Eagerly do start-of-function codegen for coverageZalathar-0/+9
2024-04-29Remove `extern crate rustc_middle` from numerous crates.Nicholas Nethercote-6/+25
2024-04-29Remove `extern crate rustc_macros` from numerous crates.Nicholas Nethercote-2/+1
2024-04-26remove extraneous note on `UnableToRunDsymutil` diagnosticRémy Rakic-1/+0
2024-04-25debuginfo: Stabilize `-Z debug-macros`, `-Z collapse-macro-debuginfo` and ↵Vadim Petrochenkov-19/+3
`#[collapse_debuginfo]` `-Z debug-macros` is "stabilized" by enabling it by default and removing. `-Z collapse-macro-debuginfo` is stabilized as `-C collapse-macro-debuginfo`. It now supports all typical boolean values (`parse_opt_bool`) in addition to just yes/no. Default value of `collapse_debuginfo` was changed from `false` to `external` (i.e. collapsed if external, not collapsed if local). `#[collapse_debuginfo]` attribute without a value is no longer supported to avoid guessing the default.
2024-04-25Rollup merge of #124324 - nnethercote:minor-ast-cleanups, r=estebankMatthias Krüger-1/+1
Minor AST cleanups r? ``@estebank``
2024-04-24Rename `NestedMetaItem::name_value_literal`.Nicholas Nethercote-1/+1
It's a highly misleading name, because it's completely different to `MetaItem::name_value_literal`. Specifically, it doesn't match `MetaItemKind::NameValue` (e.g. `#[foo = 3]`), it matches `MetaItemKind::List` (e.g. `#[foo(3)]`).
2024-04-24Auto merge of #122053 - erikdesjardins:alloca, r=nikicbors-7/+7
Stop using LLVM struct types for alloca The alloca type has no semantic meaning, only the size (and alignment, but we specify it explicitly) matter. Using `[N x i8]` is a more direct way to specify that we want `N` bytes, and avoids relying on LLVM's struct layout. It is likely that a future LLVM version will change to an untyped alloca representation. Split out from #121577. r? `@ghost`
2024-04-23Auto merge of #121801 - zetanumbers:async_drop_glue, r=oli-obkbors-1/+45
Add simple async drop glue generation This is a prototype of the async drop glue generation for some simple types. Async drop glue is intended to behave very similar to the regular drop glue except for being asynchronous. Currently it does not execute synchronous drops but only calls user implementations of `AsyncDrop::async_drop` associative function and awaits the returned future. It is not complete as it only recurses into arrays, slices, tuples, and structs and does not have same sensible restrictions as the old `Drop` trait implementation like having the same bounds as the type definition, while code assumes their existence (requires a future work). This current design uses a workaround as it does not create any custom async destructor state machine types for ADTs, but instead uses types defined in the std library called future combinators (deferred_async_drop, chain, ready_unit). Also I recommend reading my [explainer](https://zetanumbers.github.io/book/async-drop-design.html). This is a part of the [MCP: Low level components for async drop](https://github.com/rust-lang/compiler-team/issues/727) work. Feature completeness: - [x] `AsyncDrop` trait - [ ] `async_drop_in_place_raw`/async drop glue generation support for - [x] Trivially destructible types (integers, bools, floats, string slices, pointers, references, etc.) - [x] Arrays and slices (array pointer is unsized into slice pointer) - [x] ADTs (enums, structs, unions) - [x] tuple-like types (tuples, closures) - [ ] Dynamic types (`dyn Trait`, see explainer's [proposed design](https://github.com/zetanumbers/posts/blob/main/async-drop-design.md#async-drop-glue-for-dyn-trait)) - [ ] coroutines (https://github.com/rust-lang/rust/pull/123948) - [x] Async drop glue includes sync drop glue code - [x] Cleanup branch generation for `async_drop_in_place_raw` - [ ] Union rejects non-trivially async destructible fields - [ ] `AsyncDrop` implementation requires same bounds as type definition - [ ] Skip trivially destructible fields (optimization) - [ ] New [`TyKind::AdtAsyncDestructor`](https://github.com/zetanumbers/posts/blob/main/async-drop-design.md#adt-async-destructor-types) and get rid of combinators - [ ] [Synchronously undroppable types](https://github.com/zetanumbers/posts/blob/main/async-drop-design.md#exclusively-async-drop) - [ ] Automatic async drop at the end of the scope in async context
2024-04-22Auto merge of #115120 - icedrocket:ignore-strip-on-msvc, r=michaelwoeristerbors-42/+35
Ignore `-C strip` on MSVC tl;dr - Define `-Cstrip` to only ever affect the binary; no other build artifacts. This is necessary to improve cross-platform behavior consistency: if someone wanted debug information to be contained only in separate files on all platforms, they would set `-Cstrip=symbols` and `-Csplit-debuginfo=packed`, but this would result in no PDB files on MSVC. Resolves #114215
2024-04-21Use it in the library, and `InstSimplify` it away in the easy placesScott McMurray-1/+21
2024-04-19Show files produced by --emit foo in json artifact notificationsMichael Baikov-0/+41
2024-04-18Fix disabling the export of noop async_drop_in_place_rawDaria Sukhonina-1/+4
2024-04-17Use non-exhaustive matches for TyKindDaria Sukhonina-1/+1
Also no longer export noop async_drop_in_place_raw
2024-04-17Rollup merge of #122723 - bjorn3:archive_writer_fixes, r=nnethercoteMatthias Krüger-8/+19
Use same file permissions for ar_archive_writer as the LLVM archive writer This is required to switch to ar_archive_writer in the future without regressions. In addition to this PR support for reading thin archives needs to be added (https://github.com/rust-lang/rust/issues/107407) to fix all known regressions. Fixes https://github.com/rust-lang/rust/issues/107495
2024-04-17Use the default file permissions when writingbjorn3-8/+19
static libraries with ar_archive_writer Fixes #107495
2024-04-17Make the comments for `ReturnDest` variants doc commentsbeetrees-4/+4
2024-04-16Rollup merge of #124023 - pacak:less-splody, r=jieyouxuGuillaume Gomez-8/+5
Allow workproducts without object files. This pull request partially reverts changes from e16c3b4a4421 Original motivation for this assert was described with "A WorkProduct without a saved file is useless" which was true at the time but now it is possible to have work products with other types of files (llvm-ir, asm, etc) and there are bugreports for this failure: For example: https://github.com/rust-lang/rust/issues/123695 Fixes https://github.com/rust-lang/rust/issues/123234 Now existing `assert` and `.unwrap_or_else` are unified into a single check that emits slightly more user friendly error message if an object files was meant to be produced but it's missing
2024-04-16Add simple async drop glue generationzetanumbers-0/+41
Explainer: https://zetanumbers.github.io/book/async-drop-design.html https://github.com/rust-lang/rust/pull/121801
2024-04-16Allow workproducts without object files.Michael Baikov-8/+5
This pull request partially reverts changes from e16c3b4a4421 Original motivation for this assert was described with "A WorkProduct without a saved file is useless" which was true at the time but now it is possible to have work products with other types of files (llvm-ir, asm, etc) and there are bugreports for this failure: For example: https://github.com/rust-lang/rust/issues/123695 Fixes https://github.com/rust-lang/rust/issues/123234 Now existing `assert` and `.unwrap_or_else` are unified into a single check that emits slightly more user friendly error message if an object files was meant to be produced but it's missing
2024-04-16Rollup merge of #123721 - madsmtm:fix-visionos, r=davidtwcoGuillaume Gomez-3/+4
Various visionOS fixes A few small mistakes was introduced in https://github.com/rust-lang/rust/pull/121419, probably after the rename from `xros` to `visionos`. See the commits for details. CC `@agg23` Since you reviewed https://github.com/rust-lang/rust/pull/121419 r? davidtwco
2024-04-16Rollup merge of #123687 - bjorn3:ar_archive_writer_0_2_0, r=oli-obkGuillaume Gomez-8/+1
Update ar_archive_writer to 0.2.0 This adds a whole bunch of tests checking for any difference with llvm's archive writer. It also fixes two mistakes in the porting from C++ to Rust. The first one causes a divergence for Mach-O archives which may or may not be harmless. The second will definitively cause issues, but only applies to thin archives, which rustc currently doesn't create.
2024-04-16Rollup merge of #121694 - davidtwco:stabilize-relro-level, r=Mark-SimulacrumGuillaume Gomez-1/+1
sess: stabilize `-Zrelro-level` as `-Crelro-level` Stabilise `-Zrelro-level` as `-Crelro-level`. There's no tracking issue for this flag to close.
2024-04-13Auto merge of #123854 - petrochenkov:searchdirs2, r=lqdbors-104/+16
linker: Remove laziness and caching from native search directory walks It shouldn't be necessary for performance now. Follow up to https://github.com/rust-lang/rust/pull/123827.
2024-04-13Auto merge of #123656 - lqd:linker-features, r=petrochenkovbors-25/+46
Linker flavors next steps: linker features This is my understanding of the first step towards `@petrochenkov's` vision for the future of linker flavors, described in https://github.com/rust-lang/rust/pull/119906#issuecomment-1895693162 and the discussion that followed. To summarize: having `Cc` and `Lld` embedded in linker flavors creates tension about naming, and a combinatorial explosion of flavors for each new linker feature we'd want to use. Linker features are an extension mechanism that is complementary to principal flavors, with benefits described in #119906. The most immediate use of this flag would be to turn self-contained linking on and off via features instead of flavors. For example, `-Clinker-features=+/-lld` would toggle using lld instead of selecting a precise flavor, and would be "generic" and work cross-platform (whereas linker flavors are currently more tied to targets). Under this scheme, MCP510 is expected to be `-Clink-self-contained=+linker -Zlinker-features=+lld -Zunstable-options` (though for the time being, the original flags using lld-cc flavors still work). I purposefully didn't add or document CLI support for `+/-cc`, as it would be a noop right now. I only expect that we'd initially want to stabilize `+/-lld` to begin with. r? `@petrochenkov` You had requested that minimal churn would be done to the 230 target specs and this does none yet: the linker features are inferred from the flavor since they're currently isomorphic. We of course expect this to change sooner rather than later. In the future, we can allow targets to define linker features independently from their flavor, and remove the cc and lld components from the flavors to use the features instead, this actually doesn't need to block stabilization, as we discussed. (Best reviewed per commit)
2024-04-12Auto merge of #121430 - madsmtm:mac-catalyst-iOSSupport, r=wesleywiserbors-0/+10
Add `/System/iOSSupport` to the library search path on Mac Catalyst On macOS, `/System/iOSSupport` contains iOS frameworks like UIKit, which is the whole idea of Mac Catalyst. To link to these, we need to explicitly tell the linker about the support library stubs provided in the macOS SDK under the same path. Concretely, when building a binary for Mac Catalyst, Xcode passes the following flags to the linker: ``` -iframework /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/System/iOSSupport/System/Library/Frameworks -L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/System/iOSSupport/usr/lib ``` This is not something that can be disabled (it's enabled as soon as you enable `SUPPORTS_MACCATALYST`), so I think it's pretty safe to say that we don't need an option to turn these off. I've chosen to slightly deviate from what Xcode does and use `-F` instead of `-iframework`, since we don't need to change the header search path, and this way the flags nicely match on all the linkers. From what I could tell by reading Clang sources, there shouldn't be a difference when just running the linker. CC `@BlackHoleFox,` `@shepmaster` (I accidentally let rustbot choose the reviewer).
2024-04-12Auto merge of #121426 - madsmtm:remove-cc-syslibroot, r=pnkfelixbors-1/+7
Remove redundant `-Wl,-syslibroot` Since `-isysroot` is set, [Clang already passes this when invoking the linker](https://github.com/llvm/llvm-project/blob/llvmorg-17.0.6/clang/lib/Driver/ToolChains/Darwin.cpp#L439-L442). See https://github.com/rust-lang/rust/pull/56833 for when the `-isysroot` was originally added, but didn't remove the unnecessary linker flag. CC `@BlackHoleFox` r? shepmaster
2024-04-12Rollup merge of #123249 - goolmoos:naked_variadics, r=pnkfelixMatthias Krüger-0/+7
do not add prolog for variadic naked functions fixes #99858
2024-04-12linker: Remove laziness and caching from native search directory walksVadim Petrochenkov-104/+16
It shouldn't be necessary for performance now.
2024-04-12do not add prolog for variadic naked functionsGuy Shefy-0/+7
fixes #99858
2024-04-12make CLI linker features influence the linker flavorRémy Rakic-2/+27
While they're isomorphic, we can flip the lld component where applicable, so that downstream doesn't have to check both the flavor and the linker features.
2024-04-12remove some unnecessary lifetimesRémy Rakic-23/+19
2024-04-12Rollup merge of #123827 - petrochenkov:searchdirs, r=NadrierilMatthias Krüger-15/+12
linker: Avoid some allocations in search directory iteration This is more a cleanup than actual optimization.
2024-04-11use [N x i8] for alloca typesErik Desjardins-7/+7
2024-04-12linker: Avoid some allocations in search directory iterationVadim Petrochenkov-15/+12
2024-04-11Add load/store helpers that take `PlaceValue`Scott McMurray-10/+17
2024-04-11Put `PlaceValue` into `OperandValue::Ref`, rather than 3 tuple fieldsScott McMurray-51/+52