@@ -1153,7 +1153,8 @@ fn codegen_enzyme_autodiff<'ll, 'tcx>(
11531153 ty:: FnDef ( def_id, source_params) => ( def_id, source_params) ,
11541154 _ => bug ! ( "invalid args" ) ,
11551155 } ;
1156- let fn_source = Instance :: new_raw ( * source_id, source_args) ;
1156+ let fn_source =
1157+ Instance :: try_resolve ( tcx, bx. cx . typing_env ( ) , * source_id, source_args) . unwrap ( ) . unwrap ( ) ;
11571158 let source_symbol = symbol_name_for_instance_in_crate ( tcx, fn_source. clone ( ) , LOCAL_CRATE ) ;
11581159 let fn_to_diff: Option < & ' ll llvm:: Value > = bx. cx . get_function ( & source_symbol) ;
11591160 let Some ( fn_to_diff) = fn_to_diff else { bug ! ( "could not find source function" ) } ;
@@ -1162,10 +1163,11 @@ fn codegen_enzyme_autodiff<'ll, 'tcx>(
11621163 ty:: FnDef ( def_id, diff_args) => ( def_id, diff_args) ,
11631164 _ => bug ! ( "invalid args" ) ,
11641165 } ;
1165- let fn_diff = Instance :: new_raw ( * diff_id, diff_args) ;
1166+ let fn_diff =
1167+ Instance :: try_resolve ( tcx, bx. cx . typing_env ( ) , * diff_id, diff_args) . unwrap ( ) . unwrap ( ) ;
11661168 let diff_symbol = symbol_name_for_instance_in_crate ( tcx, fn_diff. clone ( ) , LOCAL_CRATE ) ;
11671169
1168- let diff_attrs = autodiff_attrs ( tcx, * diff_id ) ;
1170+ let diff_attrs = autodiff_attrs ( tcx, fn_diff . def_id ( ) ) ;
11691171 let Some ( diff_attrs) = diff_attrs else { bug ! ( "could not find autodiff attrs" ) } ;
11701172
11711173 // Build body
0 commit comments