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