about summary refs log tree commit diff
path: root/compiler/rustc_codegen_gcc
AgeCommit message (Collapse)AuthorLines
2023-09-01Deduplicate inlined function debug info, but create a new lexical scope to ↵Daniel Paoliello-1/+1
child subsequent scopes and variables from colliding
2023-08-29Rollup merge of #111580 - atsuzaki:layout-ice, r=oli-obkMatthias Krüger-1/+2
Don't ICE on layout computation failure Fixes #111176 regression. r? `@oli-obk`
2023-08-28Don't ICE on layout computation failureKatherine Philip-1/+2
2023-08-28Rollup merge of #115240 - RalfJung:llvm-no-type, r=bjorn3Matthias Krüger-37/+17
codegen_llvm/llvm_type: avoid matching on the Rust type This `match` is highly suspicious. Looking at `scalar_llvm_type_at` I think it makes no difference. But if it were to make a difference that would be a huge problem, since it doesn't look through `repr(transparent)`! Cc `@eddyb` `@bjorn3`
2023-08-28remove an unused argumentRalf Jung-10/+10
it was already unused before, but due to the recursion the compiler did not realize
2023-08-28carry out the same changes in the gcc backendRalf Jung-27/+7
2023-08-25Revert "Use the same DISubprogram for each instance of the same inlined ↵Wesley Wiser-1/+1
function within the caller" This reverts commit 687bffa49375aa00bacc51f5d9adfb84a9453e17. Reverting to resolve ICEs reported on nightly.
2023-08-22Auto merge of #114643 - dpaoliello:inlinedebuginfo, r=wesleywiserbors-1/+1
Use the same DISubprogram for each instance of the same inlined function within a caller # Issue Details: The call to `panic` within a function like `Option::unwrap` is translated to LLVM as a `tail call` (as it will never return), when multiple calls to the same function like this is inlined LLVM will notice the common `tail call` block (i.e., loading the same panic string + location info and then calling `panic`) and merge them together. When merging these instructions together, LLVM will also attempt to merge the debug locations as well, but this fails (i.e., debug info is dropped) as Rust emits a new `DISubprogram` at each inline site thus LLVM doesn't recognize that these are actually the same function and so thinks that there isn't a common debug location. As an example of this when building for x86_64 Windows (note the lack of `.cv_loc` before the call to `panic`, thus it will be attributed to the same line at the `addq` instruction): ``` .cv_loc 0 1 23 0 # src\lib.rs:23:0 addq $40, %rsp retq leaq .Lalloc_f570dea0a53168780ce9a91e67646421(%rip), %rcx leaq .Lalloc_629ace53b7e5b76aaa810d549cc84ea3(%rip), %r8 movl $43, %edx callq _ZN4core9panicking5panic17h12e60b9063f6dee8E int3 ``` # Fix Details: Cache the `DISubprogram` emitted for each inlined function instance within a caller so that this can be reused if that instance is encountered again, this also requires caching the `DILexicalBlock` and `DIVariable` objects to avoid creating duplicates. After this change the above assembly now looks like: ``` .cv_loc 0 1 23 0 # src\lib.rs:23:0 addq $40, %rsp retq .cv_inline_site_id 5 within 0 inlined_at 1 0 0 .cv_inline_site_id 6 within 5 inlined_at 1 12 0 .cv_loc 6 2 935 0 # library\core\src\option.rs:935:0 leaq .Lalloc_5f55955de67e57c79064b537689facea(%rip), %rcx leaq .Lalloc_e741d4de8cb5801e1fd7a6c6795c1559(%rip), %r8 movl $43, %edx callq _ZN4core9panicking5panic17hde1558f32d5b1c04E int3 ```
2023-08-15Auto merge of #114467 - Amanieu:asm-unstable-features, r=davidtwcobors-2/+2
Use `unstable_target_features` when checking inline assembly This is necessary to properly validate register classes even when the relevant target feature name is still unstable.
2023-08-14add a csky-unknown-linux-gnuabiv2 targetDirreke-0/+6
2023-08-11Use the same DISubprogram for each instance of the same inlined function ↵Daniel Paoliello-1/+1
within the caller
2023-08-07Rollup merge of #114382 - scottmcm:compare-bytes-intrinsic, r=cjgillotMatthias Krüger-0/+15
Add a new `compare_bytes` intrinsic instead of calling `memcmp` directly As discussed in #113435, this lets the backends be the place that can have the "don't call the function if n == 0" logic, if it's needed for the target. (I didn't actually *add* those checks, though, since as I understood it we didn't actually need them on known targets?) Doing this also let me make it `const` (unstable), which I don't think `extern "C" fn memcmp` can be. cc `@RalfJung` `@Amanieu`
2023-08-06Apply suggestions from code reviewscottmcm-0/+1
Co-authored-by: Ralf Jung <post@ralfj.de>
2023-08-06Add a new `compare_bytes` intrinsic instead of calling `memcmp` directlyScott McMurray-0/+14
2023-08-06Generate better function argument names in global_allocator expansionDavid Tolnay-2/+2
2023-08-04Rollup merge of #114450 - chenyukang:yukang-fix-114435, r=compiler-errorsMatthias Krüger-1/+1
Fix ICE failed to get layout for ReferencesError Fixes #114435 r? `@compiler-errors`
2023-08-05Fix ICE failed to get layout for ReferencesErroryukang-1/+1
2023-08-04Use `unstable_target_features` when checking inline assemblyAmanieu d'Antras-2/+2
This is necessary to properly validate register classes even when the relevant target feature name is still unstable.
2023-08-03Forbid old-style `simd_shuffleN` intrinsicsOli Scherer-195/+250
2023-08-01Auto merge of #105545 - erikdesjardins:ptrclean, r=bjorn3bors-11/+26
cleanup: remove pointee types This can't be merged until the oldest LLVM version we support uses opaque pointers, which will be the case after #114148. (Also note `-Cllvm-args="-opaque-pointers=0"` can technically be used in LLVM 15, though I don't think we should support that configuration.) I initially hoped this would provide some minor perf win, but in https://github.com/rust-lang/rust/pull/105412#issuecomment-1341224450 it had very little impact, so this is only valuable as a cleanup. As a followup, this will enable #96242 to be resolved. r? `@ghost` `@rustbot` label S-blocked
2023-07-31Use standard Rust capitalization rules for names containing "LTO".Nicholas Nethercote-4/+4
2023-07-29cg_ssa: remove pointee types and pointercast/bitcast-of-ptrErik Desjardins-11/+26
2023-07-24Auto merge of #113877 - ↵bors-322/+58
JhonnyBillM:reuse-codegen-ssa-monomorphization-errors-in-gcc, r=davidtwco Reuse `codegen_ssa` monomorphization errors in `codegen_gcc` Removes monomorphization errors duplication by reusing the ones defined in `codegen_ssa`. Also updates `expected_simd` errors usage in `codegen_gcc` by assuming we want to treat those parameters as translatable. See https://github.com/rust-lang/rust/commit/7a888fb56e23abded6eb5ec0803f182caacc89cb
2023-07-21Revert "Auto merge of #113166 - moulins:ref-niches-initial, r=oli-obk"David Tolnay-2/+1
This reverts commit 557359f92512ca88b62a602ebda291f17a953002, reversing changes made to 1e6c09a803fd543a98bfbe1624d697a55300a786.
2023-07-21Auto merge of #113166 - moulins:ref-niches-initial, r=oli-obkbors-1/+2
Prototype: Add unstable `-Z reference-niches` option MCP: rust-lang/compiler-team#641 Relevant RFC: rust-lang/rfcs#3204 This prototype adds a new `-Z reference-niches` option, controlling the range of valid bit-patterns for reference types (`&T` and `&mut T`), thereby enabling new enum niching opportunities. Like `-Z randomize-layout`, this setting is crate-local; as such, references to built-in types (primitives, tuples, ...) are not affected. The possible settings are (here, `MAX` denotes the all-1 bit-pattern): | `-Z reference-niches=` | Valid range | |:---:|:---:| | `null` (the default) | `1..=MAX` | | `size` | `1..=(MAX- size)` | | `align` | `align..=MAX.align_down_to(align)` | | `size,align` | `align..=(MAX-size).align_down_to(align)` | ------ This is very WIP, and I'm not sure the approach I've taken here is the best one, but stage 1 tests pass locally; I believe this is in a good enough state to unleash this upon unsuspecting 3rd-party code, and see what breaks.
2023-07-21Rollup merge of #113723 - khei4:khei4/llvm-stats, r=oli-obk,nikicMatthias Krüger-0/+4
Resurrect: rustc_llvm: Add a -Z `print-codegen-stats` option to expose LLVM statistics. This resurrects PR https://github.com/rust-lang/rust/pull/104000, which has sat idle for a while. And I want to see the effect of stack-move optimizations on LLVM (like https://reviews.llvm.org/D153453) :). I have applied the changes requested by `@oli-obk` and `@nagisa` https://github.com/rust-lang/rust/pull/104000#discussion_r1014625377 and https://github.com/rust-lang/rust/pull/104000#discussion_r1014642482 in the latest commits. r? `@oli-obk` ----- LLVM has a neat [statistics](https://llvm.org/docs/ProgrammersManual.html#the-statistic-class-stats-option) feature that tracks how often optimizations kick in. It's very handy for optimization work. Since we expose the LLVM pass timings, I thought it made sense to expose the LLVM statistics too. ----- (Edit: fix broken link (Edit2: fix segmentation fault and use malloc If `rustc` is built with ```toml [llvm] assertions = true ``` Then you can see like ``` rustc +stage1 -Z print-codegen-stats -C opt-level=3 tmp.rs ===-------------------------------------------------------------------------=== ... Statistics Collected ... ===-------------------------------------------------------------------------=== 3 aa - Number of MayAlias results 193 aa - Number of MustAlias results 531 aa - Number of NoAlias results ... ``` And the current default build emits only ``` $ rustc +stage1 -Z print-codegen-stats -C opt-level=3 tmp.rs ===-------------------------------------------------------------------------=== ... Statistics Collected ... ===-------------------------------------------------------------------------=== $ ``` This might be better to emit the message to tell assertion flag necessity, but now I can't find how to do that...
2023-07-21Don't treat ref. fields with non-null niches as `dereferenceable_or_null`Moulins-1/+2
2023-07-20UPDATE - replace expected_simd error with one from codegen_ssaJhonny Bill Mena-42/+16
Here I am assuming we want to treat these parameters (input, first, second, third, return) as translatable
2023-07-19UPDATE - replace gcc monomorphization errors with ssa onesJhonny Bill Mena-280/+42
Reduces error duplication and makes it more consistent across backends
2023-07-18support for mips32r6 as a target_arch valuechenx97-0/+1
2023-07-18support for mips64r6 as a target_arch valuechenx97-0/+1
2023-07-17Introduce `MonoItemData`.Nicholas Nethercote-2/+2
It replaces `(Linkage, Visibility)`, making the code nicer. Plus the next commit will add another field.
2023-07-16rustc_llvm: Add a `-Z print-llvm-stats` option to expose LLVM statistics.Patrick Walton-0/+4
LLVM has a neat [statistics] feature that tracks how often optimizations kick in. It's very handy for optimization work. Since we expose the LLVM pass timings, I thought it made sense to expose the LLVM statistics too. [statistics]: https://llvm.org/docs/ProgrammersManual.html#the-statistic-class-stats-option
2023-07-14refactor(rustc_middle): Substs -> GenericArgMahdi Dibaiee-10/+10
2023-07-05Move `TyCtxt::mk_x` to `Ty::new_x` where applicableBoxy-6/+6
2023-07-05Remove trait `CoverageInfoMethods`, since non-LLVM backends don't need itZalathar-34/+1
These methods are only ever called from within `rustc_codegen_llvm`, so they can just be declared there as well.
2023-07-05Narrow trait `CoverageInfoBuilderMethods` down to just one methodZalathar-27/+2
This effectively inlines most of `FunctionCx::codegen_coverage` into the LLVM implementation of `CoverageInfoBuilderMethods`.
2023-06-22Auto merge of #112814 - antoyo:sync-cg_gcc-2023-06-19, r=bjorn3bors-265/+245
Sync rustc_codegen_gcc 2023/06/19 Hi. This is a sync of the rustc_codegen_gcc subtree. Thanks.
2023-06-19Rollup merge of #112499 - tgross35:py-ruff-fixes, r=Mark-SimulacrumMichael Goulet-2/+1
Fix python linting errors These were flagged by `ruff`, run using the config in https://github.com/rust-lang/rust/pull/112482
2023-06-19Update Cargo.lockAntoni Boucher-2/+2
2023-06-19Merge commit '1bbee3e217d75e7bc3bfe5d8c1b35e776fce96e6' into ↵Antoni Boucher-263/+243
sync-cg_gcc-2023-06-19
2023-06-17Auto merge of #100036 - DrMeepster:box_free_free_box, r=oli-obkbors-6/+2
Remove `box_free` lang item This PR removes the `box_free` lang item, replacing it with `Box`'s `Drop` impl. Box dropping is still slightly magic because the contained value is still dropped by the compiler.
2023-06-16Apply changes to fix python linting errorsTrevor Gross-2/+1
2023-06-16remove box_free and replace with drop implDrMeepster-6/+2
2023-06-10Support 128-bit enum variant in debuginfo codegenDonoughLiu-1/+5
2023-06-04Updated cranelift codegen to reflect modified trait signatureAndrew Xie-2/+2
2023-06-01Use translatable diagnostics in `rustc_const_eval`Deadbeef-13/+4
2023-05-31Add a distinct `OperandValue::ZeroSized` variant for ZSTsScott McMurray-3/+2
These tend to have special handling in a bunch of places anyway, so the variant helps remember that. And I think it's easier to grok than non-Scalar Aggregates sometimes being `Immediates` (like I got wrong and caused 109992). As a minor bonus, it means we don't need to generate poison LLVM values for them to pass around in `OperandValue::Immediate`s.
2023-05-30Auto merge of #111768 - oli-obk:pair_const_llvm, r=cjgillotbors-39/+20
Optimize scalar and scalar pair representations loaded from ByRef in llvm in https://github.com/rust-lang/rust/pull/105653 I noticed that we were generating suboptimal LLVM IR if we had a `ConstValue::ByRef` that could be represented by a `ScalarPair`. Before https://github.com/rust-lang/rust/pull/105653 this is probably rare, but after it, every slice will go down this suboptimal code path that requires LLVM to untangle a bunch of indirections and translate static allocations that are only used once to read a scalar pair from.
2023-05-26Stop creating intermediate places just to immediate convert them to operandsOli Scherer-39/+20