summary refs log tree commit diff
path: root/compiler/rustc_codegen_cranelift
AgeCommit message (Collapse)AuthorLines
2023-02-27Unify all validity check intrinsicsNilstrieb-49/+31
Also merges the inhabitedness check into the query to further unify the code paths.
2023-02-27Rollup merge of #108364 - Nilstrieb:validity-checks-refactor, r=compiler-errorsMatthias Krüger-3/+7
Unify validity checks into a single query Previously, there were two queries to check whether a type allows the 0x01 or zeroed bitpattern. I am planning on adding a further initness to check in #100423, truly uninit for MaybeUninit, which would make this three queries. This seems overkill for such a small feature, so this PR unifies them into one. I am not entirely happy with the naming and key type and open for improvements. r? oli-obk
2023-02-24Rename many interner functions.Nicholas Nethercote-9/+9
(This is a large commit. The changes to `compiler/rustc_middle/src/ty/context.rs` are the most important ones.) The current naming scheme is a mess, with a mix of `_intern_`, `intern_` and `mk_` prefixes, with little consistency. In particular, in many cases it's easy to use an iterator interner when a (preferable) slice interner is available. The guiding principles of the new naming system: - No `_intern_` prefixes. - The `intern_` prefix is for internal operations. - The `mk_` prefix is for external operations. - For cases where there is a slice interner and an iterator interner, the former is `mk_foo` and the latter is `mk_foo_from_iter`. Also, `slice_interners!` and `direct_interners!` can now be `pub` or non-`pub`, which helps enforce the internal/external operations division. It's not perfect, but I think it's a clear improvement. The following lists show everything that was renamed. slice_interners - const_list - mk_const_list -> mk_const_list_from_iter - intern_const_list -> mk_const_list - substs - mk_substs -> mk_substs_from_iter - intern_substs -> mk_substs - check_substs -> check_and_mk_substs (this is a weird one) - canonical_var_infos - intern_canonical_var_infos -> mk_canonical_var_infos - poly_existential_predicates - mk_poly_existential_predicates -> mk_poly_existential_predicates_from_iter - intern_poly_existential_predicates -> mk_poly_existential_predicates - _intern_poly_existential_predicates -> intern_poly_existential_predicates - predicates - mk_predicates -> mk_predicates_from_iter - intern_predicates -> mk_predicates - _intern_predicates -> intern_predicates - projs - intern_projs -> mk_projs - place_elems - mk_place_elems -> mk_place_elems_from_iter - intern_place_elems -> mk_place_elems - bound_variable_kinds - mk_bound_variable_kinds -> mk_bound_variable_kinds_from_iter - intern_bound_variable_kinds -> mk_bound_variable_kinds direct_interners - region - intern_region (unchanged) - const - mk_const_internal -> intern_const - const_allocation - intern_const_alloc -> mk_const_alloc - layout - intern_layout -> mk_layout - adt_def - intern_adt_def -> mk_adt_def_from_data (unusual case, hard to avoid) - alloc_adt_def(!) -> mk_adt_def - external_constraints - intern_external_constraints -> mk_external_constraints Other - type_list - mk_type_list -> mk_type_list_from_iter - intern_type_list -> mk_type_list - tup - mk_tup -> mk_tup_from_iter - intern_tup -> mk_tup
2023-02-23Unify validity checks into a single queryNilstrieb-3/+7
Previously, there were two queries to check whether a type allows the 0x01 or zeroed bitpattern. I am planning on adding a further initness to check, truly uninit for MaybeUninit, which would make this three queries. This seems overkill for such a small feature, so this PR unifies them into one.
2023-02-22Auto merge of #108340 - eggyal:remove_traversal_trait_aliases, r=oli-obkbors-2/+2
Remove type-traversal trait aliases #107924 moved the type traversal (folding and visiting) traits into the type library, but created trait aliases in `rustc_middle` to minimise both the API churn for trait consumers and the arising boilerplate. As mentioned in that PR, an alternative approach of defining subtraits with blanket implementations of the respective supertraits was also considered at that time but was ruled out as not adding much value. Unfortunately, it has since emerged that rust-analyzer has difficulty with these trait aliases at present, resulting in a degraded contributor experience (see the recent [r-a has become useless](https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/r-a.20has.20become.20useless) topic on the #t-compiler/help Zulip stream). This PR removes the trait aliases, and accordingly the underlying type library traits are now used directly; they are parameterised by `TyCtxt<'tcx>` rather than just the `'tcx` lifetime, and imports have been updated to reflect the fact that the trait aliases' explicitly named traits are no longer automatically brought into scope. These changes also roll-back the (no-longer required) workarounds to #107747 that were made in b409329c624b9e3bbd7d8e07697e2e9f861a45b6. Since this PR is just a find+replace together with the changes necessary for compilation & tidy to pass, it's currently just one mega-commit. Let me know if you'd like it broken up. r? `@oli-obk`
2023-02-22Remove type-traversal trait aliasesAlan Egerton-2/+2
2023-02-22various: translation resources from cg backendDavid Wood-0/+5
Extend `CodegenBackend` trait with a function returning the translation resources from the codegen backend, which can be added to the complete list of resources provided to the emitter. Signed-off-by: David Wood <david.wood@huawei.com>
2023-02-18Stop implementing _with_overflow intrinsics in codegen backends.Camille GILLOT-14/+0
2023-02-18Adapt cg_clif.Camille GILLOT-10/+7
2023-02-17Replace `mk_foo` calls with `infer_foo` where possible.Nicholas Nethercote-5/+5
There are several `mk_foo`/`intern_foo` pairs, where the former takes an iterator and the latter takes a slice. (This naming convention is bad, but that's a fix for another PR.) This commit changes several `mk_foo` occurrences into `intern_foo`, avoiding the need for some `.iter()`/`.into_iter()` calls. Affected cases: - mk_type_list - mk_tup - mk_substs - mk_const_list
2023-02-16`if $c:expr { Some($r:expr) } else { None }` =>> `$c.then(|| $r)`Maybe Waffle-11/+7
2023-02-15Auto merge of #108012 - compiler-errors:issue-107999, r=oli-obkbors-3/+10
Don't ICE in `might_permit_raw_init` if reference is polymorphic Emitting optimized MIR for a polymorphic function may require computing layout of a type that isn't (yet) known. This happens in the instcombine pass, for example. Let's fail gracefully in that condition. cc `@saethlin` fixes #107999
2023-02-14Make permit_uninit/zero_init fallibleMichael Goulet-3/+10
2023-02-14s/eval_usize/eval_target_usize/ for clarityOli Scherer-6/+6
2023-02-13Alias folding/visiting traits instead of re-exportAlan Egerton-1/+1
2023-02-09Merge commit '7d53619064ab7045c383644cb445052d2a3d46db' into ↵bjorn3-331/+640
sync_cg_clif-2023-02-09
2023-01-29Auto merge of #106227 - bryangarza:ctfe-limit, r=oli-obkbors-0/+2
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-27Auto merge of #107055 - kylematsuda:eb-fn-sig, r=lcnrbors-1/+1
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-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-1/+1
EarlyBinder to fn_sig in metadata
2023-01-26replace usages of fn_sig query with bound_fn_sigKyle Matsuda-1/+1
2023-01-27Auto merge of #107269 - bjorn3:sync_cg_clif-2023-01-24, r=bjorn3bors-1104/+1386
Sync rustc_codegen_cranelift For cg_clif itself there have been a couple of bug fixes since the last sync, a Cranelift update and implemented all remaining simd platform intrinsics used by `std::simd`. (`std::arch` still misses a lot though) Most of the diff is from reworking of the cg_clif build system though. r? `@ghost` `@rustbot` label +A-codegen +A-cranelift +T-compiler
2023-01-26Auto merge of #107314 - matthiaskrgr:rollup-j40lnlj, r=matthiaskrgrbors-1/+2
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/+5
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-25Fix CIbjorn3-24/+4
2023-01-25Vendor newer version of cranelift-nativebjorn3-2/+273
It fixes a bug that caused compilation on 32bit x86 to fail
2023-01-24Merge commit '598f0909568a51de8a2d1148f55a644fd8dffad0' into ↵bjorn3-1103/+1134
sync_cg_clif-2023-01-24
2023-01-23Thread a ParamEnv down to might_permit_raw_initBen Kimock-2/+5
2023-01-23Update codegen cranelift for ConstEvalCounterBryan Garza-0/+2
2023-01-22abi: add `AddressSpace` field to `Primitive::Pointer`Erik Desjardins-1/+2
...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-19Auto merge of #106810 - oli-obk:resolver_reverse_plumbing, r=petrochenkovbors-1/+1
Various cleanups around pre-TyCtxt queries and functions part of #105462 based on https://github.com/rust-lang/rust/pull/106776 (everything starting at [0e2b39f](https://github.com/rust-lang/rust/pull/106810/commits/0e2b39fd1ffde51b50d45ccbe41de52b85136b8b) is new in this PR) r? `@petrochenkov` I think this should be most of the uncontroversial part of #105462.
2023-01-17Remove double spaces after dots in commentsMaybe Waffle-1/+1
2023-01-16Move compiler input and ouput paths into sessionOli Scherer-1/+1
2023-01-11Change `src/test` to `tests` in source files, fix tidy and testsAlbert Larsan-66/+66
2022-12-21Auto merge of #105613 - Nilstrieb:rename-assert_uninit_valid, r=RalfJungbors-2/+4
Rename `assert_uninit_valid` intrinsic It's not about "uninit" anymore but about "filling with 0x01 bytes" so the name should at least try to reflect that. This is actually not fully correct though, as it does still panic for all uninit with `-Zstrict-init-checks`. I'm not sure what the best way is to deal with that not causing confusion. I guess we could just remove the flag? I don't think having it makes a lot of sense anymore with the direction that we have chose to go. It could be relevant again if #100423 lands so removing it may be a bit over eager. r? `@RalfJung`
2022-12-14Merge commit '2bb3996244cf1b89878da9e39841e9f6bf061602' into ↵bjorn3-1028/+1691
sync_cg_clif-2022-12-14
2022-12-13Rename `assert_uninit_valid` intrinsicNilstrieb-2/+4
It's not about "uninit" anymore but about "filling with 0x01 bytes" so the name should at least try to reflect that.
2022-12-11bug! with a better error message for failing Instance::resolveMichael Goulet-4/+3
2022-12-09Remove unneeded field from `SwitchTargets`Jakob Degen-2/+4
2022-12-03Auto merge of #97485 - bjorn3:new_archive_writer, r=wesleywiserbors-226/+5
Rewrite LLVM's archive writer in Rust This allows it to be used by other codegen backends. Fixes https://github.com/bjorn3/rustc_codegen_cranelift/issues/1155
2022-11-27Prefer doc comments over `//`-comments in compilerMaybe Waffle-2/+2
2022-11-26Rewrite LLVM's archive writer in Rustbjorn3-226/+5
This allows it to be used by other codegen backends
2022-11-26Rollup merge of #104786 - WaffleLapkin:amp-mut-help, r=compiler-errorsGuillaume Gomez-9/+4
Use the power of adding helper function to simplify code w/ `Mutability` r? `@compiler-errors`
2022-11-24Auto merge of #104507 - WaffleLapkin:asderefsyou, r=wesleywiserbors-2/+2
Use `as_deref` in compiler (but only where it makes sense) This simplifies some code :3 (there are some changes that are not exacly `as_deref`, but more like "clever `Option`/`Result` method use")
2022-11-23Add `Mutability::{is_mut,is_not}`Maybe Waffle-9/+4
2022-11-21Rollup merge of #104605 - RalfJung:clf_consts, r=bjorn3Matthias Krüger-35/+23
deduplicate constant evaluation in cranelift backend The cranelift backend had two matches on `ConstantKind`, which can be avoided, and used this `eval_for_mir` that nothing else uses... this makes things more consistent with the (better-tested) LLVM backend. I noticed this because cranelift was the only user of `eval_for_mir`. However `try_eval_for_mir` still has one other user in `eval`... the odd thing is that the interpreter has its own `eval_mir_constant` which seems to duplicate the same functionality and does not use `try_eval_for_mir`. No idea what is happening here. r? ``@bjorn3`` Cc ``@lcnr``
2022-11-19deduplicate constant evaluation in cranelift backendRalf Jung-35/+23
also sync LLVM and cranelift structure a bit
2022-11-19Rollup merge of #104001 - Ayush1325:custom-entry, r=bjorn3Dylan DPC-12/+21
Improve generating Custom entry function This commit is aimed at making compiler-generated entry functions (Basically just C `main` right now) more generic so other targets can do similar things for custom entry. This was initially implemented as part of https://github.com/rust-lang/rust/pull/100316. Currently, this moves the entry function name and Call convention to the target spec. Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2022-11-17Use custom entry name in craneliftAyush Singh-12/+21
This is a continuation of 9f0a8620bd7d325e6d42417b08daff3e55cb88f6 for cranelift. Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2022-11-16Use `as_deref` in compiler (but only where it makes sense)Maybe Waffle-2/+2