about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
AgeCommit message (Collapse)AuthorLines
2025-08-28Revert "fix(debuginfo): disable overflow check for"Wesley Wiser-2/+2
This reverts commit 49eda8edd5c99e4c65c687fff0b8e194eb339a23.
2025-07-31remove rustc_attr_data_structuresJana Dönszelmann-3/+4
2025-07-31Rollup merge of #144663 - Zalathar:empty-span, r=petrochenkovStuart Cook-24/+4
coverage: Re-land "Enlarge empty spans during MIR instrumentation" This allows us to assume that coverage spans will only be discarded during codegen in very unusual situations. --- This seemingly-simple change has a rather messy history: - rust-lang/rust#140847 - rust-lang/rust#141650 - rust-lang/rust#144298 - rust-lang/rust#144480 Since then, a number of related changes have landed that should make it reasonable to try again: - rust-lang/rust#144530 - rust-lang/rust#144560 - rust-lang/rust#144616 In particular, we have multiple fixes/mitigations, and a confirmed regression test for the original bug that is not triggered by re-landing the changes in this PR.
2025-07-31Rollup merge of #144232 - xacrimon:explicit-tail-call, r=WaffleLapkinStuart Cook-1/+35
Implement support for `become` and explicit tail call codegen for the LLVM backend This PR implements codegen of explicit tail calls via `become` in `rustc_codegen_ssa` and support within the LLVM backend. Completes a task on (https://github.com/rust-lang/rust/issues/112788). This PR implements all the necessary bits to make explicit tail calls usable, other backends have received stubs for now and will ICE if you use `become` on them. I suspect there is some bikeshedding to be done on how we should go about implementing this for other backends, but it should be relatively straightforward for GCC after this is merged. During development I also put together a POC bytecode VM based on tail call dispatch to test these changes out and analyze the codegen to make sure it generates expected assembly. That is available [here](https://github.com/xacrimon/tcvm).
2025-07-30coverage: Re-land "Enlarge empty spans during MIR instrumentation"Zalathar-24/+4
This allows us to assume that coverage spans will only be discarded during codegen in very unusual situations.
2025-07-29Rollup merge of #144407 - godzie44:godzie44/fix_dwarf_inconsistency, ↵Stuart Cook-2/+2
r=wesleywiser fix(debuginfo): disable overflow check for recursive non-enum types Commit b10edb4 introduce an overflow check when generating debuginfo for expanding recursive types. While this check works correctly for enums, it can incorrectly prune valid debug information for structures. For example see rust-lang/rust#143241 (https://github.com/rust-lang/rust/issues/143241#issuecomment-3073721477). Furthermore, for structures such check does not make sense, since structures with recursively expanding types simply will not compile (there is a `hir_analysis_recursive_generic_parameter` for that). closes rust-lang/rust#143241
2025-07-28Rename impl_of_method -> impl_of_assocCameron Steffen-1/+1
2025-07-28Auto merge of #144562 - matthiaskrgr:rollup-mlvn7qo, r=matthiaskrgrbors-83/+37
Rollup of 7 pull requests Successful merges: - rust-lang/rust#144072 (update `Atomic*::from_ptr` and `Atomic*::as_ptr` docs) - rust-lang/rust#144151 (`tests/ui/issues/`: The Issues Strike Back [1/N]) - rust-lang/rust#144300 (Clippy fixes for miropt-test-tools) - rust-lang/rust#144399 (Add a ratchet for moving all standard library tests to separate packages) - rust-lang/rust#144472 (str: Mark unstable `round_char_boundary` feature functions as const) - rust-lang/rust#144503 (Various refactors to the codegen coordinator code (part 3)) - rust-lang/rust#144530 (coverage: Infer `instances_used` from `pgo_func_name_var_map`) r? `@ghost` `@rustbot` modify labels: rollup
2025-07-28Rollup merge of #144530 - Zalathar:instances-used, r=lqdMatthias Krüger-22/+28
coverage: Infer `instances_used` from `pgo_func_name_var_map` In obscure circumstances involving macro-expanded spans, we would sometimes emit a covfun record for a function with no physical coverage counters, and therefore no corresponding entry in the “PGO names” section of the binary. The absence of that name entry causes `llvm-cov` to fail with the cryptic error message: ```text malformed instrumentation profile data: function name is empty ``` We can eliminate this mismatch by removing `instances_used` entirely, and instead inferring its contents from the keys of `pgo_func_name_var_map`. This makes it impossible for a "used" function to lack a PGO name entry. --- This is an attempt to eliminate the cause of rust-lang/rust#141577 when re-landing changes like rust-lang/rust#144298 in the future. I haven't been able to reproduce the underlying issue in an in-tree test, because the only known repro involves a non-trivial derive proc-macro that relies on `syn` and `proc-macro2`. But I have manually verified in a separate branch that this change would have prevented the reoccurrence of https://github.com/rust-lang/rust/issues/141577#issuecomment-3120667286.
2025-07-28Rollup merge of #144503 - bjorn3:lto_refactors3, r=petrochenkovMatthias Krüger-61/+9
Various refactors to the codegen coordinator code (part 3) Continuing from https://github.com/rust-lang/rust/pull/144062 this removes an option without any known users, uses the object crate in favor of LLVM for getting the LTO bitcode and improves the coordinator channel handling.
2025-07-28Auto merge of #144469 - Kivooeo:chains-cleanup, r=SparrowLiibors-8/+8
Some `let chains` clean-up Not sure if this kind of clean-up is welcoming because of size, but I decided to try out one r? compiler
2025-07-28use let chains in ast, borrowck, codegen, const_evalKivooeo-8/+8
2025-07-27coverage: Clarify that getting a PGO name also makes a function "used"Zalathar-4/+7
2025-07-27coverage: Infer `instances_used` from `pgo_func_name_var_map`Zalathar-18/+21
In obscure circumstances, we would sometimes emit a covfun record for a function with no physical coverage counters, causing `llvm-cov` to fail with the cryptic error message: malformed instrumentation profile data: function name is empty We can eliminate this mismatch by removing `instances_used` entirely, and instead inferring its contents from the keys of `pgo_func_name_var_map`. This makes it impossible for a "used" function to lack a PGO name entry.
2025-07-27fix(debuginfo): disable overflow check forgodzie44-2/+2
recursive non-enum types
2025-07-27Rollup merge of #144455 - TDecking:ctlz-cttz, r=SparrowLiiMatthias Krüger-19/+9
Unify LLVM ctlz/cttz intrinsic generation The type signature for `llvm.ctlz` is the same as the one for `llvm.cttz`, which enables a small simplification.
2025-07-26Rollup merge of #144480 - Zalathar:revert-empty-span, r=ZalatharJacob Pratt-4/+24
Revert "coverage: Enlarge empty spans during MIR instrumentation, not codegen" Surprisingly, rust-lang/rust#144298 alone (extracted from rust-lang/rust#140847) was enough to re-trigger the failures observed in https://github.com/rust-lang/rust/issues/141577#issuecomment-3120667286. --- This reverts commit f877aa7d14916f71a2f88c6d4c009e7ded7684c4. --- r? ghost
2025-07-26Rollup merge of #144383 - ZuseZ4:disable-f128-on-amdgcn, r=oli-obkJacob Pratt-0/+2
disable cfg.has_reliable_f128 on amdgcn I was experimenting with compiling a few kernels for amd while working on std::offload. It seems like the logic in https://github.com/rust-lang/compiler-builtins/pull/737 got removed, so I re-introduce it here. Probably should have a test to avoid another regression and make sure that f128 doesn't show up as target feature for amdgcn. It looks like currently we neither check that for nvptx, nor amdgpu. Maybe I could add two revisions to https://github.com/rust-lang/rust/blob/master/tests/ui/float/target-has-reliable-nightly-float.rs? r? ````@Flakebi```` fixes: https://github.com/rust-lang/rust/issues/144381
2025-07-26Remove support for -Zcombine-cgubjorn3-30/+0
Nobody seems to actually use this, while still adding some extra complexity to the already rather complex codegen coordinator code. It is also not supported by any backend other than the LLVM backend.
2025-07-26Disable has_reliable_f128_math on musl targetsJens Reidel-0/+3
musl does not implement the symbols required by std for f128 maths. Disable the associated cfg for all musl targets and adjust the tests accordingly. Signed-off-by: Jens Reidel <adrian@travitia.xyz>
2025-07-26Revert "coverage: Enlarge empty spans during MIR instrumentation, not codegen"Zalathar-4/+24
This reverts commit f877aa7d14916f71a2f88c6d4c009e7ded7684c4.
2025-07-26Implement support for explicit tail calls in the MIR block builders and the ↵Joel Wejdenstål-1/+35
LLVM codegen backend.
2025-07-25Unify LLVM ctlz/cttz intrinsic generationTobias Decking-19/+9
2025-07-25Use the object crate rather than LLVM for extracting bitcode sectionsbjorn3-31/+9
2025-07-24Auto merge of #144062 - bjorn3:lto_refactors2, r=davidtwcobors-111/+37
Various refactors to the LTO handling code (part 2) Continuing from https://github.com/rust-lang/rust/pull/143388 this removes a bit of dead code and moves the LTO symbol export calculation from individual backends to cg_ssa.
2025-07-23disable cfg.has_reliable_f128 on amdgcnManuel Drehwald-0/+2
2025-07-22coverage: Enlarge empty spans during MIR instrumentation, not codegenZalathar-24/+4
This allows us to assume that coverage spans will only be discarded during codegen in very unusual situations.
2025-07-22Rollup merge of #142097 - ZuseZ4:offload-host1, r=oli-obk许杰友 Jieyou Xu (Joe)-11/+577
gpu offload host code generation r? ghost This will generate most of the host side code to use llvm's offload feature. The first PR will only handle automatic mem-transfers to and from the device. So if a user calls a kernel, we will copy inputs back and forth, but we won't do the actual kernel launch. Before merging, we will use LLVM's Info infrastructure to verify that the memcopies match what openmp offloa generates in C++. `LIBOMPTARGET_INFO=-1 ./my_rust_binary` should print that a memcpy to and later from the device is happening. A follow-up PR will generate the actual device-side kernel which will then do computations on the GPU. A third PR will implement manual host2device and device2host functionality, but the goal is to minimize cases where a user has to overwrite our default handling due to performance issues. I'm trying to get a full MVP out first, so this just recognizes GPU functions based on magic names. The final frontend will obviously move this over to use proper macros, like I'm already doing it for the autodiff work. This work will also be compatible with std::autodiff, so one can differentiate GPU kernels. Tracking: - https://github.com/rust-lang/rust/issues/131513
2025-07-21Remove each_linked_rlib_for_lto from CodegenContextbjorn3-6/+19
2025-07-21Move exported_symbols_for_lto out of CodegenContextbjorn3-6/+12
2025-07-21Merge exported_symbols computation into exported_symbols_for_ltobjorn3-6/+5
And move exported_symbols_for_lto call from backends to cg_ssa.
2025-07-21Move LTO symbol export calculation from backends to cg_ssabjorn3-94/+14
2025-07-21Merge modules and cached_modules for fat LTObjorn3-14/+2
The modules vec can already contain serialized modules and there is no need to distinguish between cached and non-cached cgus at LTO time.
2025-07-20Rollup merge of #144116 - nikic:llvm-21-fixes, r=dianqkMatthias Krüger-0/+12
Fixes for LLVM 21 This fixes compatibility issues with LLVM 21 without performing the actual upgrade. Split out from https://github.com/rust-lang/rust/pull/143684. This fixes three issues: * Updates the AMDGPU data layout for address space 8. * Makes emit-arity-indicator.rs a no_core test, so it doesn't fail on non-x86 hosts. * Explicitly sets the exception model for wasm, as this is no longer implied by `-wasm-enable-eh`.
2025-07-18gpu host code generationManuel Drehwald-7/+464
2025-07-18add various wrappers for gpu code generationManuel Drehwald-2/+103
2025-07-18add -Zoffload=Enable flag behind -Zunstable-options, to enable gpu (host) ↵Manuel Drehwald-0/+6
code generation
2025-07-18make more builder functions genericManuel Drehwald-2/+4
2025-07-18Pass wasm exception model to TargetOptionsNikita Popov-0/+7
This is no longer implied by -wasm-enable-eh.
2025-07-18Update AMDGPU data layoutNikita Popov-0/+5
2025-07-18Rollup merge of #143293 - folkertdev:naked-function-kcfi, r=compiler-errorsMatthias Krüger-4/+4
fix `-Zsanitizer=kcfi` on `#[naked]` functions fixes https://github.com/rust-lang/rust/issues/143266 With `-Zsanitizer=kcfi`, indirect calls happen via generated intermediate shim that forwards the call. The generated shim preserves the attributes of the original, including `#[unsafe(naked)]`. The shim is not a naked function though, and violates its invariants (like having a body that consists of a single `naked_asm!` call). My fix here is to match on the `InstanceKind`, and only use `codegen_naked_asm` when the instance is not a `ReifyShim`. That does beg the question whether there are other `InstanceKind`s that could come up. As far as I can tell the answer is no: calling via `dyn` seems to work find, and `#[track_caller]` is disallowed in combination with `#[naked]`. r? codegen ````@rustbot```` label +A-naked cc ````@maurer```` ````@rcvalle````
2025-07-17Rollup merge of #143388 - bjorn3:lto_refactors, r=compiler-errorsLeón Orell Valerian Liehr-47/+29
Various refactors to the LTO handling code In particular reducing the sharing of code paths between fat and thin-LTO and making the fat LTO implementation more self-contained. This also moves some autodiff handling out of cg_ssa into cg_llvm given that Enzyme only works with LLVM anyway and an implementation for another backend may do things entirely differently. This will also make it a bit easier to split LTO handling out of the coordinator thread main loop into a separate loop, which should reduce the complexity of the coordinator thread.
2025-07-16use `codegen_instance_attrs` where an instance is (easily) availableFolkert de Vries-4/+4
2025-07-16Rollup merge of #143920 - oli-obk:cg-llvm-safety, r=jieyouxuSamuel Tardieu-249/+216
Make more of codegen_llvm safe Best reviewed commit-by-commit.
2025-07-14Eliminate all direct uses of LLVMMDStringInContext2Oli Scherer-24/+21
2025-07-14Use context methods instead of directly calling FFIOli Scherer-25/+9
2025-07-14Merge `typeid_metadata` and `create_metadata`Oli Scherer-18/+17
2025-07-14Shrink some `unsafe` blocks in cg_llvmOli Scherer-139/+137
2025-07-14Avoid a bunch of unnecessary `unsafe` blocks in cg_llvmOli Scherer-65/+54
2025-07-12Port `#[omit_gdb_pretty_printer_section]` to the new attribute parsing ↵Jonathan Brouwer-3/+2
infrastructure Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>