about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-10-01 14:36:51 +0000
committerbors <bors@rust-lang.org>2025-10-01 14:36:51 +0000
commitd4ae855111df8c7ee255bea4c112e74b7d72cf45 (patch)
tree1061cf71bca8dcba2ac269aaa753d99f1fb12daa /compiler/rustc_codegen_llvm/src
parent1e1a39441bd11aba541a48ba714d939490fc7b85 (diff)
parentde20efd01e560f74649b95c1e48c8e5e21c82269 (diff)
downloadrust-d4ae855111df8c7ee255bea4c112e74b7d72cf45.tar.gz
rust-d4ae855111df8c7ee255bea4c112e74b7d72cf45.zip
Auto merge of #147220 - Zalathar:rollup-fubv0wy, r=Zalathar
Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#146918 (add regression test)
 - rust-lang/rust#146980 (simplify setup_constraining_predicates, and note it is potentially cubic)
 - rust-lang/rust#147170 (compiletest: Pass around `DirectiveLine` instead of bare strings)
 - rust-lang/rust#147180 (add tests)
 - rust-lang/rust#147188 (Remove usage of `compiletest-use-stage0-libtest` from CI)
 - rust-lang/rust#147189 (Replace `rustc_span::Span` with a stripped down version for librustdoc's highlighter)
 - rust-lang/rust#147199 (remove outdated comment in (inner) `InferCtxt`)
 - rust-lang/rust#147200 (Fix autodiff empty ret regression)
 - rust-lang/rust#147209 (Remove `no-remap-src-base` from tests)
 - rust-lang/rust#147213 (Fix broken STD build for ESP-IDF)
 - rust-lang/rust#147217 (Don't create a top-level `true` directory when running UI tests)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
-rw-r--r--compiler/rustc_codegen_llvm/src/builder/autodiff.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_llvm/src/builder/autodiff.rs b/compiler/rustc_codegen_llvm/src/builder/autodiff.rs
index c3485f56391..4a749642265 100644
--- a/compiler/rustc_codegen_llvm/src/builder/autodiff.rs
+++ b/compiler/rustc_codegen_llvm/src/builder/autodiff.rs
@@ -378,5 +378,12 @@ pub(crate) fn generate_enzyme_call<'ll, 'tcx>(
 
     let call = builder.call(enzyme_ty, None, None, ad_fn, &args, None, None);
 
-    builder.store_to_place(call, dest.val);
+    let fn_ret_ty = builder.cx.val_ty(call);
+    if fn_ret_ty != builder.cx.type_void() && fn_ret_ty != builder.cx.type_struct(&[], false) {
+        // If we return void or an empty struct, then our caller (due to how we generated it)
+        // does not expect a return value. As such, we have no pointer (or place) into which
+        // we could store our value, and would store into an undef, which would cause UB.
+        // As such, we just ignore the return value in those cases.
+        builder.store_to_place(call, dest.val);
+    }
 }