about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src
AgeCommit message (Collapse)AuthorLines
2023-02-01ast: Optimize list and value extraction primitives for attributesVadim Petrochenkov-50/+38
It's not necessary to convert the whole attribute into a meta item to extract something specific
2023-02-01Auto merge of #107257 - inquisitivecrystal:ffi-attr, r=davidtwcobors-47/+3
Strengthen validation of FFI attributes Previously, `codegen_attrs` validated the attributes `#[ffi_pure]`, `#[ffi_const]`, and `#[ffi_returns_twice]` to make sure that they were only used on foreign functions. However, this validation was insufficient in two ways: 1. `codegen_attrs` only sees items for which code must be generated, so it was unable to raise errors when the attribute was incorrectly applied to macros and the like. 2. the validation code only checked that the item with the attr was foreign, but not that it was a foreign function, allowing these attributes to be applied to foreign statics as well. This PR moves the validation to `check_attr`, which sees all items. It additionally changes the validation to ensure that the attribute's target is `Target::ForeignFunction`, only allowing the attributes on foreign functions and not foreign statics. Because these attributes are unstable, there is no risk for backwards compatibility. The changes also ending up making the code much easier to read. This PR is best reviewed commit by commit. Additionally, I was considering moving the tests to the `attribute` subdirectory, to get them out of the general UI directory. I could do that as part of this PR or a follow-up, as the reviewer prefers. CC: #58328, #58329
2023-02-01Stabilize `#![feature(target_feature_11)]`Léo Lanteri Thauvin-29/+18
2023-02-01Stabilize cmpxchg16b_target_featureNugine-2/+1
2023-01-30session: diagnostic migration lint on more fnsDavid Wood-2/+7
Apply the diagnostic migration lint to more functions on `Session`. Signed-off-by: David Wood <david.wood@huawei.com>
2023-01-29Auto merge of #107435 - matthiaskrgr:rollup-if5h6yu, r=matthiaskrgrbors-11/+22
Rollup of 8 pull requests Successful merges: - #106618 (Disable `linux_ext` in wasm32 and fortanix rustdoc builds.) - #107097 (Fix def-use dominance check) - #107154 (library/std/sys_common: Define MIN_ALIGN for m68k-unknown-linux-gnu) - #107397 (Gracefully exit if --keep-stage flag is used on a clean source tree) - #107401 (remove the usize field from CandidateSource::AliasBound) - #107413 (make more pleasant to read) - #107422 (Also erase substs for new infcx in pin move error) - #107425 (Check for missing space between fat arrow and range pattern) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-01-29Rollup merge of #107097 - tmiasko:ssa, r=cjgillotMatthias Krüger-11/+22
Fix def-use dominance check A definition does not dominate a use in the same statement. For example in MIR generated for compound assignment x += a (when overflow checks are disabled).
2023-01-29Auto merge of #106227 - bryangarza:ctfe-limit, r=oli-obkbors-0/+1
Use stable metric for const eval limit instead of current terminator-based logic This patch adds a `MirPass` that inserts a new MIR instruction `ConstEvalCounter` to any loops and function calls in the CFG. This instruction is used during Const Eval to count against the `const_eval_limit`, and emit the `StepLimitReached` error, replacing the current logic which uses Terminators only. The new method of counting loops and function calls should be more stable across compiler versions (i.e., not cause crates that compiled successfully before, to no longer compile when changes to the MIR generation/optimization are made). Also see: #103877
2023-01-28Auto merge of #107360 - bjorn3:fix_thin_archive_reading, r=wesleywiserbors-34/+36
Fix thin archive reading This includes a revert of https://github.com/rust-lang/rust/pull/105221 to restore fat archive reading with LlvmArchiveBuilder. Should fix #107162, #107334 and https://github.com/google/shaderc-rs/issues/133
2023-01-27Introduce GeneratorWitnessMIR.Camille GILLOT-0/+1
2023-01-27Auto merge of #107055 - kylematsuda:eb-fn-sig, r=lcnrbors-4/+4
Switch to `EarlyBinder` for `fn_sig` query Part of the work to finish #105779 (also see https://github.com/rust-lang/types-team/issues/78). Several queries `X` have a `bound_X` variant that wraps the output in [`EarlyBinder`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/subst/struct.EarlyBinder.html). This adds `EarlyBinder` to the return type of the `fn_sig` query and removes `bound_fn_sig`. r? `@lcnr`
2023-01-27Revert "Avoid a temporary file when processing macOS fat archives"bjorn3-34/+36
This reverts commit bd8e476d8bd85b6d60a0de7694d154b4a74f5133.
2023-01-26add EarlyBinder::no_bound_varsKyle Matsuda-1/+1
2023-01-26change fn_sig query to use EarlyBinder; remove bound_fn_sig query; add ↵Kyle Matsuda-4/+4
EarlyBinder to fn_sig in metadata
2023-01-27Auto merge of #106959 - tmiasko:opt-funclets, r=davidtwcobors-43/+40
Omit needless funclet partitioning
2023-01-26replace usages of fn_sig query with bound_fn_sigKyle Matsuda-3/+3
2023-01-27Fix def-use dominance checkTomasz Miąsko-11/+22
A definition does not dominate a use in the same statement. For example in MIR generated for compound assignment x += a (when overflow checks are disabled).
2023-01-26Rollup merge of #106904 - khuey:preserve_debuginfo_for_rlibs, r=davidtwcoMatthias Krüger-6/+0
Preserve split DWARF files when building archives. r? ```@davidtwco```
2023-01-26Auto merge of #107318 - matthiaskrgr:rollup-776kd81, r=matthiaskrgrbors-1/+2
Rollup of 9 pull requests Successful merges: - #97373 (impl DispatchFromDyn for Cell and UnsafeCell) - #106625 (Remove backwards compat for LLVM 12 coverage format) - #106779 (Avoid __cxa_thread_atexit_impl on Emscripten) - #106811 (Append .dwp to the binary filename instead of replacing the existing extension.) - #106836 (Remove optimistic spinning from `mpsc::SyncSender`) - #106946 (implement Hash for proc_macro::LineColumn) - #107074 (remove unnecessary check for opaque types) - #107287 (Improve fn pointer notes) - #107304 (Use `can_eq` to compare types for default assoc type error) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-01-26Rollup merge of #106811 - khuey:dwp_extension, r=davidtwcoMatthias Krüger-1/+2
Append .dwp to the binary filename instead of replacing the existing extension. gdb et al. expect to find the dwp file at `<binary>`.dwp, even if <binary> already has an extension (e.g. libfoo.so's dwp is expected to be at libfoo.so.dwp).
2023-01-26Auto merge of #107314 - matthiaskrgr:rollup-j40lnlj, r=matthiaskrgrbors-9/+12
Rollup of 11 pull requests Successful merges: - #106407 (Improve proc macro attribute diagnostics) - #106960 (Teach parser to understand fake anonymous enum syntax) - #107085 (Custom MIR: Support binary and unary operations) - #107086 (Print PID holding bootstrap build lock on Linux) - #107175 (Fix escaping inference var ICE in `point_at_expr_source_of_inferred_type`) - #107204 (suggest qualifying bare associated constants) - #107248 (abi: add AddressSpace field to Primitive::Pointer ) - #107272 (Implement ObjectSafe and WF in the new solver) - #107285 (Implement `Generator` and `Future` in the new solver) - #107286 (ICE in new solver if we see an inference variable) - #107313 (Add Style Team Triagebot config) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-01-26Auto merge of #105582 - saethlin:instcombine-assert-inhabited, r=cjgillotbors-2/+2
InstCombine away intrinsic validity assertions This optimization (currently) fires 246 times on the standard library. It seems to fire hardly at all on the big crates in the benchmark suite. Interesting.
2023-01-24Move FFI attribute validation to `check_attr`inquisitivecrystal-47/+3
2023-01-23Thread a ParamEnv down to might_permit_raw_initBen Kimock-2/+2
2023-01-23Create stable metric to measure long computation in Const EvalBryan Garza-0/+1
This patch adds a `MirPass` that tracks the number of back-edges and function calls in the CFG, adds a new MIR instruction to increment a counter every time they are encountered during Const Eval, and emit a warning if a configured limit is breached.
2023-01-22abi: add `AddressSpace` field to `Primitive::Pointer`Erik Desjardins-9/+12
...and remove it from `PointeeInfo`, which isn't meant for this. There are still various places (marked with FIXMEs) that assume all pointers have the same size and alignment. Fixing this requires parsing non-default address spaces in the data layout string, which will be done in a followup.
2023-01-19Allow for more efficient sorting when exporting Unord collections.Michael Woerister-1/+1
2023-01-19Use UnordMap instead of FxHashMap in define_id_collections!().Michael Woerister-5/+9
2023-01-19Use UnordSet instead of FxHashSet in define_id_collections!().Michael Woerister-6/+9
2023-01-17Rollup merge of #104505 - WaffleLapkin:no-double-spaces-in-comments, r=jackh726Matthias Krüger-14/+14
Remove double spaces after dots in comments Most of the comments do not have double spaces, so I assume these are typos.
2023-01-17Remove double spaces after dots in commentsMaybe Waffle-14/+14
2023-01-16Append .dwp to the binary filename instead of replacing the existing extension.Kyle Huey-1/+2
gdb et al. expect to find the dwp file at <binary>.dwp, even if <binary> already has an extension (e.g. libfoo.so's dwp is expected to be at libfoo.so.dwp).
2023-01-17Omit needless funclet partitioningTomasz Miąsko-43/+40
2023-01-15Preserve split DWARF files when building archives.Kyle Huey-6/+0
The optimization that removes artifacts when building libraries is correct from the compiler's perspective but not from a debugger's perspective. Unpacked split debuginfo is referred to by filename and debuggers need the artifact that contains debuginfo to continue to exist at that path. Ironically the test expects the correct behavior but it was not running.
2023-01-14Auto merge of #106646 - Amanieu:ilp32-object, r=Mark-Simulacrumbors-1/+7
Fix aarch64-unknown-linux-gnu_ilp32 target This was broken because the synthetic object files produced by rustc were for 64-bit AArch64, which caused link failures when combined with 32-bit ILP32 object files. This PR updates the object crate to 0.30.1 which adds support for generating ILP32 AArch64 object files.
2023-01-13Rollup merge of #106797 - FawazTirmizi:dev/issues/104284, r=bjorn3Matthias Krüger-5/+17
riscv: Fix ELF header flags The previous version added both `EF_RISCV_FLOAT_ABI_DOUBLE` and `EF_RISCV_RVC` if the "D" extension was enabled on riscv64 targets. riscv32 targets were not accounted for. This patch changes this so that: - Only add `EF_RISCV_RVC` if the "C" extension is enabled - Add `EF_RISCV_FLOAT_ABI_SINGLE` if the "F" extension is enabled and the "D" extension is not - Add these ELF flags for riscv32 as well Fixes #104284 r? rust-lang/risc-v
2023-01-13Improve linker-flavor detectionJonathan Schwender-1/+10
Linker drivers such as gcc, clang or lld often have a version postfix, e.g clang-12. The previous logic would not account for this and would fall back to guessing the linker flavor to be the default linker flavor for the target, which causes linker errors when this is not the case. By accounting for the possible version postfix and also considering g++ and clang++, we considerably reduce the amount of times the fallback guess has to be used. To simplify matching check for a version postfix and match against the linker stem without any version postfix. In contrast to gcc, clang supports all architectures in one binary. This means there are no variants like `aarch64-linux-gnu-clang` and there is no need to check for `-clang` variants.
2023-01-12riscv: Fix ELF header flagsFawaz-5/+17
The previous version added both `EF_RISCV_FLOAT_ABI_DOUBLE` and `EF_RISCV_RVC` if the "D" extension was enabled on riscv64 targets. riscv32 targets were not accounted for. This patch changes this so that: - Only add `EF_RISCV_RVC` if the "C" extension is enabled - Add `EF_RISCV_FLOAT_ABI_SINGLE` if the "F" extension is enabled and the "D" extension is not - Add these ELF flags for riscv32 as well
2023-01-12Auto merge of #106760 - compiler-errors:rollup-0bogyco, r=compiler-errorsbors-2/+1
Rollup of 8 pull requests Successful merges: - #103236 (doc: rewrite doc for signed int::{carrying_add,borrowing_sub}) - #103800 (Stabilize `::{core,std}::pin::pin!`) - #106097 (Migrate mir_build diagnostics 2 of 3) - #106170 (Move autoderef to `rustc_hir_analysis`) - #106323 (Stabilize f16c_target_feature) - #106360 (Tweak E0277 `&`-removal suggestions) - #106524 (Label `struct/enum constructor` instead of `fn item`, mention that it should be called on type mismatch) - #106739 (Remove `<dyn AstConv<'tcx>>::fun(c, ...)` calls in favour of `c.astconv().fun(...)`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-01-11Rollup merge of #106323 - starkat99:stabilize-f16c_target_feature, ↵Michael Goulet-2/+1
r=petrochenkov Stabilize f16c_target_feature Resolves https://github.com/rust-lang/stdarch/issues/1234 Library PR for stabilizing corresponding intrinsics: https://github.com/rust-lang/stdarch/pull/1366 See also #44839 tracking issue for target_feature
2023-01-12Rollup merge of #106532 - compiler-errors:dyn-star-to-dyn, r=jackh726Matthias Krüger-3/+1
Allow codegen to unsize `dyn*` to `dyn` `dyn* Trait` is just another type that implements `Trait`, so we should be able to unsize `&dyn* Trait` into `&dyn Trait` perfectly fine, same for `Box` and other unsizeable types. Fixes #106488
2023-01-11Allow codegen to unsize dyn* to dynMichael Goulet-3/+1
2023-01-11Fix some typos in code comments.Cedric-9/+9
2023-01-10Add comment to cleanup_kindsTomasz Miąsko-0/+3
based on the original commit message 1ae7ae0c1c7ed68c616273f245647afa47f3cbde
2023-01-09Fix aarch64-unknown-linux-gnu_ilp32 targetAmanieu d'Antras-1/+7
This was broken because the synthetic object files produced by rustc were for 64-bit AArch64, which caused link failures when combined with 32-bit ILP32 object files. This PR updates the object crate to 0.30.1 which adds support for generating ILP32 AArch64 object files.
2023-01-07Rollup merge of #104543 - ↵Matthias Krüger-74/+459
JhonnyBillM:migrate-codegen-ssa-to-diagnostics-structs-pt3, r=davidtwco Migrate `codegen_ssa` to diagnostics structs - [Part 3] Completes migrating `codegen_ssa` module except 2 outstanding errors that depend on other crates: 1. [`rustc_middle::mir::interpret::InterpError`](https://github.com/rust-lang/rust/blob/b6097f2e1b2ca62e188ba53cf43bd66b06b36915/compiler/rustc_middle/src/mir/interpret/error.rs#L475): I saw `rustc_middle` is unassigned, I am open to take this work. 2. `codegen_llvm`'s use of `fn span_invalid_monomorphization_error`, which I started to replace in the [last commit](https://github.com/rust-lang/rust/commit/9a31b3cdda78a2c0891828254fe9886e0a1cfd16) of this PR, but would like to know the team's preference on how we should keep replacing the other macros: 2.1. Update macros to expect a `Diagnostic` 2.2. Remove macros and expand the code on each use. See [some examples of the different options in this experimental commit](https://github.com/JhonnyBillM/rust/commit/64aee83e80857dcfa450f0c6e31d5f29c6d577e6) _Part 2 - https://github.com/rust-lang/rust/pull/103792_ r? ``@davidtwco`` Cc ``@compiler-errors``
2023-01-04Auto merge of #106224 - bjorn3:staticlib_fixes, r=wesleywiserbors-83/+81
Small fixes for --crate-type staticlib The first commit doesn't have an effect until we start translating error messages. The second commit fixes potential linker errors when combining `--crate-type staticlib` with another crate type and I think `-Cprefer-dynamic`.
2023-01-04Fix each_linked_rlib when the current crate has 0 crate typesbjorn3-0/+3
2023-01-02only specify --target by default for -Zgcc-ld=lld on wasmRémy Rakic-1/+20
On macOS, it's not yet clear which cases of clang/OS/target/SDK version impact how to find ld/lld/rust-lld. The --target is not needed on our current targets with a vanilla config, but may be in some cases. Specifying it all the time breaks the 10.7+ targets on x64 macOS. We try to only specify it on macOS if the linker flavors are different, for possible cases of cross-compilation with `-Zgcc-ld=lld` but the expectation is that it should be passed manually when needed in these situations.
2022-12-30Stabilize f16c_target_featureKathryn Long-2/+1