@@ -1151,7 +1151,8 @@ fn codegen_enzyme_autodiff<'ll, 'tcx>(
11511151 ty:: FnDef ( def_id, source_params) => ( def_id, source_params) ,
11521152 _ => bug ! ( "invalid args" ) ,
11531153 } ;
1154- let fn_source = Instance :: new_raw ( * source_id, source_args) ;
1154+ let fn_source =
1155+ Instance :: try_resolve ( tcx, bx. cx . typing_env ( ) , * source_id, source_args) . unwrap ( ) . unwrap ( ) ;
11551156 let source_symbol = symbol_name_for_instance_in_crate ( tcx, fn_source. clone ( ) , LOCAL_CRATE ) ;
11561157 let fn_to_diff: Option < & ' ll llvm:: Value > = bx. cx . get_function ( & source_symbol) ;
11571158 let Some ( fn_to_diff) = fn_to_diff else { bug ! ( "could not find source function" ) } ;
@@ -1160,10 +1161,11 @@ fn codegen_enzyme_autodiff<'ll, 'tcx>(
11601161 ty:: FnDef ( def_id, diff_args) => ( def_id, diff_args) ,
11611162 _ => bug ! ( "invalid args" ) ,
11621163 } ;
1163- let fn_diff = Instance :: new_raw ( * diff_id, diff_args) ;
1164+ let fn_diff =
1165+ Instance :: try_resolve ( tcx, bx. cx . typing_env ( ) , * diff_id, diff_args) . unwrap ( ) . unwrap ( ) ;
11641166 let diff_symbol = symbol_name_for_instance_in_crate ( tcx, fn_diff. clone ( ) , LOCAL_CRATE ) ;
11651167
1166- let diff_attrs = autodiff_attrs ( tcx, * diff_id ) ;
1168+ let diff_attrs = autodiff_attrs ( tcx, fn_diff . def_id ( ) ) ;
11671169 let Some ( diff_attrs) = diff_attrs else { bug ! ( "could not find autodiff attrs" ) } ;
11681170
11691171 // Build body
0 commit comments