about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/context.rs
AgeCommit message (Collapse)AuthorLines
2024-10-16llvm: Match aarch64 data layout to new LLVM layoutMatthew Maurer-0/+10
LLVM has added 3 new address spaces to support special Windows use cases. These shouldn't trouble us for now, but LLVM requires matching data layouts. See llvm/llvm-project#111879 for details
2024-10-11intrinsics.fmuladdf{16,32,64,128}: expose llvm.fmuladd.* semanticsJed Brown-0/+5
Add intrinsics `fmuladd{f16,f32,f64,f128}`. This computes `(a * b) + c`, to be fused if the code generator determines that (i) the target instruction set has support for a fused operation, and (ii) that the fused operation is more efficient than the equivalent, separate pair of `mul` and `add` instructions. https://llvm.org/docs/LangRef.html#llvm-fmuladd-intrinsic MIRI support is included for f32 and f64. The codegen_cranelift uses the `fma` function from libc, which is a correct implementation, but without the desired performance semantic. I think this requires an update to cranelift to expose a suitable instruction in its IR. I have not tested with codegen_gcc, but it should behave the same way (using `fma` from libc).
2024-10-08Dont ICE when encountering post-mono layout cycle errorMichael Goulet-5/+6
2024-09-25Add missing module flags for function-return=thunk-externAlice Ryhl-1/+13
2024-09-24Auto merge of #130389 - Luv-Ray:LLVMMDNodeInContext2, r=nikicbors-5/+13
llvm: replace some deprecated functions `LLVMMDStringInContext` and `LLVMMDNodeInContext` are deprecated, replace them with `LLVMMDStringInContext2` and `LLVMMDNodeInContext2`. Also replace `Value` with `Metadata` in some function signatures for better consistency.
2024-09-23formatLuv-Ray-1/+1
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-3/+3
2024-09-19MetadataType type castLuv-Ray-3/+3
2024-09-19move placeLuv-Ray-8/+8
2024-09-19wrap `LLVMSetMetadata`Luv-Ray-1/+10
2024-09-19Reformat some comments.Nicholas Nethercote-1/+2
So they are less than 100 chars.
2024-09-19Fix a comment.Nicholas Nethercote-2/+2
I'm pretty sure `CodegenCx` applies to codegen units, rather than compilation units.
2024-09-19replace some deprecated functionsLuv-Ray-4/+3
2024-09-18Update the minimum external LLVM to 18Josh Stone-8/+0
2024-09-17Use associative type defaults in `{Layout,FnAbi}OfHelpers`.Nicholas Nethercote-6/+0
This avoids some repetitive boilerplate code.
2024-09-17Rename supertraits of `CodegenMethods`.Nicholas Nethercote-1/+1
Supertraits of `BuilderMethods` are all called `XyzBuilderMethods`. Supertraits of `CodegenMethods` are all called `XyzMethods`. This commit changes the latter to `XyzCodegenMethods`, for consistency.
2024-09-10Add -Z small-data-thresholdPaul Menage-1/+19
This flag allows specifying the threshold size above which LLVM should not consider placing small objects in a .sdata or .sbss section. Support is indicated in the target options via the small-data-threshold-support target option, which can indicate either an LLVM argument or an LLVM module flag. To avoid duplicate specifications in a large number of targets, the default value for support is DefaultForArch, which is translated to a concrete value according to the target's architecture.
2024-08-27Rollup merge of #126013 - nnethercote:unreachable_pub, r=UrgauMatthias Krüger-4/+6
Add `#[warn(unreachable_pub)]` to a bunch of compiler crates By default `unreachable_pub` identifies things that need not be `pub` and tells you to make them `pub(crate)`. But sometimes those things don't need any kind of visibility. So they way I did these was to remove the visibility entirely for each thing the lint identifies, and then add `pub(crate)` back in everywhere the compiler said it was necessary. (Or occasionally `pub(super)` when context suggested that was appropriate.) Tedious, but results in more `pub` removal. There are plenty more crates to do but this seems like enough for a first PR. r? `@compiler-errors`
2024-08-21Add missing module flags for CFI and KCFI sanitizersSami Tolvanen-0/+31
Set the cfi-normalize-integers and kcfi-offset module flags when Control-Flow Integrity sanitizers are used, so functions generated by the LLVM backend use the same CFI/KCFI options as rustc. cfi-normalize-integers tells LLVM to also use integer normalization for generated functions when -Zsanitizer-cfi-normalize-integers is used. kcfi-offset specifies the number of prefix nops between the KCFI type hash and the function entry when -Z patchable-function-entry is used. Note that LLVM assumes all indirectly callable functions use the same number of prefix NOPs with -Zsanitizer=kcfi.
2024-08-20Avoid extra `cast()`s after `CStr::as_ptr()`Josh Stone-11/+11
These used to be `&str` literals that did need a pointer cast, but that became a no-op after switching to `c""` literals in #118566.
2024-08-17Fix `is_val_statically_known` for floatsbeetrees-0/+2
2024-08-16Add `warn(unreachable_pub)` to `rustc_codegen_llvm`.Nicholas Nethercote-4/+6
2024-08-07Rollup merge of #128221 - calebzulawski:implied-target-features, r=AmanieuMatthias Krüger-1/+1
Add implied target features to target_feature attribute See [zulip](https://rust-lang.zulipchat.com/#narrow/stream/208962-t-libs.2Fstdarch/topic/Why.20would.20target-feature.20include.20implied.20features.3F) for some context. Adds implied target features, e.g. `#[target_feature(enable = "avx2")]` acts like `#[target_feature(enable = "avx2,avx,sse4.2,sse4.1...")]`. Fixes #128125, fixes #128426 The implied feature sets are taken from [the rust reference](https://doc.rust-lang.org/reference/attributes/codegen.html?highlight=target-fea#x86-or-x86_64), there are certainly more features and targets to add. Please feel free to reassign this to whoever should review it. r? ``@Amanieu``
2024-08-07Don't use LLVM to compute -Ctarget-featureCaleb Zulawski-1/+1
2024-08-07Don't use LLVM's target featuresCaleb Zulawski-1/+1
2024-08-01Specify the integer type of the `powi` LLVM intrinsicTrevor Gross-4/+4
Since LLVM <https://reviews.llvm.org/D99439> (4c7f820b2b20, "Update @llvm.powi to handle different int sizes for the exponent"), the size of the integer can be specified for the `powi` intrinsic. Make use of this so it is more obvious that integer size is consistent across all float types. This feature is available since LLVM 13 (October 2021). Based on bootstrap we currently support >= 17.0, so there should be no support problems.
2024-07-29Reformat `use` declarations.Nicholas Nethercote-20/+17
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-16Fix unsafe_op_in_unsafe_fn in compilerMichael Goulet-110/+149
2024-07-02Fix spansMichael Goulet-2/+2
2024-07-02Give Instance::expect_resolve a spanMichael Goulet-0/+1
2024-06-21Remove check_overflow method from MiscMethodsbjorn3-8/+0
It can be retrieved from the Session too.
2024-06-21Move vcall_visibility_metadata optimization hint out of a debuginfo ↵bjorn3-0/+10
generation method
2024-06-12Adjust LoongArch64 data layouts for LLVM updateHans Wennborg-0/+8
The data layout was changed in LLVM 19: llvm/llvm-project#93814
2024-05-06Adjust 64-bit ARM data layouts for LLVM updateMatthew Maurer-0/+9
LLVM has updated data layouts to specify `Fn32` on 64-bit ARM to avoid C++ accidentally underaligning functions when trying to comply with member function ABIs. This should only affect Rust in cases where we had a similar bug (I don't believe we have one), but our data layout must match to generate code. As a compatibility adaptatation, if LLVM is not version 19 yet, `Fn32` gets voided from the data layout. See llvm/llvm-project#90415
2024-04-22Stabilize the size of incr comp object file namesBen Kimock-2/+3
2024-04-09Pass value and valueLen to create a StringRefLevi Zim-7/+5
Instead of creating a cstring. Co-authored-by: LoveSy <shana@zju.edu.cn>
2024-04-09Set target-abi module flag for RISC-V targetskxxt-15/+33
Fixes cross-language LTO on RISC-V targets (Fixes #121924)
2024-03-23Auto merge of #119552 - krtab:dead_code_priv_mod_pub_field, r=cjgillot,saethlinbors-5/+1
Replace visibility test with reachability test in dead code detection Fixes https://github.com/rust-lang/rust/issues/119545 Also included is a fix for an error now flagged by the lint
2024-03-20Rollup merge of #121543 - onur-ozkan:clippy-args, r=oli-obkMatthias Krüger-0/+1
various clippy fixes We need to keep the order of the given clippy lint rules before passing them. Since clap doesn't offer any useful interface for this purpose out of the box, we have to handle it manually. Additionally, this PR makes `-D` rules work as expected. Previously, lint rules were limited to `-W`. By enabling `-D`, clippy began to complain numerous lines in the tree, all of which have been resolved in this PR as well. Fixes #121481 cc `@matthiaskrgr`
2024-03-20resolve clippy errorsonur-ozkan-0/+1
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-03-17Update the minimum external LLVM to 17Josh Stone-11/+0
2024-03-12Remove unused fields in some structuresArthur Carcano-5/+1
The dead_code lint was previously eroneously missing those. Since this lint bug has been fixed, the unused fields need to be removed.
2024-03-11Rollup merge of #122166 - beetrees:remove-field-remapping, r=davidtwcoJubilee-11/+2
Remove the unused `field_remapping` field from `TypeLowering` The `field_remapping` field of `TypeLowering` has been unused since #121665. This PR removes it, then replaces the `TypeLowering` struct with its only remaining member `&'ll Type`.
2024-03-10use Instance::expect_resolve() instead of unwraping Instance::resolve()Ralf Jung-5/+6
2024-03-08Remove handling for previously dropped LLVM versionbeetrees-10/+4
2024-03-08Remove the unused `field_remapping` field from `TypeLowering`beetrees-11/+2
2024-03-01Add `f16` and `f128` LLVM intrinsicsTrevor Gross-0/+48
2024-01-29Avoid ICE when is_val_statically_known is not of a supported typeAlex Huang-0/+1
2024-01-27Auto merge of #120062 - davidtwco:llvm-data-layout-check, r=wesleywiserbors-29/+9
llvm: change data layout bug to an error and make it trigger more Fixes #33446. Don't skip the inconsistent data layout check for custom LLVMs or non-built-in targets. With #118708, all targets will have a simple test that would trigger this error if LLVM's data layouts do change - so data layouts would be corrected during the LLVM upgrade. Therefore, with builtin targets, this error won't happen with our LLVM because each target will have been confirmed to work. With non-builtin targets, this error is probably useful to have because you can change the data layout in your target and if it is wrong then that could lead to bugs. When using a custom LLVM, the same justification makes sense for non-builtin targets as with our LLVM, the user can update their target to match their LLVM and that's probably a good thing to do. However, with a custom LLVM, the user cannot change the builtin target data layouts if they don't match - though given that the compiler's data layout is used for layout computation and a bunch of other things - you could get some bugs because of the mismatch and probably want to know about that. I'm not sure if this is something that people do and is okay, but I doubt it? `CFG_LLVM_ROOT` was also always set during local development with `download-ci-llvm` so this bug would never trigger locally. In #33446, two points are raised: - In the issue itself, changing this from a `bug!` to a proper error is what is suggested, by using `isCompatibleDataLayout` from LLVM, but that function still just does the same thing that we do and check for equality, so I've avoided the additional code necessary to do that FFI call. - `@Mark-Simulacrum` suggests a different check is necessary to maintain backwards compatibility with old LLVM versions. I don't know how often this comes up, but we can do that with some simple string manipulation + LLVM version checks as happens already for LLVM 17 just above this diff.
2024-01-25Auto merge of #119911 - NCGThompson:is-statically-known, r=oli-obkbors-0/+14
Replacement of #114390: Add new intrinsic `is_var_statically_known` and optimize pow for powers of two This adds a new intrinsic `is_val_statically_known` that lowers to [``@llvm.is.constant.*`](https://llvm.org/docs/LangRef.html#llvm-is-constant-intrinsic).` It also applies the intrinsic in the int_pow methods to recognize and optimize the idiom `2isize.pow(x)`. See #114390 for more discussion. While I have extended the scope of the power of two optimization from #114390, I haven't added any new uses for the intrinsic. That can be done in later pull requests. Note: When testing or using the library, be sure to use `--stage 1` or higher. Otherwise, the intrinsic will be a noop and the doctests will be skipped. If you are trying out edits, you may be interested in [`--keep-stage 0`](https://rustc-dev-guide.rust-lang.org/building/suggested.html#faster-builds-with---keep-stage). Fixes #47234 Resolves #114390 `@Centri3`