@@ -1151,7 +1151,8 @@ fn codegen_enzyme_autodiff<'ll, 'tcx>(
1151
1151
ty:: FnDef ( def_id, source_params) => ( def_id, source_params) ,
1152
1152
_ => bug ! ( "invalid args" ) ,
1153
1153
} ;
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 ( ) ;
1155
1156
let source_symbol = symbol_name_for_instance_in_crate ( tcx, fn_source. clone ( ) , LOCAL_CRATE ) ;
1156
1157
let fn_to_diff: Option < & ' ll llvm:: Value > = bx. cx . get_function ( & source_symbol) ;
1157
1158
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>(
1160
1161
ty:: FnDef ( def_id, diff_args) => ( def_id, diff_args) ,
1161
1162
_ => bug ! ( "invalid args" ) ,
1162
1163
} ;
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 ( ) ;
1164
1166
let diff_symbol = symbol_name_for_instance_in_crate ( tcx, fn_diff. clone ( ) , LOCAL_CRATE ) ;
1165
1167
1166
- let diff_attrs = autodiff_attrs ( tcx, * diff_id ) ;
1168
+ let diff_attrs = autodiff_attrs ( tcx, fn_diff . def_id ( ) ) ;
1167
1169
let Some ( diff_attrs) = diff_attrs else { bug ! ( "could not find autodiff attrs" ) } ;
1168
1170
1169
1171
// Build body
0 commit comments