Skip to content

Commit c4857a0

Browse files
committed
Lowering draft
1 parent bca8b29 commit c4857a0

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
@@ -343,7 +343,7 @@ mod llvm_enzyme {
343343
ident: first_ident(&meta_item_vec[0]),
344344
generics,
345345
contract: None,
346-
body: None,
346+
body: None, // This leads to an error when the ad function is inside a traits
347347
define_opaque: None,
348348
});
349349
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
@@ -190,6 +190,21 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
190190
)
191191
}
192192
_ if tcx.has_attr(def_id, sym::rustc_autodiff) => {
193+
// NOTE(Sa4dUs): This is a hacky way to get the autodiff items
194+
// so we can focus on the lowering of the intrinsic call
195+
196+
// `diff_items` is empty even when autodiff is enabled, and if we're here,
197+
// it's because some function was marked as intrinsic and had the `rustc_autodiff` attr
198+
let diff_items = tcx.collect_and_partition_mono_items(()).autodiff_items;
199+
200+
// this shouldn't happen?
201+
if diff_items.is_empty() {
202+
bug!("no autodiff items found for {def_id:?}");
203+
}
204+
205+
// TODO(Sa4dUs): generate the enzyme call itself, based on the logic in `builder.rs`
206+
207+
// Just gen the fallback body for now
193208
return Err(ty::Instance::new_raw(def_id, instance.args));
194209
}
195210
sym::is_val_statically_known => {

0 commit comments

Comments
 (0)