about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm
AgeCommit message (Collapse)AuthorLines
2024-03-12Reduce some duplicate work that is being done around staticsOli Scherer-8/+18
2024-03-12Share the llvm type computation between both arms of a conditionOli Scherer-5/+4
2024-03-12Rollup merge of #122000 - erer1243:issue-121868, r=nikicMatthias Krüger-22/+18
Fix 32-bit overflows in LLVM composite constants Inspired by #121868. Fixes unsoundness created when constructing constant arrays, strings, and structs with 2^32 or more elements on x86_64. This introduces copies of a few LLVM functions that have their signatures updated to use size_t in place of unsigned int. Alternatively we could just add overflow checks and just disallow huge composite constants. That introduces less code, but maybe a huge static block of memory is useful in embedded/no-os situations?
2024-03-11Rollup merge of #122166 - beetrees:remove-field-remapping, r=davidtwcoJubilee-34/+9
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-11Rollup merge of #121438 - coolreader18:wasm32-panic-unwind, r=cuviperJubilee-0/+9
std support for wasm32 panic=unwind Tracking issue: #118168 This adds std support for `-Cpanic=unwind` on wasm, and with it slightly more fleshed out rustc support. Now, the stable default is still panic=abort without exception-handling, but if you `-Zbuild-std` with `RUSTFLAGS=-Cpanic=unwind`, you get wasm exception-handling try/catch blocks in the binary: ```rust #[no_mangle] pub fn foo_bar(x: bool) -> *mut u8 { let s = Box::<str>::from("hello"); maybe_panic(x); Box::into_raw(s).cast() } #[inline(never)] #[no_mangle] fn maybe_panic(x: bool) { if x { panic!("AAAAA"); } } ``` ```wat ;; snip... (try $label$5 (do (call $maybe_panic (local.get $0) ) (br $label$1) ) (catch_all (global.set $__stack_pointer (local.get $1) ) (call $__rust_dealloc (local.get $2) (i32.const 5) (i32.const 1) ) (rethrow $label$5) ) ) ;; snip... ```
2024-03-11copy byval argument to alloca if alignment is insufficientErik Desjardins-49/+55
2024-03-11Auto merge of #122050 - erikdesjardins:sret, r=nikicbors-4/+16
Stop using LLVM struct types for byval/sret For `byval` and `sret`, the type has no semantic meaning, only the size matters\*†. Using `[N x i8]` is a more direct way to specify that we want `N` bytes, and avoids relying on LLVM's struct layout. \*: The alignment would matter, if we didn't explicitly specify it. From what I can tell, we always specified the alignment for `sret`; for `byval`, we didn't until #112157. †: For `byval`, the hidden copy may be impacted by padding in the LLVM struct type, i.e. padding bytes may not be copied. (I'm not sure if this is done today, but I think it would be legal.) But we manually pad our LLVM struct types specifically to avoid there ever being LLVM-visible padding, so that shouldn't be an issue. Split out from #121577. r? `@nikic`
2024-03-11Auto merge of #122132 - nnethercote:diag-renaming3, r=nnethercotebors-9/+9
Diagnostic renaming 3 A sequel to https://github.com/rust-lang/rust/pull/121780. r? `@davidtwco`
2024-03-11Rename `IntoDiagnostic` as `Diagnostic`.Nicholas Nethercote-9/+9
To match `derive(Diagnostic)`. Also rename `into_diagnostic` as `into_diag`.
2024-03-10Fix 32-bit overflows in LLVM composite constantserer1243-22/+18
2024-03-10use Instance::expect_resolve() instead of unwraping Instance::resolve()Ralf Jung-5/+6
2024-03-09Rollup merge of #121584 - klensy:itertools-up, r=Mark-SimulacrumGuillaume Boisseau-1/+1
bump itertools to 0.12 still depend on 0.11 (temporary dupes version): * <del>clippy</del>, https://github.com/rust-lang/rust-clippy/pull/12346 * rustfmt, sigh, https://github.com/rust-lang/rustfmt/pull/6093 https://github.com/rust-itertools/itertools/blob/v0.12.1/CHANGELOG.md removed unused `derive_more` dep from `rustc_middle`
2024-03-09Sink ptrtoint for RMW ops on pointers to cg_llvmBen Kimock-1/+7
2024-03-08Rollup merge of #122198 - beetrees:no-llvm-14, r=cuviperMatthias Krüger-10/+4
Remove handling for previously dropped LLVM version LLVM 14 support was dropped in #114148, so this LLVM version check is no longer required.
2024-03-08bump itertools to 0.12klensy-1/+1
still depend on 0.11: * clippy * rustfmt, sigh
2024-03-08Rollup merge of #119365 - nbdd0121:asm-goto, r=AmanieuMatthias Krüger-10/+88
Add asm goto support to `asm!` Tracking issue: #119364 This PR implements asm-goto support, using the syntax described in "future possibilities" section of [RFC2873](https://rust-lang.github.io/rfcs/2873-inline-asm.html#asm-goto). Currently I have only implemented the `label` part, not the `fallthrough` part (i.e. fallthrough is implicit). This doesn't reduce the expressive though, since you can use label-break to get arbitrary control flow or simply set a value and rely on jump threading optimisation to get the desired control flow. I can add that later if deemed necessary. r? ``@Amanieu`` cc ``@ojeda``
2024-03-08Remove handling for previously dropped LLVM versionbeetrees-10/+4
2024-03-08Remove the unused `field_remapping` field from `TypeLowering`beetrees-34/+9
2024-03-06Add arm64ec-pc-windows-msvc targetDaniel Paoliello-2/+10
Introduces the `arm64ec-pc-windows-msvc` target for building Arm64EC ("Emulation Compatible") binaries for Windows. For more information about Arm64EC see <https://learn.microsoft.com/en-us/windows/arm/arm64ec>. Tier 3 policy: > A tier 3 target must have a designated developer or developers (the "target maintainers") on record to be CCed when issues arise regarding the target. (The mechanism to track and CC such developers may evolve over time.) I will be the maintainer for this target. > Targets must use naming consistent with any existing targets; for instance, a target for the same CPU or OS as an existing Rust target should use the same name for that CPU or OS. Targets should normally use the same names and naming conventions as used elsewhere in the broader ecosystem beyond Rust (such as in other toolchains), unless they have a very good reason to diverge. Changing the name of a target can be highly disruptive, especially once the target reaches a higher tier, so getting the name right is important even for a tier 3 target. Target uses the `arm64ec` architecture to match LLVM and MSVC, and the `-pc-windows-msvc` suffix to indicate that it targets Windows via the MSVC environment. > Target names should not introduce undue confusion or ambiguity unless absolutely necessary to maintain ecosystem compatibility. For example, if the name of the target makes people extremely likely to form incorrect beliefs about what it targets, the name should be changed or augmented to disambiguate it. Target name exactly specifies the type of code that will be produced. > If possible, use only letters, numbers, dashes and underscores for the name. Periods (.) are known to cause issues in Cargo. Done. > Tier 3 targets may have unusual requirements to build or use, but must not create legal issues or impose onerous legal terms for the Rust project or for Rust developers or users. > The target must not introduce license incompatibilities. Uses the same dependencies, requirements and licensing as the other `*-pc-windows-msvc` targets. > Anything added to the Rust repository must be under the standard Rust license (MIT OR Apache-2.0). Understood. > The target must not cause the Rust tools or libraries built for any other host (even when supporting cross-compilation to the target) to depend on any new dependency less permissive than the Rust licensing policy. This applies whether the dependency is a Rust crate that would require adding new license exceptions (as specified by the tidy tool in the rust-lang/rust repository), or whether the dependency is a native library or binary. In other words, the introduction of the target must not cause a user installing or running a version of Rust or the Rust tools to be subject to any new license requirements. > Compiling, linking, and emitting functional binaries, libraries, or other code for the target (whether hosted on the target itself or cross-compiling from another target) must not depend on proprietary (non-FOSS) libraries. Host tools built for the target itself may depend on the ordinary runtime libraries supplied by the platform and commonly used by other applications built for the target, but those libraries must not be required for code generation for the target; cross-compilation to the target must not require such libraries at all. For instance, rustc built for the target may depend on a common proprietary C runtime library or console output library, but must not depend on a proprietary code generation library or code optimization library. Rust's license permits such combinations, but the Rust project has no interest in maintaining such combinations within the scope of Rust itself, even at tier 3. > "onerous" here is an intentionally subjective term. At a minimum, "onerous" legal/licensing terms include but are not limited to: non-disclosure requirements, non-compete requirements, contributor license agreements (CLAs) or equivalent, "non-commercial"/"research-only"/etc terms, requirements conditional on the employer or employment of any particular Rust developers, revocable terms, any requirements that create liability for the Rust project or its developers or users, or any requirements that adversely affect the livelihood or prospects of the Rust project or its developers or users. Uses the same dependencies, requirements and licensing as the other `*-pc-windows-msvc` targets. > Neither this policy nor any decisions made regarding targets shall create any binding agreement or estoppel by any party. If any member of an approving Rust team serves as one of the maintainers of a target, or has any legal or employment requirement (explicit or implicit) that might affect their decisions regarding a target, they must recuse themselves from any approval decisions regarding the target's tier status, though they may otherwise participate in discussions. > This requirement does not prevent part or all of this policy from being cited in an explicit contract or work agreement (e.g. to implement or maintain support for a target). This requirement exists to ensure that a developer or team responsible for reviewing and approving a target does not face any legal threats or obligations that would prevent them from freely exercising their judgment in such approval, even if such judgment involves subjective matters or goes beyond the letter of these requirements. Understood, I am not a member of the Rust team. > Tier 3 targets should attempt to implement as much of the standard libraries as possible and appropriate (core for most targets, alloc for targets that can support dynamic memory allocation, std for targets with an operating system or equivalent layer of system-provided functionality), but may leave some code unimplemented (either unavailable or stubbed out as appropriate), whether because the target makes it impossible to implement or challenging to implement. The authors of pull requests are not obligated to avoid calling any portions of the standard library on the basis of a tier 3 target not implementing those portions. Both `core` and `alloc` are supported. Support for `std` dependends on making changes to the standard library, `stdarch` and `backtrace` which cannot be done yet as the bootstrapping compiler raises a warning ("unexpected `cfg` condition value") for `target_arch = "arm64ec"`. > The target must provide documentation for the Rust community explaining how to build for the target, using cross-compilation if possible. If the target supports running binaries, or running tests (even if they do not pass), the documentation must explain how to run such binaries or tests for the target, using emulation if possible or dedicated hardware if necessary. Documentation is provided in src/doc/rustc/src/platform-support/arm64ec-pc-windows-msvc.md > Tier 3 targets must not impose burden on the authors of pull requests, or other developers in the community, to maintain the target. In particular, do not post comments (automated or manual) on a PR that derail or suggest a block on the PR based on a tier 3 target. Do not send automated messages or notifications (via any medium, including via @) to a PR author or others involved with a PR regarding a tier 3 target, unless they have opted into such messages. > Backlinks such as those generated by the issue/PR tracker when linking to an issue or PR are not considered a violation of this policy, within reason. However, such messages (even on a separate repository) must not generate notifications to anyone involved with a PR who has not requested such notifications. > Patches adding or updating tier 3 targets must not break any existing tier 2 or tier 1 target, and must not knowingly break another tier 3 target without approval of either the compiler team or the maintainers of the other tier 3 target. > In particular, this may come up when working on closely related targets, such as variations of the same architecture with different features. Avoid introducing unconditional uses of features that another variation of the target may not have; use conditional compilation or runtime detection, as appropriate, to let each target run code supported by that target. Understood.
2024-03-05use [N x i8] for byval/sret typesErik Desjardins-4/+16
This avoids depending on LLVM's struct types to determine the size of the byval/sret slot.
2024-03-05only set noalias on Box with the global allocatorRalf Jung-3/+7
2024-03-03Auto merge of #121665 - erikdesjardins:ptradd, r=nikicbors-96/+62
Always generate GEP i8 / ptradd for struct offsets This implements #98615, and goes a bit further to remove `struct_gep` entirely. Upstream LLVM is in the beginning stages of [migrating to `ptradd`](https://discourse.llvm.org/t/rfc-replacing-getelementptr-with-ptradd/68699). LLVM 19 will [canonicalize](https://github.com/llvm/llvm-project/pull/68882) all constant-offset GEPs to i8, which has roughly the same effect as this change. Fixes #121719. Split out from #121577. r? `@nikic`
2024-03-03Auto merge of #121763 - clubby789:llvm-old-comment, r=cjgillotbors-6/+3
Update outdated LLVM comment The first path no longer exists, but the second does.
2024-03-02Auto merge of #121914 - Nadrieril:rollup-ol98ncg, r=Nadrierilbors-1/+129
Rollup of 5 pull requests Successful merges: - #120761 (Add initial support for DataFlowSanitizer) - #121622 (Preserve same vtable pointer when cloning raw waker, to fix Waker::will_wake) - #121716 (match lowering: Lower bindings in a predictable order) - #121731 (Now that inlining, mir validation and const eval all use reveal-all, we won't be constraining hidden types here anymore) - #121841 (`f16` and `f128` step 2: intrinsics) r? `@ghost` `@rustbot` modify labels: rollup
2024-03-02Rollup merge of #121841 - tgross35:f16-f128-step2-intrinsics, r=compiler-errorsGuillaume Boisseau-1/+116
`f16` and `f128` step 2: intrinsics Continuation of https://github.com/rust-lang/rust/pull/121728, another portion of https://github.com/rust-lang/rust/pull/114607. This PR adds `f16` and `f128` intrinsics, and hooks them up to both HIR and LLVM. This is all still unexposed to the frontend, which will probably be the next step. Also update itanium mangling per `@rcvalle's` in https://github.com/rust-lang/rust/pull/121728/files#r1506570300, and fix a typo from step 1. Once these types are usable in code, I will add the codegen tests from #114607 (codegen is passing on that branch) This does add more `unimplemented!`s to Clippy, but I still don't think we can do better until library support is added. r? `@compiler-errors` cc `@Nilstrieb` `@rustbot` label +T-compiler +F-f16_and_f128
2024-03-02avoid collecting into vecs in some placesMatthias Krüger-20/+16
2024-03-01Add initial support for DataFlowSanitizerRamon de C Valle-0/+13
Adds initial support for DataFlowSanitizer to the Rust compiler. It currently supports `-Zsanitizer-dataflow-abilist`. Additional options for it can be passed to LLVM command line argument processor via LLVM arguments using `llvm-args` codegen option (e.g., `-Cllvm-args=-dfsan-combine-pointer-labels-on-load=false`).
2024-03-01Add `f16` and `f128` LLVM intrinsicsTrevor Gross-1/+116
2024-03-01Update outdated LLVM commentclubby789-6/+3
2024-03-01Auto merge of #121728 - tgross35:f16-f128-step1-ty-updates, r=compiler-errorsbors-4/+29
Add stubs in IR and ABI for `f16` and `f128` This is the very first step toward the changes in https://github.com/rust-lang/rust/pull/114607 and the [`f16` and `f128` RFC](https://rust-lang.github.io/rfcs/3453-f16-and-f128.html). It adds the types to `rustc_type_ir::FloatTy` and `rustc_abi::Primitive`, and just propagates those out as `unimplemented!` stubs where necessary. These types do not parse yet so there is no feature gate, and it should be okay to use `unimplemented!`. The next steps will probably be AST support with parsing and the feature gate. r? `@compiler-errors` cc `@Nilstrieb` suggested breaking the PR up in https://github.com/rust-lang/rust/pull/120645#issuecomment-1925900572
2024-02-28Add `f16` and `f128` to `rustc_type_ir::FloatTy` and `rustc_abi::Primitive`Trevor Gross-4/+29
Make changes necessary to support these types in the compiler.
2024-02-28Rename `DiagnosticBuilder` as `Diag`.Nicholas Nethercote-11/+7
Much better! Note that this involves renaming (and updating the value of) `DIAGNOSTIC_BUILDER` in clippy.
2024-02-26introduce and use ptradd/inbounds_ptradd instead of gepErik Desjardins-28/+16
2024-02-26remove struct_gep, use manual layout calculations for va_argErik Desjardins-81/+62
2024-02-26always use gep inbounds i8 (ptradd) for field offsetsErik Desjardins-3/+0
2024-02-27Auto merge of #121635 - 823984418:remove_archive_builder_lifetime_a, ↵bors-2/+2
r=nnethercote Remove useless lifetime of ArchiveBuilder `trait ArchiveBuilder<'a>` has a seemingly useless lifetime a, so I remove it. If this is intentional, please reject this PR. ```rust pub trait ArchiveBuilder<'a> { fn add_file(&mut self, path: &Path); fn add_archive( &mut self, archive: &Path, skip: Box<dyn FnMut(&str) -> bool + 'static>, ) -> io::Result<()>; fn build(self: Box<Self>, output: &Path) -> bool; } ```
2024-02-27Rollup merge of #121598 - RalfJung:catch_unwind, r=oli-obkMatthias Krüger-4/+4
rename 'try' intrinsic to 'catch_unwind' The intrinsic has nothing to do with `try` blocks, and corresponds to the stable `catch_unwind` function, so this makes a lot more sense IMO. Also rename Miri's special function while we are at it, to reflect the level of abstraction it works on: it's an unwinding mechanism, on which Rust implements panics.
2024-02-26Rollup merge of #121389 - klensy:llvm-warn-fix, r=nikicMatthias Krüger-6/+6
llvm-wrapper: fix few warnings Two fixes: first one is simple unsigned -> uint64_t, but how second one is more subtile, see commit description.
2024-02-26remove useless lifetime of ArchiveBuilder823984418-2/+2
2024-02-26rename 'try' intrinsic to 'catch_unwind'Ralf Jung-4/+4
2024-02-25Rollup merge of #121060 - clubby789:bool-newtypes, r=cjgillotMatthias Krüger-24/+31
Add newtypes for bool fields/params/return types Fixed all the cases of this found with some simple searches for `*/ bool` and `bool /*`; probably many more
2024-02-24Auto merge of #121569 - matthiaskrgr:rollup-awglrax, r=matthiaskrgrbors-4/+4
Rollup of 7 pull requests Successful merges: - #121343 (Add examples for some methods on slices) - #121374 (match lowering: Split off `test_candidates` into several functions and improve comments) - #121474 (Ignore compiletest test directive migration commits) - #121515 (promotion: don't promote int::MIN / -1) - #121530 (Fix incorrect doc of ScopedJoinHandle::is_finished) - #121551 (Forbid use of `extern "C-unwind"` inside standard library) - #121556 (Use `addr_of!`) r? `@ghost` `@rustbot` modify labels: rollup
2024-02-24Add assertions and clarify asm-goto with noreturnGary Guo-0/+1
2024-02-24Implement asm goto for LLVM and GCC backendGary Guo-10/+21
2024-02-24Add callbr support to LLVM wrapperGary Guo-0/+66
2024-02-24compiler: use `addr_of!`Pavel Grigorenko-4/+4
2024-02-23Handle .init_array link_section specially on wasmmatt rice-2/+8
2024-02-23check that simd_insert/extract indices are in-boundsRalf Jung-19/+34
2024-02-22Unconditionally pass -wasm-enable-ehNoa-6/+6
2024-02-22std support for wasm32 panic=unwindNoa-2/+11