about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src
AgeCommit message (Collapse)AuthorLines
2024-03-08Auto merge of #122048 - erikdesjardins:inbounds, r=oli-obkbors-6/+1
Use GEP inbounds for ZST and DST field offsets ZST field offsets have been non-`inbounds` since I made [this old layout change](https://github.com/rust-lang/rust/pull/73453/files#diff-160634de1c336f2cf325ff95b312777326f1ab29fec9b9b21d5ee9aae215ecf5). Before that, they would have been `inbounds` due to using `struct_gep`. Using `inbounds` for ZSTs likely doesn't matter for performance, but I'd like to remove the special case. DST field offsets have been non-`inbounds` since the alignment-aware DST field offset computation was first [implemented](https://github.com/erikdesjardins/rust/commit/a2557d472e570559caf18d9b042cd941f5002398#diff-04fd352da30ca186fe0bb71cc81a503d1eb8a02ca17a3769e1b95981cd20964aR1188) in 1.6 (back then `GEPi()` would be used for `inbounds`), but I don't think there was any reason for it. Split out from #121577 / #121665. r? `@oli-obk` cc `@RalfJung` -- is there some weird situation where field offsets can't be `inbounds`? Note that it's fine for `inbounds` offsets to be one-past-the-end, so it's okay even if there's a ZST as the last field in the layout: > The base pointer has an in bounds address of an allocated object, which means that it points into an allocated object, or to its end. [(link)](https://llvm.org/docs/LangRef.html#getelementptr-instruction) For https://github.com/rust-lang/unsafe-code-guidelines/issues/93, zero-offset GEP is (now) always `inbounds`: > Note that getelementptr with all-zero indices is always considered to be inbounds, even if the base pointer does not point to an allocated object. [(link)](https://llvm.org/docs/LangRef.html#getelementptr-instruction)
2024-03-08Fix misaligned loads when loading UEFI arg pointersbeetrees-4/+6
2024-03-06Add arm64ec-pc-windows-msvc targetDaniel Paoliello-30/+39
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-06Rollup merge of #122051 - erikdesjardins:cleanup, r=nikicMatthias Krüger-2/+1
cleanup: remove zero-offset GEP This GEP would've been used to change the pointer type in the past, but after opaque pointers it's a no-op. I missed removing this in #105545. Split out from #121577.
2024-03-05remove all-zero GEPErik Desjardins-2/+1
This always produces zero offset, regardless of what the struct layout is. Originally, this may have been necessary in order to change the pointer type, but with opaque pointers, it is no longer necessary.
2024-03-05Rollup merge of #122028 - oli-obk:drop_in_place_leftovers, r=compiler-errorsMatthias Krüger-1/+1
Remove some dead code drop_in_place has been a lang item, not an intrinsic, for forever
2024-03-05Remove some dead codeOli Scherer-1/+1
drop_in_place has been a lang item, not an intrinsic, for forever
2024-03-05only set noalias on Box with the global allocatorRalf Jung-0/+1
2024-03-05Adjust wordingKai Luo-1/+1
2024-03-05RebasedKai Luo-0/+15
2024-03-05[AIX] Remove AixLinker's debuginfo() implementationKai Luo-10/+1
`-s` option doesn't perfectly fit into debuginfo()'s semantics and may unexpectedly remove metadata in shared libraries. Remove the implementation and suggest user to use `strip` utility instead.
2024-03-05Auto merge of #121780 - nnethercote:diag-renaming2, r=davidtwcobors-8/+8
Diagnostic renaming 2 A sequel to #121489. r? `@davidtwco`
2024-03-05Fix some out-of-date comments.Nicholas Nethercote-4/+4
2024-03-05Rename `DiagnosticMessage` as `DiagMessage`.Nicholas Nethercote-4/+4
2024-03-05Auto merge of #120675 - oli-obk:intrinsics3.0, r=pnkfelixbors-17/+46
Add a scheme for moving away from `extern "rust-intrinsic"` entirely All `rust-intrinsic`s can become free functions now, either with a fallback body, or with a dummy body and an attribute, requiring backends to actually implement the intrinsic. This PR demonstrates the dummy-body scheme with the `vtable_size` intrinsic. cc https://github.com/rust-lang/rust/issues/63585 follow-up to #120500 MCP at https://github.com/rust-lang/compiler-team/issues/720
2024-03-04Rollup merge of #121969 - nnethercote:ParseSess-cleanups, r=wesleywiserMatthias Krüger-1/+1
`ParseSess` cleanups The main change here is to rename all `ParseSess` values as `psess`. Plus a few other small cleanups. r? `@wesleywiser`
2024-03-05Rename all `ParseSess` variables/fields/lifetimes as `psess`.Nicholas Nethercote-1/+1
Existing names for values of this type are `sess`, `parse_sess`, `parse_session`, and `ps`. `sess` is particularly annoying because that's also used for `Session` values, which are often co-located, and it can be difficult to know which type a value named `sess` refers to. (That annoyance is the main motivation for this change.) `psess` is nice and short, which is good for a name used this much. The commit also renames some `parse_sess_created` values as `psess_created`.
2024-03-04Remove some depgraph edges on the HIR by invoking the intrinsic query ↵Oli Scherer-2/+1
instead of checking the attribute
2024-03-04Avoid some boolean argument footgunsOli Scherer-10/+26
2024-03-04Add a scheme for moving away from `extern "rust-intrinsic"` entirelyOli Scherer-1/+15
2024-03-04Return a struct from `query intrinsic` to be able to add another field in ↵Oli Scherer-6/+6
the next commit
2024-03-04use GEP inbounds for ZST and DST field offsetsErik Desjardins-6/+1
For the former, it's fine for `inbounds` offsets to be one-past-the-end, so it's okay even if the ZST is the last field in the layout: > The base pointer has an in bounds address of an allocated object, > which means that it points into an allocated object, or to its end. https://llvm.org/docs/LangRef.html#getelementptr-instruction For the latter, even DST fields must always be inside the layout (or to its end for ZSTs), so using inbounds is also fine there.
2024-03-04Auto merge of #121900 - chenyukang:yukang-fix-121425-repr-pack-error, ↵bors-1/+1
r=compiler-errors Fix misleading message in struct repr alignment and packed Fixes #121425 By the way, fix the spans for the argument in the second commit.
2024-03-03Auto merge of #121665 - erikdesjardins:ptradd, r=nikicbors-35/+19
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-02Fix misleading message when using a named constant as a struct alignment/packyukang-1/+1
2024-03-01Add initial support for DataFlowSanitizerRamon de C Valle-0/+8
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-01Rollup merge of #121730 - ecnelises:aix_pgo, r=wesleywiserMatthias Krüger-1/+3
Add profiling support to AIX AIX ld needs special option to merge objects with profiling. Also, profiler_builtins should include builtins for AIX from compiler-rt.
2024-03-01Auto merge of #121728 - tgross35:f16-f128-step1-ty-updates, r=compiler-errorsbors-3/+7
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-29Rollup merge of #121464 - alexcrichton:fix-wasm64, r=wesleywiserMatthias Krüger-50/+46
rustc: Fix wasm64 metadata object files It looks like LLD will detect object files being either 32 or 64-bit depending on any memory present. LLD will additionally reject 32-bit objects during a 64-bit link. Previously metadata objects did not have any memories in them which led LLD to conclude they were 32-bit objects which broke 64-bit targets for wasm. This commit fixes this by ensuring that for 64-bit targets there's a memory object present to get LLD to detect it's a 64-bit target. Additionally this commit moves away from a hand-crafted wasm encoder to the `wasm-encoder` crate on crates.io as the complexity grows for the generated object file. Closes #121460
2024-02-29Rename `DiagCtxt::with_emitter` as `DiagCtxt::new`.Nicholas Nethercote-1/+1
Because it's now the only constructor.
2024-02-28Add `f16` and `f128` to `rustc_type_ir::FloatTy` and `rustc_abi::Primitive`Trevor Gross-3/+7
Make changes necessary to support these types in the compiler.
2024-02-28Add profiling support to AIXQiu Chaofan-1/+3
AIX ld needs special option to merge objects with profiling. Also, profiler_builtins should include builtins for AIX from compiler-rt.
2024-02-27use non-inbounds GEP for ZSTs, add fixmesErik Desjardins-0/+5
2024-02-28Rename `DiagnosticArg{,Map,Name,Value}` as `DiagArg{,Map,Name,Value}`.Nicholas Nethercote-13/+13
2024-02-28Rename `DiagnosticBuilder` as `Diag`.Nicholas Nethercote-8/+8
Much better! Note that this involves renaming (and updating the value of) `DIAGNOSTIC_BUILDER` in clippy.
2024-02-28Rename `SubDiagnostic` as `Subdiag`.Nicholas Nethercote-1/+1
Note the change of the `D` to `d`, to match all the other names that have `Subdiag` in them, such as `SubdiagnosticMessage` and `derive(Subdiagnostic)`.
2024-02-28Rename `Diagnostic` as `DiagInner`.Nicholas Nethercote-3/+3
I started by changing it to `DiagData`, but that didn't feel right. `DiagInner` felt much better.
2024-02-26introduce and use ptradd/inbounds_ptradd instead of gepErik Desjardins-5/+10
2024-02-26remove struct_gep, use manual layout calculations for va_argErik Desjardins-1/+0
2024-02-26always use gep inbounds i8 (ptradd) for field offsetsErik Desjardins-30/+5
2024-02-27Auto merge of #121635 - 823984418:remove_archive_builder_lifetime_a, ↵bors-4/+4
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-26remove useless lifetime of ArchiveBuilder823984418-4/+4
2024-02-25Auto merge of #120650 - clubby789:switchint-const, r=saethlinbors-5/+13
Use `br` instead of a conditional when switching on a constant boolean r? `@ghost`
2024-02-24Add assertions and clarify asm-goto with noreturnGary Guo-0/+1
2024-02-24Implement asm goto for LLVM and GCC backendGary Guo-9/+35
2024-02-24Implement asm goto in MIR and MIR loweringGary Guo-0/+3
2024-02-24Change InlineAsm to allow multiple targets insteadGary Guo-2/+2
2024-02-24Add asm label support to AST and HIRGary Guo-1/+2
2024-02-24Rollup merge of #121522 - RalfJung:insert-extract-boundscheck, r=oli-obkMatthias Krüger-10/+2
check that simd_insert/extract indices are in-bounds Fixes https://github.com/rust-lang/rust/issues/77477 r? `@oli-obk`
2024-02-23rustc: Fix wasm64 metadata object filesAlex Crichton-50/+46
It looks like LLD will detect object files being either 32 or 64-bit depending on any memory present. LLD will additionally reject 32-bit objects during a 64-bit link. Previously metadata objects did not have any memories in them which led LLD to conclude they were 32-bit objects which broke 64-bit targets for wasm. This commit fixes this by ensuring that for 64-bit targets there's a memory object present to get LLD to detect it's a 64-bit target. Additionally this commit moves away from a hand-crafted wasm encoder to the `wasm-encoder` crate on crates.io as the complexity grows for the generated object file. Closes #121460