Skip to content

Commit fc86dda

Browse files
committed
Lowering draft
1 parent dc56f2b commit fc86dda

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

compiler/rustc_builtin_macros/src/autodiff.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ mod llvm_enzyme {
344344
ident: first_ident(&meta_item_vec[0]),
345345
generics,
346346
contract: None,
347-
body: None,
347+
body: None, // This leads to an error when the ad function is inside a traits
348348
define_opaque: None,
349349
});
350350
let mut rustc_ad_attr =

compiler/rustc_codegen_llvm/src/intrinsic.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,21 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
188188
)
189189
}
190190
_ if tcx.has_attr(def_id, sym::rustc_autodiff) => {
191+
// NOTE(Sa4dUs): This is a hacky way to get the autodiff items
192+
// so we can focus on the lowering of the intrinsic call
193+
194+
// `diff_items` is empty even when autodiff is enabled, and if we're here,
195+
// it's because some function was marked as intrinsic and had the `rustc_autodiff` attr
196+
let diff_items = tcx.collect_and_partition_mono_items(()).autodiff_items;
197+
198+
// this shouldn't happen?
199+
if diff_items.is_empty() {
200+
bug!("no autodiff items found for {def_id:?}");
201+
}
202+
203+
// TODO(Sa4dUs): generate the enzyme call itself, based on the logic in `builder.rs`
204+
205+
// Just gen the fallback body for now
191206
return Err(ty::Instance::new_raw(def_id, instance.args));
192207
}
193208
sym::is_val_statically_known => {

0 commit comments

Comments
 (0)