Skip to content

Commit 6cbf9cc

Browse files
committed
Lowering draft
1 parent b023611 commit 6cbf9cc

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
@@ -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)