about summary refs log tree commit diff
path: root/compiler/rustc_llvm
AgeCommit message (Collapse)AuthorLines
2025-08-28Add `libc` to `[workspace.dependencies]`.Nicholas Nethercote-1/+1
2025-08-28Auto merge of #145877 - nikic:capture-address, r=tmiaskobors-10/+5
Use captures(address) instead of captures(none) for indirect args While provenance cannot be captured through these arguments, the address / object identity can. Fixes https://github.com/rust-lang/rust/issues/137668. r? `@ghost`
2025-08-26Use captures(address) instead of captures(none) for indirect argsNikita Popov-10/+5
While provenance cannot be captured through these arguments, the address / object identity can.
2025-08-26Assert that LLVM range-attribute values don't exceed 128 bitsZalathar-0/+3
The underlying implementation of `LLVMCreateConstantRangeAttribute` assumes that each of `LowerWords` and `UpperWords` points to enough u64 values to define an integer of the specified bit-length, and will encounter UB if that is not the case. Our safe wrapper function always passes pointers to `[u64; 2]` arrays, regardless of the bit-length specified. That's fine in practice, because scalar primitives never exceed 128 bits, but it is technically a soundness hole in a safe function. We can close the soundness hole by explicitly asserting `size_bits <= 128`. This is effectively just a stricter version of the existing check that the value must be small enough to fit in `c_uint`.
2025-08-20Tell LLVM about read-only capturesNikita Popov-0/+8
`&Freeze` parameters are not only `readonly` within the function, but any captures of the pointer can also only be used for reads. This can now be encoded using the `captures(address, read_provenance)` attribute.
2025-08-19Rollup merge of #145484 - Zalathar:archive-builder, r=bjorn3Stuart Cook-209/+0
Remove `LlvmArchiveBuilder` and supporting code/bindings Switching over to the newer Rust-based `ArArchiveBuilder` happened in rust-lang/rust#128936, a year ago. Per the comment in `new_archive_builder`, that seems like enough time to justify removing the older, unused `LlvmArchiveBuilder` implementation and its associated bindings. Fixes rust-lang/rust#128955.
2025-08-16Remove `LlvmArchiveBuilder` and supporting code/bindingsZalathar-209/+0
2025-08-15Use `LLVMGetTypeKind`Zalathar-54/+0
2025-08-15Use `LLVMSetTailCallKind`Zalathar-26/+0
2025-08-13Auto merge of #145093 - nikic:dead-on-return, r=nnethercotebors-0/+7
Set dead_on_return attribute for indirect arguments Set the dead_on_return attribute (added in LLVM 21) for arguments that are passed indirectly, but not byval. This indicates that the value of the argument on return does not matter, enabling additional dead store elimination. From LangRef: > This attribute indicates that the memory pointed to by the argument is dead upon function return, both upon normal return and if the calls unwinds, meaning that the caller will not depend on its contents. Stores that would be observable either on the return path or on the unwind path may be elided. > > Specifically, the behavior is as-if any memory written through the pointer during the execution of the function is overwritten with a poison value upon function return. The caller may access the memory, but any load not preceded by a store will return poison. > > This attribute does not imply aliasing properties. For pointer arguments that do not alias other memory locations, noalias attribute may be used in conjunction. Conversely, this attribute always implies dead_on_unwind. > > This attribute cannot be applied to return values. This fixes parts of https://github.com/rust-lang/rust/issues/96497.
2025-08-11Set dead_on_return attribute for indirect argumentsNikita Popov-0/+7
Set the dead_on_return attribute (added in LLVM 21) for arguments that are passed indirectly, but not byval. This indicates that the value of the argument on return does not matter, enabling additional dead store elimination.
2025-08-10Fix typo with paren rustc_llvm/build.rsDaniel Paoliello-1/+1
2025-08-08Auto merge of #145077 - Zalathar:rollup-0k4194x, r=Zalatharbors-62/+3
Rollup of 19 pull requests Successful merges: - rust-lang/rust#144400 (`tests/ui/issues/`: The Issues Strike Back [3/N]) - rust-lang/rust#144764 ([codegen] assume the tag, not the relative discriminant) - rust-lang/rust#144807 (Streamline config in bootstrap) - rust-lang/rust#144899 (Print CGU reuse statistics in `-Zprint-mono-items`) - rust-lang/rust#144909 (Add new `test::print_merged_doctests_times` used by rustdoc to display more detailed time information) - rust-lang/rust#144912 (Resolver: introduce a conditionally mutable Resolver for (non-)speculative resolution.) - rust-lang/rust#144914 (Add support for `ty::Instance` path shortening in diagnostics) - rust-lang/rust#144931 ([win][arm64ec] Fix msvc-wholearchive for Arm64EC) - rust-lang/rust#144999 (coverage: Remove all unstable support for MC/DC instrumentation) - rust-lang/rust#145009 (A couple small changes for rust-analyzer next-solver work) - rust-lang/rust#145030 (GVN: Do not flatten derefs with ProjectionElem::Index. ) - rust-lang/rust#145042 (stdarch subtree update) - rust-lang/rust#145047 (move `type_check` out of `compute_regions`) - rust-lang/rust#145051 (Prevent name collisions with internal implementation details) - rust-lang/rust#145053 (Add a lot of NLL `known-bug` tests) - rust-lang/rust#145055 (Move metadata symbol export from exported_non_generic_symbols to exported_symbols) - rust-lang/rust#145057 (Clean up some resolved test regressions of const trait removals in std) - rust-lang/rust#145068 (Readd myself to review queue) - rust-lang/rust#145070 (Add minimal `armv7a-vex-v5` tier three target) r? `@ghost` `@rustbot` modify labels: rollup
2025-08-07Auto merge of #143807 - rperier:rustc_llvm_werror, r=cuviperbors-0/+10
Pass -Werror when building the LLVM wrapper cc rust-lang/rust#109712
2025-08-07Pass -Werror when building the LLVM wrapperRomain Perier-0/+10
Enabling warning_into_errors() only whether it's in rust-lang/rust CI, so deprecated uses of LLVM methods can be treated as errors.
2025-08-06coverage: Remove all unstable support for MC/DC instrumentationZalathar-62/+3
2025-07-31Rollup merge of #144712 - nnethercote:dedup-num-types, r=fmeaseJana Dönszelmann-0/+2
Deduplicate `IntTy`/`UintTy`/`FloatTy`. There are identical definitions in `rustc_type_ir` and `rustc_ast`. This commit removes them and places a single definition in `rustc_ast_ir`. This requires adding `rust_span` as a dependency of `rustc_ast_ir`, but means a bunch of silly conversion functions can be removed. r? `@fmease`
2025-07-31Tidy up `Cargo.toml` files.Nicholas Nethercote-0/+2
- Add some missing `tidy-alphabetical-*` markers. - Remove some unnecessary blank lines.
2025-07-31Rollup merge of #144232 - xacrimon:explicit-tail-call, r=WaffleLapkinStuart Cook-0/+26
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-29cc dependencies: clarify commentRalf Jung-2/+2
2025-07-28Rollup merge of #144503 - bjorn3:lto_refactors3, r=petrochenkovMatthias Krüger-34/+0
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-26Implement support for explicit tail calls in the MIR block builders and the ↵Joel Wejdenstål-0/+26
LLVM codegen backend.
2025-07-25Use the object crate rather than LLVM for extracting bitcode sectionsbjorn3-34/+0
2025-07-23RustWrapper: Suppress getNextNonDebugInfoInstructionWANG Rui-1/+1
Link: https://github.com/llvm/llvm-project/pull/144383
2025-07-22Rollup merge of #142097 - ZuseZ4:offload-host1, r=oli-obk许杰友 Jieyou Xu (Joe)-0/+37
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-20Rollup merge of #144116 - nikic:llvm-21-fixes, r=dianqkMatthias Krüger-1/+4
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-19Rollup merge of #142444 - KMJ-007:autodiff-codegen-test, r=ZuseZ4Matthias Krüger-0/+13
adding run-make test to autodiff r? `@ZuseZ4`
2025-07-18add various wrappers for gpu code generationManuel Drehwald-0/+37
2025-07-18Pass wasm exception model to TargetOptionsNikita Popov-1/+4
This is no longer implied by -wasm-enable-eh.
2025-07-11Avoid building C++ for rustc_llvm with --compile-time-depsbjorn3-0/+8
This saves about 30s.
2025-07-02awhile -> a while where appropriateнаб-1/+1
2025-07-02fix: Fix TypePrintFn flag passing for autodiff codegenKaran Janthe-0/+13
Signed-off-by: Karan Janthe <karanjanthe@gmail.com>
2025-05-31rustc_llvm: add Windows system libs only when cross-compiling from WindowsMateusz Mikuła-2/+2
This obviously doesn't work when cross-compiling from Linux. Split out from: https://github.com/rust-lang/rust/pull/140772
2025-05-15Experimental cygwin support in rustc王宇逸-0/+1
Co-authored-by: Ookiineko <chiisaineko@protonmail.com>
2025-05-11Use `LLVMGetInlineAsm`Zalathar-27/+0
This LLVM-C binding replaces the existing `LLVMRustInlineAsm` function.
2025-05-01PassWrapper: adapt for ↵Erick Tryzelaar-0/+5
llvm/llvm-project@f137c3d592e96330e450a8fd63ef7e8877fc1908 In LLVM 21 PR https://github.com/llvm/llvm-project/pull/130940 `TargetRegistry::createTargetMachine` was changed to take a `const Triple&` and has deprecated the old `StringRef` method. @rustbot label llvm-main
2025-04-29Rollup merge of #140400 - durin42:llvm-21-getguid, r=cuviperTrevor Gross-4/+9
PassWrapper: adapt for llvm/llvm-project@d3d856ad8469 LLVM 21 moves to making it more explicit what this function call is doing, but nothing has changed behaviorally, so for now we just adjust to using the new name of the function. `@rustbot` label llvm-main
2025-04-28Rollup merge of #139308 - Shourya742:2025-03-29-add-autodiff-inline, r=ZuseZ4Chris Denton-0/+21
add autodiff inline closes: #138920 r? ```@ZuseZ4``` try-job: dist-aarch64-linux
2025-04-28PassWrapper: adapt for llvm/llvm-project@d3d856ad8469Augie Fackler-4/+9
LLVM 21 moves to making it more explicit what this function call is doing, but nothing has changed behaviorally, so for now we just adjust to using the new name of the function. @rustbot label llvm-main
2025-04-28remove noinline attribute and add alwaysinline after AD passbit-aloo-4/+6
2025-04-26Rollup merge of #140253 - SergioGasquez:feat/xtensa-asm-printer, r=cuviperMatthias Krüger-0/+1
Add XtensaAsmPrinter See https://github.com/rust-lang/rust/pull/133601. The PR was closed because it required LLVM 19 in CI added with (https://github.com/rust-lang/rust/commit/12167d7064597993355e41d3a8c20654bccaf0be)
2025-04-25add llvm wrappers and corresponding methods in attributebit-aloo-0/+19
2025-04-24feat: Add XtensaAsmPrinterSergio Gasquez-0/+1
2025-04-12fix LooseTypes flag and PrintMod behaviour, add debug helperManuel Drehwald-2/+28
2025-04-05Update the minimum external LLVM to 19Josh Stone-129/+14
2025-04-05Rollup merge of #137880 - EnzymeAD:autodiff-batching, r=oli-obkStuart Cook-0/+10
Autodiff batching Enzyme supports batching, which is especially known from the ML side when training neural networks. There we would normally have a training loop, where in each iteration we would pass in some data (e.g. an image), and a target vector. Based on how close we are with our prediction we compute our loss, and then use backpropagation to compute the gradients and update our weights. That's quite inefficient, so what you normally do is passing in a batch of 8/16/.. images and targets, and compute the gradients for those all at once, allowing better optimizations. Enzyme supports batching in two ways, the first one (which I implemented here) just accepts a Batch size, and then each Dual/Duplicated argument has not one, but N shadow arguments. So instead of ```rs for i in 0..100 { df(x[i], y[i], 1234); } ``` You can now do ```rs for i in 0..100.step_by(4) { df(x[i+0],x[i+1],x[i+2],x[i+3], y[i+0], y[i+1], y[i+2], y[i+3], 1234); } ``` which will give the same results, but allows better compiler optimizations. See the testcase for details. There is a second variant, where we can mark certain arguments and instead of having to pass in N shadow arguments, Enzyme assumes that the argument is N times longer. I.e. instead of accepting 4 slices with 12 floats each, we would accept one slice with 48 floats. I'll implement this over the next days. I will also add more tests for both modes. For any one preferring some more interactive explanation, here's a video of Tim's llvm dev talk, where he presents his work. https://www.youtube.com/watch?v=edvaLAL5RqU I'll also add some other docs to the dev guide and user docs in another PR. r? ghost Tracking: - https://github.com/rust-lang/rust/issues/124509 - https://github.com/rust-lang/rust/issues/135283
2025-04-04add autodiff batching backendManuel Drehwald-0/+10
2025-03-31PassWrapper: adapt for ↵Augie Fackler-4/+9
llvm/llvm-project@94122d58fc77079a291a3d008914006cb509d9db We also have to remove the LLVM argument in cast-target-abi.rs for LLVM 21. I'm not really sure what the best approach here is since that test already uses revisions. We could also fork the test into a copy for LLVM 19-20 and another for LLVM 21, but what I did for now was drop the lint-abort-on-error flag to LLVM figuring that some coverage was better than none, but I'm happy to change this if that was a bad direction. The above also applies for ffi-out-of-bounds-loads.rs. r? dianqk @rustbot label llvm-main
2025-03-20coverage: Add LLVM plumbing for expansion regionsZalathar-0/+16
This is currently unused, but paves the way for future work on expansion regions without having to worry about the FFI parts.
2025-03-16Auto merge of #137011 - LuuuXXX:promote-ohos-with-host-tools, r=Amanieubors-1/+2
Promote ohos targets to tier2 with host tools. ### What does this PR try to resolve? Try to promote the following [[Tier 2 without Host Tools](https://doc.rust-lang.org/rustc/platform-support.html#tier-2-without-host-tools)](https://doc.rust-lang.org/rustc/platform-support.html#tier-2-without-host-tools) targets to [[Tier 2 with Host Tools](https://doc.rust-lang.org/rustc/platform-support.html#tier-2-with-host-tools)](https://doc.rust-lang.org/rustc/platform-support.html#tier-2-with-host-tools): - `aarch64-unknown-linux-ohos` - `armv7-unknown-linux-ohos` - `x86_64-unknown-linux-ohos` ### More Information? see MCP: https://github.com/rust-lang/compiler-team/issues/811 ### Blockage to be solved? - [x] Submit an MCP - [x] Submit code of promote ohos targets - [x] Resolve related dependencies (`measureme`) The modified code of the measureme has been merged (see https://github.com/rust-lang/measureme/pull/238). [done] The new version will was released (https://github.com/rust-lang/measureme/pull/240). [done]