@@ -62,7 +62,7 @@ fn generate_enzyme_call<'ll>(
6262 // add outer_fn name to ad_name to make it unique, in case users apply autodiff to multiple
6363 // functions. Unwrap will only panic, if LLVM gave us an invalid string.
6464 let name = llvm:: get_value_name ( outer_fn) ;
65- let outer_fn_name = std:: ffi :: CStr :: from_bytes_with_nul ( name) . unwrap ( ) . to_str ( ) . unwrap ( ) ;
65+ let outer_fn_name = std:: str :: from_utf8 ( name) . unwrap ( ) ;
6666 ad_name. push_str ( outer_fn_name. to_string ( ) . as_str ( ) ) ;
6767
6868 // Let us assume the user wrote the following function square:
@@ -255,21 +255,29 @@ fn generate_enzyme_call<'ll>(
255255 // have no debug info to copy, which would then be ok.
256256 trace ! ( "no dbg info" ) ;
257257 }
258+ // Dump module:
259+ llvm:: LLVMDumpModule ( cx. llmod ) ;
260+ // now print the last instruction:
261+ llvm:: LLVMDumpValue ( last_inst) ;
262+
258263 // Now that we copied the metadata, get rid of dummy code.
259264 llvm:: LLVMRustEraseInstBefore ( entry, last_inst) ;
260- llvm:: LLVMRustEraseInstFromParent ( last_inst) ;
265+ dbg ! ( "cleaneup done" ) ;
266+ llvm:: LLVMDumpValue ( outer_fn) ;
261267
262268 if cx. val_ty ( outer_fn) != cx. type_void ( ) {
263269 builder. ret ( call) ;
264270 } else {
265271 builder. ret_void ( ) ;
266272 }
273+ dbg ! ( "build ret done" ) ;
267274
268275 // Let's crash in case that we messed something up above and generated invalid IR.
269276 llvm:: LLVMRustVerifyFunction (
270277 outer_fn,
271278 llvm:: LLVMRustVerifierFailureAction :: LLVMAbortProcessAction ,
272279 ) ;
280+ dbg ! ( "verification done" ) ;
273281 }
274282}
275283
@@ -308,33 +316,34 @@ pub(crate) fn differentiate<'ll>(
308316 } ;
309317
310318 generate_enzyme_call ( & cx, fn_def, fn_target, item. attrs . clone ( ) ) ;
319+ dbg ! ( "generated enzyme call" ) ;
311320 }
312321
313322 // FIXME(ZuseZ4): support SanitizeHWAddress and prevent illegal/unsupported opts
314323
315- if let Some ( opt_level) = config. opt_level {
316- let opt_stage = match cgcx. lto {
317- Lto :: Fat => llvm:: OptStage :: PreLinkFatLTO ,
318- Lto :: Thin | Lto :: ThinLocal => llvm:: OptStage :: PreLinkThinLTO ,
319- _ if cgcx. opts . cg . linker_plugin_lto . enabled ( ) => llvm:: OptStage :: PreLinkThinLTO ,
320- _ => llvm:: OptStage :: PreLinkNoLTO ,
321- } ;
322- // This is our second opt call, so now we run all opts,
323- // to make sure we get the best performance.
324- let skip_size_increasing_opts = false ;
325- trace ! ( "running Module Optimization after differentiation" ) ;
326- unsafe {
327- llvm_optimize (
328- cgcx,
329- diag_handler. handle ( ) ,
330- module,
331- config,
332- opt_level,
333- opt_stage,
334- skip_size_increasing_opts,
335- ) ?
336- } ;
337- }
324+ // if let Some(opt_level) = config.opt_level {
325+ // let opt_stage = match cgcx.lto {
326+ // Lto::Fat => llvm::OptStage::PreLinkFatLTO,
327+ // Lto::Thin | Lto::ThinLocal => llvm::OptStage::PreLinkThinLTO,
328+ // _ if cgcx.opts.cg.linker_plugin_lto.enabled() => llvm::OptStage::PreLinkThinLTO,
329+ // _ => llvm::OptStage::PreLinkNoLTO,
330+ // };
331+ // // This is our second opt call, so now we run all opts,
332+ // // to make sure we get the best performance.
333+ // let skip_size_increasing_opts = false;
334+ // trace!("running Module Optimization after differentiation");
335+ // unsafe {
336+ // llvm_optimize(
337+ // cgcx,
338+ // diag_handler.handle(),
339+ // module,
340+ // config,
341+ // opt_level,
342+ // opt_stage,
343+ // skip_size_increasing_opts,
344+ // )?
345+ // };
346+ // }
338347 trace ! ( "done with differentiate()" ) ;
339348
340349 Ok ( ( ) )
0 commit comments