about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/builder
AgeCommit message (Collapse)AuthorLines
2025-09-30fix void and empty struct retManuel Drehwald-1/+8
2025-09-19Add TypeTree metadata attachment for autodiffKaran Janthe-0/+6
- Add F128 support to TypeTree Kind enum - Implement TypeTree FFI bindings and conversion functions - Add typetree.rs module for metadata attachment to LLVM functions - Integrate TypeTree generation with autodiff intrinsic pipeline - Support scalar types: f32, f64, integers, f16, f128 - Attach enzyme_type attributes as LLVM string metadata for Enzyme Signed-off-by: Karan Janthe <karanjanthe@gmail.com>
2025-09-18Auto merge of #142544 - Sa4dUs:prevent-abi-changes, r=ZuseZ4bors-2/+42
Prevent ABI changes affect EnzymeAD This PR handles ABI changes for autodiff input arguments to improve Enzyme compatibility. Fundamentally this adjusts activities when a function argument is lowered as an `ScalarPair`, so there's no mismatch between diff activities and args. Also removes activities corresponding to ZSTs. fixes: https://github.com/rust-lang/rust/issues/144025 r? `@ZuseZ4`
2025-09-17Check ZST via `PassMode`Marcelo Domínguez-3/+17
2025-09-17Support ZST argsMarcelo Domínguez-1/+10
2025-09-17doc and move single branch match to an if letMarcelo Domínguez-6/+6
2025-09-17Adjust autodiff actitivies for ScalarPairMarcelo Domínguez-0/+17
2025-09-05gpu offload: change suspicious map into filterMarijn Schouten-1/+1
2025-08-24Rename `llvm::Bool` aliases to standard const caseZalathar-2/+2
This avoids the need for `#![allow(non_upper_case_globals)]`.
2025-08-14Remove inlining for autodiff handlingMarcelo Domínguez-7/+1
2025-08-14Complete functionality and general cleanupMarcelo Domínguez-92/+86
2025-08-14Basic implementation of `autodiff` intrinsicMarcelo Domínguez-234/+68
2025-07-18gpu host code generationManuel Drehwald-0/+439
2025-07-17Rollup merge of #143388 - bjorn3:lto_refactors, r=compiler-errorsLeón Orell Valerian Liehr-2/+0
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-14Eliminate all direct uses of LLVMMDStringInContext2Oli Scherer-8/+8
2025-07-14Merge `typeid_metadata` and `create_metadata`Oli Scherer-8/+8
2025-07-10Make some "safe" llvm ops actually soundOli Scherer-1/+1
2025-07-03Remove unused config param from WriteBackendMethods::autodiffbjorn3-2/+0
2025-06-16add and use generic get_const_int functionManuel Drehwald-2/+2
2025-04-25add custom enzyme markers to target methodsbit-aloo-0/+5
2025-04-24Rollup merge of #139700 - EnzymeAD:autodiff-flags, r=oli-obkMatthias Krüger-1/+1
Autodiff flags Interestingly, it seems that some other projects have conflicts with exactly the same LLVM optimization passes as autodiff. At least `LLVMRustOptimize` has exactly the flags that we need to disable problematic opt passes. This PR enables us to compile code where users differentiate two identical functions in the same module. This has been especially common in test cases, but it's not impossible to encounter in the wild. It also enables two new flags for testing/debugging. I consider writing an MCP to upgrade PrintPasses to be a standalone -Z flag, since it is *not* the same as `-Z print-llvm-passes`, which IMHO gives less useful output. A discussion can be found here: [#t-compiler/llvm > Print llvm passes. @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/187780-t-compiler.2Fllvm/topic/Print.20llvm.20passes.2E/near/511533038) Finally, it improves `PrintModBefore` and `PrintModAfter`. They used to work reliable, but now we just schedule enzyme as part of an existing ModulePassManager (MPM). Since Enzyme is last in the MPM scheduling, PrintModBefore became very inaccurate. It used to print the input module, which we gave to the Enzyme and was great to create llvm-ir reproducer. However, lately the MPM would run the whole `default<O3>` pipeline, which heavily modifies the llvm module, before we pass it to Enzyme. That made it impossible to use the flag to create llvm-ir reproducers for Enzyme bugs. We now schedule a PrintModule pass just before Enzyme, solving this problem. Based on the PrintPass output, it also _seems_ like changing `registerEnzymeAndPassPipeline(PB, true);` to `registerEnzymeAndPassPipeline(PB, false);` has no effect. In theory, the bool should tell Enzyme to schedule some helpful passes in the PassBuilder. However, since it doesn't do anything and I'm not 100% sure anymore on whether we really need it, I'll just disable it for now and postpone investigations. r? ``@oli-obk`` closes #139471 Tracking: - https://github.com/rust-lang/rust/issues/124509
2025-04-16working dupv and dupvonly for fwd modeManuel Drehwald-5/+33
2025-04-12update documentationManuel Drehwald-1/+1
2025-04-07handle sret for scalar autodiffManuel Drehwald-2/+22
2025-04-04add autodiff batching backendManuel Drehwald-39/+160
2025-03-17[NFC] simplify matchingManuel Drehwald-12/+3
2025-03-17[NFC] extract autodiff call lowering in cg_llvm into own functionManuel Drehwald-93/+108
2025-02-24Remove inherent function that has a trait method duplicate of a commonly ↵Oli Scherer-0/+1
imported trait
2025-02-24Generalize BaseTypeCodegenMethodsOli Scherer-1/+2
2025-02-24Avoid some duplication between SimpleCx and CodegenCxOli Scherer-1/+1
2025-02-21update autodiff flagsManuel Drehwald-4/+9
2025-02-10Rollup merge of #136419 - EnzymeAD:autodiff-tests, r=onur-ozkan,jieyouxuMatthias Krüger-32/+14
adding autodiff tests I'd like to get started with upstreaming some tests, even though I'm still waiting for an answer on how to best integrate the enzyme pass. Can we therefore temporarily support the -Z llvm-plugins here without too much effort? And in that case, how would that work? I saw you can do remapping, e.g. `rust-src-base`, but I don't think that will give me the path to libEnzyme.so. Do you have another suggestion? Other than that this test simply checks that the derivative of `x*x` is `2.0 * x`, which in this case is computed as `%0 = fadd fast double %x.0.val, %x.0.val` (I'll add a few more tests and move it to an autodiff folder if we can use the -Z flag) r? ``@jieyouxu`` Locally at least `-Zllvm-plugins=${PWD}/build/x86_64-unknown-linux-gnu/enzyme/build/Enzyme/libEnzyme-19.so` seems to work if I copy the command I get from x.py test and run it manually. However, running x.py test itself fails. Tracking: - https://github.com/rust-lang/rust/issues/124509 Zulip discussion: https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Enzyme.20build.20changes
2025-02-10remove outdated *First autodiff variants for higher-order adManuel Drehwald-2/+0
2025-02-10move second opt run to lto phase and cleanup codeManuel Drehwald-28/+7
2025-02-08Rustfmtbjorn3-10/+16
2025-02-05fix fwd-mode autodiff caseManuel Drehwald-3/+8
2025-01-29upstream rustc_codegen_ssa/rustc_middle changes for enzyme/autodiffManuel Drehwald-7/+7
2025-01-24Make CodegenCx and Builder genericManuel Drehwald-14/+11
Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
2025-01-01upstream rustc_codegen_llvm changes for enzyme/autodiffManuel Drehwald-0/+344