about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm
AgeCommit message (Collapse)AuthorLines
2022-04-03Replace every `String` in Target(Options) with `Cow<'static, str>`Loïc BRANSTETT-9/+11
2022-04-02make memcmp return a value of c_int_width instead of i32David Morrison-2/+12
2022-03-30Rollup merge of #95461 - nyurik:spelling, r=lcnrDylan DPC-2/+2
Spellchecking some comments This PR attempts to clean up some minor spelling mistakes in comments
2022-03-30Spellchecking compiler codeYuri Astrakhan-1/+1
Address some spelling mistakes in strings, private function names, and function params.
2022-03-30Spellchecking some commentsYuri Astrakhan-2/+2
This PR attempts to clean up some minor spelling mistakes in comments
2022-03-28Auto merge of #95300 - workingjubilee:less-bitsets, r=eddybbors-12/+14
Skip needless bitset for debuginfo Found this while digging around looking at the inlining logic. Seemed obvious enough so I decided to try to take care of it. Is this what you had in mind, `@eddyb?`
2022-03-25Skip needless bitset for debuginfoJubilee Young-12/+14
2022-03-24debuginfo: Fix debuginfo for Box<T> where T is unsized.Michael Woerister-1/+18
Before this fix, the debuginfo for the fields was generated from the struct defintion of Box<T>, but (at least at the moment) the compiler pretends that Box<T> is just a (fat) pointer, so the fields need to be `pointer` and `vtable` instead of `__0: Unique<T>` and `__1: Allocator`. This is meant as a temporary mitigation until we can make sure that simply treating Box as a regular struct in debuginfo does not cause too much breakage in the ecosystem.
2022-03-23Rollup merge of #91608 - workingjubilee:fold-neon-fp, r=nagisa,AmanieuDylan DPC-4/+6
Fold aarch64 feature +fp into +neon Arm's FEAT_FP and Feat_AdvSIMD describe the same thing on AArch64: The Neon unit, which handles both floating point and SIMD instructions. Moreover, a configuration for AArch64 must include both or neither. Arm says "entirely proprietary" toolchains may omit floating point: https://developer.arm.com/documentation/102374/0101/Data-processing---floating-point In the Programmer's Guide for Armv8-A, Arm says AArch64 can have both FP and Neon or neither in custom implementations: https://developer.arm.com/documentation/den0024/a/AArch64-Floating-point-and-NEON In "Bare metal boot code for Armv8-A", enabling Neon and FP is just disabling the same trap flag: https://developer.arm.com/documentation/dai0527/a In an unlikely future where "Neon and FP" become unrelated, we can add "[+-]fp" as its own feature flag. Until then, we can simplify programming with Rust on AArch64 by folding both into "[+-]neon", which is valid as it supersets both. "[+-]neon" is retained for niche uses such as firmware, kernels, "I just hate floats", and so on. I am... pretty sure no one is relying on this. An argument could be made that, as we are not an "entirely proprietary" toolchain, we should not support AArch64 without floats at all. I think that's a bit excessive. However, I want to recognize the intent: programming for AArch64 should be simplified where possible. For x86-64, programmers regularly set up illegal feature configurations because it's hard to understand them, see https://github.com/rust-lang/rust/issues/89586. And per the above notes, plus the discussion in https://github.com/rust-lang/rust/issues/86941, there should be no real use cases for leaving these features split: the two should in fact always go together. - Fixes rust-lang/rust#95002. - Fixes rust-lang/rust#95064. - Fixes rust-lang/rust#95122.
2022-03-22Filter for all features instead of anyJubilee Young-3/+6
Adds regression tests for feature logic Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com> Co-authored-by: Simonas Kazlauskas <git@kazlauskas.me>
2022-03-22Fold aarch64 feature +fp into +neonJubilee Young-1/+0
Arm's FEAT_FP and Feat_AdvSIMD describe the same thing on AArch64: The Neon unit, which handles both floating point and SIMD instructions. Moreover, a configuration for AArch64 must include both or neither. Arm says "entirely proprietary" toolchains may omit floating point: https://developer.arm.com/documentation/102374/0101/Data-processing---floating-point In the Programmer's Guide for Armv8-A, Arm says AArch64 can have both FP and Neon or neither in custom implementations: https://developer.arm.com/documentation/den0024/a/AArch64-Floating-point-and-NEON In "Bare metal boot code for Armv8-A", enabling Neon and FP is just disabling the same trap flag: https://developer.arm.com/documentation/dai0527/a In an unlikely future where "Neon and FP" become unrelated, we can add "[+-]fp" as its own feature flag. Until then, we can simplify programming with Rust on AArch64 by folding both into "[+-]neon", which is valid as it supersets both. "[+-]neon" is retained for niche uses such as firmware, kernels, "I just hate floats", and so on.
2022-03-18Auto merge of #88098 - Amanieu:oom_panic, r=nagisabors-1/+11
Implement -Z oom=panic This PR removes the `#[rustc_allocator_nounwind]` attribute on `alloc_error_handler` which allows it to unwind with a panic instead of always aborting. This is then used to implement `-Z oom=panic` as per RFC 2116 (tracking issue #43596). Perf and binary size tests show negligible impact.
2022-03-15Auto merge of #94261 - michaelwoerister:debuginfo-types-refactor, r=wesleywiserbors-1793/+2243
debuginfo: Refactor debuginfo generation for types This PR implements the refactoring of the `rustc_codegen_llvm::debuginfo::metadata` module as described in MCP https://github.com/rust-lang/compiler-team/issues/482. In particular it - changes names to use `di_node` instead of `metadata` - uniformly names all functions that build new debuginfo nodes `build_xyz_di_node` - renames `CrateDebugContext` to `CodegenUnitDebugContext` (which is more accurate) - removes outdated parts from `compiler/rustc_codegen_llvm/src/debuginfo/doc.md` - moves `TypeMap` and functions that work directly work with it to a new `type_map` module - moves enum related builder functions to a new `enums` module - splits enum debuginfo building for the native and cpp-like cases, since they are mostly separate - uses `SmallVec` instead of `Vec` in many places - removes the old infrastructure for dealing with recursion cycles (`create_and_register_recursive_type_forward_declaration()`, `RecursiveTypeDescription`, `set_members_of_composite_type()`, `MemberDescription`, `MemberDescriptionFactory`, `prepare_xyz_metadata()`, etc) - adds `type_map::build_type_with_children()` as a replacement for dealing with recursion cycles - adds many (doc-)comments explaining what's going on - changes cpp-like naming for C-Style enums so they don't get a `enum$<...>` name (because the NatVis visualizer does not apply to them) - fixes detection of what is a C-style enum because some enums where classified as C-style even though they have fields - changes cpp-like naming for generator enums so that NatVis works for them - changes the position of discriminant debuginfo node so it is consistently nested inside the top-level union instead of, sometimes, next to it The following could be done in subsequent PRs: - add caching for `closure_saved_names_of_captured_variables` - add caching for `generator_layout_and_saved_local_names` - fix inconsistent handling of what is considered a C-style enum wrt to debuginfo - rename `metadata` module to `types` - move common generator fields to front instead of appending them This PR is based on https://github.com/rust-lang/rust/pull/93644 which is not merged yet. Right now, the changes are all done in one big commit. They could be split into smaller commits but hopefully the list of changes above makes it tractable to review them as a single commit too. For now: r? `@ghost` (let's see if this affects compile times)
2022-03-14debuginfo: Refactor debuginfo generation for types -- Rename ↵Michael Woerister-1/+1
DebugInfoMethods::create_vtable_metadata() to DebugInfoMethods::create_vtable_debuginfo()
2022-03-14debuginfo: Refactor debuginfo generation for types -- Address review comments.Michael Woerister-18/+22
2022-03-14Rollup merge of #90621 - adamgemmell:dev/stabilise-target-feature, r=AmanieuMatthias Krüger-3/+14
Stabilise `aarch64_target_feature` This PR stabilises `aarch64_target_feature` - see https://github.com/rust-lang/rust/issues/90620
2022-03-14debuginfo: Refactor debuginfo generation for types -- Address outstanding ↵Michael Woerister-20/+19
FIXMEs.
2022-03-14debuginfo: Refactor debuginfo generation for types -- Run x.py fmtMichael Woerister-4/+6
2022-03-14Remove out-dated information from rustc_codegen_llvm/src/debuginfo/doc.mdMichael Woerister-54/+5
2022-03-14debuginfo: Refactor debuginfo generation for typesMichael Woerister-1732/+2226
This commit - changes names to use di_node instead of metadata - uniformly names all functions that build new debuginfo nodes build_xyz_di_node - renames CrateDebugContext to CodegenUnitDebugContext (which is more accurate) - moves TypeMap and functions that work directly work with it to a new type_map module - moves and reimplements enum related builder functions to a new enums module - splits enum debuginfo building for the native and cpp-like cases, since they are mostly separate - uses SmallVec instead of Vec in many places - removes the old infrastructure for dealing with recursion cycles (create_and_register_recursive_type_forward_declaration(), RecursiveTypeDescription, set_members_of_composite_type(), MemberDescription, MemberDescriptionFactory, prepare_xyz_metadata(), etc) - adds type_map::build_type_with_children() as a replacement for dealing with recursion cycles - adds many (doc-)comments explaining what's going on - changes cpp-like naming for C-Style enums so they don't get a enum$<...> name (because the NatVis visualizer does not apply to them) - fixes detection of what is a C-style enum because some enums where classified as C-style even though they have fields - changes the position of discriminant debuginfo node so it is consistently nested inside the top-level union instead of, sometimes, next to it
2022-03-14Tie `fp` and `neon`Adam Gemmell-3/+14
2022-03-12Auto merge of #94733 - nnethercote:fix-AdtDef-interning, r=fee1-deadbors-10/+10
Improve `AdtDef` interning. This commit makes `AdtDef` use `Interned`. Much of the commit is tedious changes to introduce getter functions. The interesting changes are in `compiler/rustc_middle/src/ty/adt.rs`. r? `@fee1-dead`
2022-03-11Improve `AdtDef` interning.Nicholas Nethercote-10/+10
This commit makes `AdtDef` use `Interned`. Much the commit is tedious changes to introduce getter functions. The interesting changes are in `compiler/rustc_middle/src/ty/adt.rs`.
2022-03-10Rollup merge of #94728 - compiler-errors:box-allocator-zst-meta, ↵Dylan DPC-1/+3
r=michaelwoerister Only emit pointer-like metadata for `Box<T, A>` when `A` is ZST Basically copy the change in #94043, but for debuginfo. r? ``@michaelwoerister`` Fixes #94725
2022-03-10Auto merge of #94764 - nikic:update-llvm-3, r=nagisabors-4/+5
Update LLVM submodule This merges upstream changes from the 14.x release branch. Fixes #89609. Fixes #93923. Fixes #94032.
2022-03-09Use new pass manager on s390x with LLVM 14Nikita Popov-4/+5
The problematic compile-time issue should be resolved with this version.
2022-03-08add `#[rustc_pass_by_value]` to more typeslcnr-4/+4
2022-03-07only emit pointer-like metadata for BZST-allocator BoxMichael Goulet-1/+3
2022-03-07Auto merge of #94690 - nnethercote:clarify-Layout-interning, r=fee1-deadbors-7/+7
Clarify `Layout` interning. `Layout` is another type that is sometimes interned, sometimes not, and we always use references to refer to it so we can't take any advantage of the uniqueness properties for hashing or equality checks. This commit renames `Layout` as `LayoutS`, and then introduces a new `Layout` that is a newtype around an `Interned<LayoutS>`. It also interns more layouts than before. Previously layouts within layouts (via the `variants` field) were never interned, but now they are. Hence the lifetime on the new `Layout` type. Unlike other interned types, these ones are in `rustc_target` instead of `rustc_middle`. This reflects the existing structure of the code, which does layout-specific stuff in `rustc_target` while `TyAndLayout` is generic over the `Ty`, allowing the type-specific stuff to occur in `rustc_middle`. The commit also adds a `HashStable` impl for `Interned`, which was needed. It hashes the contents, unlike the `Hash` impl which hashes the pointer. r? `@fee1-dead`
2022-03-07Clarify `Layout` interning.Nicholas Nethercote-7/+7
`Layout` is another type that is sometimes interned, sometimes not, and we always use references to refer to it so we can't take any advantage of the uniqueness properties for hashing or equality checks. This commit renames `Layout` as `LayoutS`, and then introduces a new `Layout` that is a newtype around an `Interned<LayoutS>`. It also interns more layouts than before. Previously layouts within layouts (via the `variants` field) were never interned, but now they are. Hence the lifetime on the new `Layout` type. Unlike other interned types, these ones are in `rustc_target` instead of `rustc_middle`. This reflects the existing structure of the code, which does layout-specific stuff in `rustc_target` while `TyAndLayout` is generic over the `Ty`, allowing the type-specific stuff to occur in `rustc_middle`. The commit also adds a `HashStable` impl for `Interned`, which was needed. It hashes the contents, unlike the `Hash` impl which hashes the pointer.
2022-03-07Auto merge of #94638 - erikdesjardins:noextranull, r=nagisabors-30/+18
cleanup: remove unused ability to have LLVM null-terminate const strings (and the copied function in rustc_codegen_gcc) Noticed this while writing https://github.com/rust-lang/rust/pull/94450#issuecomment-1059687348. r? `@nagisa`
2022-03-06Auto merge of #94597 - nnethercote:ConstAllocation, r=fee1-deadbors-9/+13
Introduce `ConstAllocation`. Currently some `Allocation`s are interned, some are not, and it's very hard to tell at a use point which is which. This commit introduces `ConstAllocation` for the known-interned ones, which makes the division much clearer. `ConstAllocation::inner()` is used to get the underlying `Allocation`. In some places it's natural to use an `Allocation`, in some it's natural to use a `ConstAllocation`, and in some places there's no clear choice. I've tried to make things look as nice as possible, while generally favouring `ConstAllocation`, which is the type that embodies more information. This does require quite a few calls to `inner()`. The commit also tweaks how `PartialOrd` works for `Interned`. The previous code was too clever by half, building on `T: Ord` to make the code shorter. That caused problems with deriving `PartialOrd` and `Ord` for `ConstAllocation`, so I changed it to build on `T: PartialOrd`, which is slightly more verbose but much more standard and avoided the problems. r? `@fee1-dead`
2022-03-07Introduce `ConstAllocation`.Nicholas Nethercote-9/+13
Currently some `Allocation`s are interned, some are not, and it's very hard to tell at a use point which is which. This commit introduces `ConstAllocation` for the known-interned ones, which makes the division much clearer. `ConstAllocation::inner()` is used to get the underlying `Allocation`. In some places it's natural to use an `Allocation`, in some it's natural to use a `ConstAllocation`, and in some places there's no clear choice. I've tried to make things look as nice as possible, while generally favouring `ConstAllocation`, which is the type that embodies more information. This does require quite a few calls to `inner()`. The commit also tweaks how `PartialOrd` works for `Interned`. The previous code was too clever by half, building on `T: Ord` to make the code shorter. That caused problems with deriving `PartialOrd` and `Ord` for `ConstAllocation`, so I changed it to build on `T: PartialOrd`, which is slightly more verbose but much more standard and avoided the problems.
2022-03-06Auto merge of #94679 - matthiaskrgr:rollup-9vd7w6a, r=matthiaskrgrbors-1/+1
Rollup of 3 pull requests Successful merges: - #94659 (explain why shift with signed offset works the way it does) - #94671 (fix pin doc typo) - #94672 (Improved error message for failed bitcode load) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-03-06cleanup: remove unused ability to have LLVM null-terminate const stringsErik Desjardins-30/+18
2022-03-06Improved error message for failed bitcode loadJoe-1/+1
"bc" is an unnecessary shorthand that obfuscates the compilation error
2022-03-04Always include global target features in function attributesTomasz Miąsko-7/+6
This ensures that information about target features configured with `-C target-feature=...` or detected with `-C target-cpu=native` is retained for subsequent consumers of LLVM bitcode. This is crucial for linker plugin LTO, since this information is not conveyed to the plugin otherwise.
2022-03-04Use SmallStr when building target-features LLVM attributeTomasz Miąsko-1/+2
2022-03-04Auto merge of #94539 - tmiasko:string-attributes, r=nikicbors-37/+47
Pass LLVM string attributes as string slices
2022-03-04Auto merge of #94159 - erikdesjardins:align-load, r=nikicbors-8/+31
Add !align metadata on loads of &/&mut/Box Note that this refers to the alignment of what the loaded value points to, _not_ the alignment of the loaded value itself. r? `@ghost` (blocked on #94158)
2022-03-03Add -Z oom={panic,abort} command-line optionAmanieu d'Antras-1/+11
2022-03-03all: fix some typoscuishuang-5/+5
Signed-off-by: cuishuang <imcusg@gmail.com>
2022-03-03Rollup merge of #94529 - GuillaumeGomez:unused-doc-comments-blocks, r=estebankDylan DPC-2/+2
Unused doc comments blocks Fixes #77030.
2022-03-03Pass LLVM string attributes as string slicesTomasz Miąsko-37/+47
2022-03-02Fix unused_doc_comments lint errorsGuillaume Gomez-2/+2
2022-03-02rename ErrorReported -> ErrorGuaranteedmark-3/+3
2022-03-02Auto merge of #94229 - erikdesjardins:rem2, r=nikicbors-61/+13
Remove LLVM attribute removal This was necessary before, because `declare_raw_fn` would always apply the default optimization attributes to every declared function. Then `attributes::from_fn_attrs` would have to remove the default attributes in the case of, e.g. `#[optimize(speed)]` in a `-Os` build. (see [`src/test/codegen/optimize-attr-1.rs`](https://github.com/rust-lang/rust/blob/03a8cc7df1d65554a4d40825b0490c93ac0f0236/src/test/codegen/optimize-attr-1.rs#L33)) However, every relevant callsite of `declare_raw_fn` (i.e. where we actually generate code for the function, and not e.g. a call to an intrinsic, where optimization attributes don't [?] matter) calls `from_fn_attrs`, so we can remove the attribute setting from `declare_raw_fn`, and rely on `from_fn_attrs` to apply the correct attributes all at once. r? `@ghost` (blocked on #94221) `@rustbot` label S-blocked
2022-03-02Auto merge of #87402 - nagisa:nagisa/request-feature-requests-for-features, ↵bors-89/+158
r=estebank Direct users towards using Rust target feature names in CLI This PR consists of a couple of changes on how we handle target features. In particular there is a bug-fix wherein we avoid passing through features that aren't prefixed by `+` or `-` to LLVM. These appear to be causing LLVM to assert, which is pretty poor a behaviour (and also makes it pretty clear we expect feature names to be prefixed). The other commit, I anticipate to be somewhat more controversial is outputting a warning when users specify a LLVM-specific, or otherwise unknown, feature name on the CLI. In those situations we request users to either replace it with a known Rust feature name (e.g. `bmi` -> `bmi1`) or file a feature request. I've a couple motivations for this: first of all, if users are specifying these features on the command line, I'm pretty confident there is also a need for these features to be usable via `#[cfg(target_feature)]` machinery. And second, we're growing a fair number of backends recently and having ability to provide some sort of unified-ish interface in this place seems pretty useful to me. Sponsored by: standard.ai
2022-03-01Auto merge of #94402 - erikdesjardins:revert-coldland, r=nagisabors-22/+3
Revert "Auto merge of #92419 - erikdesjardins:coldland, r=nagisa" Should fix (untested) #94390 Reopens #46515, #87055 r? `@ehuss`
2022-02-28Add !align metadata on loads of &/&mut/BoxErik Desjardins-8/+31
Note that this refers to the alignment of what the loaded value points to, _not_ the alignment of the loaded value itself.