about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src
AgeCommit message (Collapse)AuthorLines
2024-12-16rename rustc_attr to rustc_attr_parsing and create rustc_attr_data_structuresJonathan Dönszelmann-7/+8
2024-12-16split attributesJonathan Dönszelmann-3/+5
2024-12-15Auto merge of #131808 - jdonszelmann:hir-attributes, r=oli-obk,petrochenkovbors-51/+46
Hir attributes This PR needs some explanation, it's somewhat large. - This is step one as described in https://github.com/rust-lang/compiler-team/issues/796. I've added a new `hir::Attribute` which is a lowered version of `ast::Attribute`. Right now, this has few concrete effects, however every place that after this PR parses a `hir::Attribute` should later get a pre-parsed attribute as described in https://github.com/rust-lang/compiler-team/issues/796 and transitively https://github.com/rust-lang/rust/issues/131229. - an extension trait `AttributeExt` is added, which is implemented for both `ast::Attribute` and `hir::Atribute`. This makes `hir::Attributes` mostly compatible with code that used to parse `ast::Attribute`. All its methods are also added as inherent methods to avoid having to import the trait everywhere in the compiler. - Incremental can not not hash `ast::Attribute` at all.
2024-12-15Add hir::AttributeJonathan Dönszelmann-51/+46
2024-12-15Auto merge of #133417 - RalfJung:aarch64-float-abi, r=workingjubileebors-2/+2
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-15Auto merge of #134117 - DianQK:gep-i8, r=oli-obkbors-4/+1
Modifies the index instruction from `gep [0 x %Type]` to `gep %Type` Fixes #133979. This PR modifies the index instruction from `gep [0 x %Type]` to `gep %Type`, which is the same with pointer offset calculation. This will help LLVM calculate various formats of GEP instructions. According to [[RFC] Replacing getelementptr with ptradd](https://discourse.llvm.org/t/rfc-replacing-getelementptr-with-ptradd/68699), we ultimately aim to canonicalize everything to `gep i8`. Based on the results from https://github.com/rust-lang/rust/pull/134117#issuecomment-2531717076, I think we still need to investigate some missing optimizations, so this PR is just a small step forward. r? compiler
2024-12-15Simplify the GEP instruction for indexDianQK-4/+1
2024-12-15Rollup merge of #134285 - oli-obk:push-vwrqsqlwnuxo, r=UrgauStuart Cook-2/+2
Add some convenience helper methods on `hir::Safety` Makes a lot of call sites simpler and should make any refactorings needed for https://github.com/rust-lang/rust/pull/134090#issuecomment-2541332415 simpler, as fewer sites have to be touched in case we end up storing some information in the variants of `hir::Safety`
2024-12-15Rollup merge of #133633 - jyn514:hide-linker-args, r=bjorn3,jyn514Stuart Cook-6/+68
don't show the full linker args unless `--verbose` is passed the linker arguments can be *very* long, especially for crates with many dependencies. often they are not useful. omit them unless the user specifically requests them. split out from https://github.com/rust-lang/rust/pull/119286. fixes https://github.com/rust-lang/rust/issues/109979. r? `@bjorn3` try-build: i686-mingw
2024-12-14don't show the full linker args unless `--verbose` is passedjyn-6/+68
the linker arguments can be *very* long, especially for crates with many dependencies. some parts of them are not very useful. unless specifically requested: - omit object files specific to the current invocation - fold rlib files into a single braced argument (in shell expansion format) this shortens the output significantly without removing too much information.
2024-12-14Add some convenience helper methods on `hir::Safety`Oli Scherer-2/+2
2024-12-14target_features: control separately whether enabling and disabling a target ↵Ralf Jung-2/+2
feature is allowed
2024-12-14Rollup merge of #134251 - bjorn3:various_cleanups2, r=oli-obkMatthias Krüger-27/+16
A bunch of cleanups (part 2) Just like https://github.com/rust-lang/rust/pull/133567 these were all found while looking at the respective code, but are not blocking any other changes I want to make in the short term.
2024-12-13Auto merge of #133099 - RalfJung:forbidden-hardfloat-features, r=workingjubileebors-31/+26
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-13Make dependency_formats an FxIndexMap rather than a list of tuplesbjorn3-22/+14
It is treated as a map already. This is using FxIndexMap rather than UnordMap because the latter doesn't provide an api to pick a single value iff all values are equal, which each_linked_rlib depends on.
2024-12-13Remove jobserver from Sessionbjorn3-5/+2
It is effectively a global resource and the jobserver::Client in Session was a clone of GLOBAL_CLIENT anyway.
2024-12-12Auto merge of #129181 - beetrees:asm-spans, r=pnkfelix,compiler-errorsbors-13/+8
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-5/+294
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-2/+2
2024-12-11generalize 'forbidden feature' concept so that even (un)stable feature can ↵Ralf Jung-31/+26
be invalid to toggle Also rename some things for extra clarity
2024-12-11Rollup merge of #134139 - mustartt:pgo-linker-flag, r=saethlinJacob Pratt-0/+2
[AIX] keep profile-rt symbol alive Clang passes `-u __llvm_profile_runtime` on AIX. https://reviews.llvm.org/D136192 We want to preserve the symbol in the case there are no instrumented object files.
2024-12-10emit `.weak_definition` instead of `.weak` on macosFolkert de Vries-28/+37
2024-12-10codegen `#[naked]` functions using `global_asm!`Folkert-5/+285
2024-12-10Auto merge of #134125 - fmease:rollup-u38o3ob, r=fmeasebors-0/+9
Rollup of 11 pull requests Successful merges: - #133478 (jsondocck: Parse, don't validate commands.) - #133967 ([AIX] Pass -bnoipath when adding rust upstream dynamic crates) - #133970 ([AIX] Replace sa_sigaction with sa_union.__su_sigaction for AIX) - #133980 ([AIX] Remove option "-n" from AIX "ln" command) - #134008 (Make `Copy` unsafe to implement for ADTs with `unsafe` fields) - #134017 (Don't use `AsyncFnOnce::CallOnceFuture` bounds for signature deduction) - #134023 (handle cygwin environment in `install::sanitize_sh`) - #134041 (Use SourceMap to load debugger visualizer files) - #134065 (Move `write_graphviz_results`) - #134106 (Add compiler-maintainers who requested to be on review rotation) - #134123 (bootstrap: Forward cargo JSON output to stdout, not stderr) Failed merges: - #134120 (Remove Felix from ping groups and review rotation) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-10Rollup merge of #133967 - daltenty:daltenty/bnoipath, r=jieyouxuLeón Orell Valerian Liehr-0/+9
[AIX] Pass -bnoipath when adding rust upstream dynamic crates Unlike ELF linkers, AIX doesn't feature `DT_SONAME` to override the dependency name when outputing a shared library, which is something we rely on for dylib crates. See for reference: https://github.com/rust-lang/rust/blob/bc145cec4565a97a1b08df52d26ddf48ce3d7d0a/compiler/rustc_codegen_ssa/src/back/linker.rs#L464) Thus, `ld` on AIX will use the full path to shared libraries as the dependency if passed it by default unless `noipath` is passed, so pass it here so we don't end up with full path dependencies for dylib crates.
2024-12-10Rollup merge of #131558 - ↵León Orell Valerian Liehr-4/+67
sassman:feat/warnin-for-no-mangle-together-with-export-name, r=Urgau Lint on combining `#[no_mangle]` and `#[export_name]` This is my very first contribution to the compiler, even though I read the [chapter about lints](https://rustc-dev-guide.rust-lang.org/diagnostics.html) I'm not very certain that this ~~new lint is done right as a builtin lint~~ PR is right. I appreciate any guidance on how to improve the code. - Add test for issue #47446 - ~~Implement the new lint `mixed_export_name_and_no_mangle` as a builtin lint (not sure if that is the right way to go)~~ Extend `unused_attributes` lint - Add suggestion how to fix it <details> <summary>Old proposed new lint</summary> > The `mixed_export_name_and_no_mangle` lint detects usage of both `#[export_name]` and `#[no_mangle]` on the same item which results on `#[no_mangle]` being ignored. > > *warn-by-default* > > ### Example > > ```rust > #[no_mangle] // ignored > #[export_name = "foo"] // takes precedences > pub fn bar() {} > ``` > > ### Explanation > > The compiler will not respect the `#[no_mangle]` attribute when generating the symbol name for the function, as the `#[export_name]` attribute takes precedence. This can lead to confusion and is unnecessary. </details>
2024-12-09Apply suggestions from code reviewSven Kanoldt-8/+8
commit suggestion of not always pretty printing Co-authored-by: Urgau <3616612+Urgau@users.noreply.github.com>
2024-12-09Rollup merge of #133567 - bjorn3:various_cleanups, r=cjgillotMatthias Krüger-43/+31
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-08Pass the arch rather than full target name to windows_registry::find_toolbjorn3-8/+3
The full target name can be anything with custom target specs. Passing just the arch wasn't possible before cc 1.2, but is now.
2024-12-06Remove polymorphizationBen Kimock-13/+11
2024-12-06Remove all threading through of ErrorGuaranteed from the driverbjorn3-40/+26
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-06Store a single copy of the error registry in DiagCtxtbjorn3-1/+5
And pass this to the individual emitters when necessary.
2024-12-06Move some timers aroundbjorn3-2/+0
2024-12-06Clarify commentDavid Tenty-2/+4
2024-12-06Pass -bnoipath when adding rust upstream dynamic cratesKai Luo-0/+7
2024-12-03keep profile-rt symbol aliveHenry Jiang-0/+2
2024-12-03Rollup merge of #133041 - madsmtm:print-deployment-target-env-var, r=davidtwcoMatthias Krüger-1/+1
Print name of env var in `--print=deployment-target` The deployment target environment variable is OS-specific, and if you're in a place where you're asking `rustc` for the deployment target, you're likely to also wanna know the name of the environment variable. I myself wanted this for some code I'm working on in bootstrap, for example. Behaviour before this PR: ```console $ rustc --print=deployment-target --target=aarch64-apple-darwin deployment_target=11.0 $ rustc --print=deployment-target --target=aarch64-apple-visionos deployment_target=1.0 ``` Behaviour after this PR: ```console $ rustc --print=deployment-target --target=aarch64-apple-darwin MACOSX_DEPLOYMENT_TARGET=11.0 $ rustc --print=deployment-target --target=aarch64-apple-visionos XROS_DEPLOYMENT_TARGET=1.0 ``` My _belief_ is that this option is extremely rarely used in general, and a GitHub search for "rustc print deployment-target" seems to confirm this, it revealed only the following actual pieces of code using this: - https://github.com/PyO3/maturin/blob/b292ef69349f2a56cb8ab1b59fda0be3d3b9f138/src/build_context.rs#L1199-L1220 - https://github.com/rust-lang/cc-rs/blob/daab9244b03e244c4f2511944870d719c443f61f/src/lib.rs#L3422-L3426 `maturin` does `.split('=').last()`, so it will continue to work after this change, but `cc v1.0.84` did `.strip_prefix("deployment_target=")` since [this PR](https://github.com/rust-lang/cc-rs/pull/848), so it would break. That's _probably_ fine though, it was broken in a lot of scenarios anyway, and [got](https://github.com/rust-lang/cc-rs/pull/901) [reverted](https://github.com/rust-lang/cc-rs/pull/943) in `v1.0.85`. So while this is _technically_ a breaking change, I really doubt that anyone is going to observe it, so it's probably fine. ``@BlackHoleFox`` wdyt? ``@rustbot`` label O-apple r? compiler
2024-12-01Rollup merge of #132974 - madsmtm:linker-arguments-with-commas, r=petrochenkovMatthias Krüger-61/+82
Properly pass linker arguments that contain commas When linking with the system C compiler, we sometimes want to forward certain arguments unchanged to the linker. This can be done with `-Wl,arg1,arg2` or `-Xlinker arg1 -Xlinker arg2`. `-Wl` is used when possible, since it is more compact, but it does not support commas in the argument itself - in those cases, we need to use `-Xlinker`, and that is what this PR implements. This also fixes using sanitizers on macOS with `-Clinker-flavor=ld`, as those were previously manually using `-Wl`/`-Xlinker` (probably since the support wasn't present in the `link_args` function). Note that there has been [a previous PR for this](https://github.com/rust-lang/rust/pull/38798), but it only implemented this in certain cases when passing `-rpath`. r? compiler
2024-11-30Rollup merge of #131698 - the8472:remove-set-discriminant-hack, r=RalfJungRalf Jung-8/+16
use stores of the correct size to set discriminants Resolves an old HACK /FIXME. Note that I haven't worked much with codegen so I'm not sure if I'm using the functions correctly and I was surprised seeing out-of-range values being fed into `const_uint_big` but apparently they're wrapped implicitly? By making it explicit we can pass in-range values instead.
2024-11-30use stores of the correct size to set discriminantsThe 8472-8/+16
2024-11-28Auto merge of #123244 - Mark-Simulacrum:share-inline-never-generics, r=saethlinbors-1/+11
Enable -Zshare-generics for inline(never) functions This avoids inlining cross-crate generic items when possible that are already marked inline(never), implying that the author is not intending for the function to be inlined by callers. As such, having a local copy may make it easier for LLVM to optimize but mostly just adds to binary bloat and codegen time. In practice our benchmarks indicate this is indeed a win for larger compilations, where the extra cost in dynamic linking to these symbols is diminished compared to the advantages in fewer copies that need optimizing in each binary. It might also make sense it expand this with other heuristics (e.g., `#[cold]`) in the future, but this seems like a good starting point. FWIW, I expect that doing cleanup in where we make the decision what should/shouldn't be shared is also a good idea. Way too much code needed to be tweaked to check this. But I'm hoping to leave that for a follow-up PR rather than blocking this on it.
2024-11-28Share inline(never) generics across cratesMark Rousskov-1/+11
This reduces code sizes and better respects programmer intent when marking inline(never). Previously such a marking was essentially ignored for generic functions, as we'd still inline them in remote crates.
2024-11-27use intra-doc links for CodegenBackend::linkMonadic Cat-1/+1
2024-11-27update comment (codegen_backend -> codegen_crate)Monadic Cat-2/+2
use intra-doc links so there'll be a doc gen fail next time this becomes wrong
2024-11-26Pass end position of span through inline ASM cookiebeetrees-13/+8
2024-11-25Rollup merge of #133384 - RalfJung:vector-abi-check-tests, r=jieyouxu许杰友 Jieyou Xu (Joe)-3/+3
add a test for target-feature-ABI warnings in closures and when calling extern fn Also update the comment regarding the inheritance of target features into closures, to make it more clear that we really shouldn't do this right now.
2024-11-25Rollup merge of #133297 - DianQK:embed-bitcode-ios, r=nikic许杰友 Jieyou Xu (Joe)-4/+2
Remove legacy bitcode for iOS Follow #117364.
2024-11-24add a test for target-feature-ABI warnings in closuresRalf Jung-3/+3
2024-11-24Remove forces_embed_bitcodeDianQK-4/+2
2024-11-24Remove unnecessary 0 link args optimizationMads Marquart-14/+3