@@ -62,7 +62,7 @@ fn generate_enzyme_call<'ll>(
62
62
// add outer_fn name to ad_name to make it unique, in case users apply autodiff to multiple
63
63
// functions. Unwrap will only panic, if LLVM gave us an invalid string.
64
64
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 ( ) ;
66
66
ad_name. push_str ( outer_fn_name. to_string ( ) . as_str ( ) ) ;
67
67
68
68
// Let us assume the user wrote the following function square:
@@ -255,21 +255,29 @@ fn generate_enzyme_call<'ll>(
255
255
// have no debug info to copy, which would then be ok.
256
256
trace ! ( "no dbg info" ) ;
257
257
}
258
+ // Dump module:
259
+ llvm:: LLVMDumpModule ( cx. llmod ) ;
260
+ // now print the last instruction:
261
+ llvm:: LLVMDumpValue ( last_inst) ;
262
+
258
263
// Now that we copied the metadata, get rid of dummy code.
259
264
llvm:: LLVMRustEraseInstBefore ( entry, last_inst) ;
260
- llvm:: LLVMRustEraseInstFromParent ( last_inst) ;
265
+ dbg ! ( "cleaneup done" ) ;
266
+ llvm:: LLVMDumpValue ( outer_fn) ;
261
267
262
268
if cx. val_ty ( outer_fn) != cx. type_void ( ) {
263
269
builder. ret ( call) ;
264
270
} else {
265
271
builder. ret_void ( ) ;
266
272
}
273
+ dbg ! ( "build ret done" ) ;
267
274
268
275
// Let's crash in case that we messed something up above and generated invalid IR.
269
276
llvm:: LLVMRustVerifyFunction (
270
277
outer_fn,
271
278
llvm:: LLVMRustVerifierFailureAction :: LLVMAbortProcessAction ,
272
279
) ;
280
+ dbg ! ( "verification done" ) ;
273
281
}
274
282
}
275
283
@@ -308,33 +316,34 @@ pub(crate) fn differentiate<'ll>(
308
316
} ;
309
317
310
318
generate_enzyme_call ( & cx, fn_def, fn_target, item. attrs . clone ( ) ) ;
319
+ dbg ! ( "generated enzyme call" ) ;
311
320
}
312
321
313
322
// FIXME(ZuseZ4): support SanitizeHWAddress and prevent illegal/unsupported opts
314
323
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
+ // }
338
347
trace ! ( "done with differentiate()" ) ;
339
348
340
349
Ok ( ( ) )
0 commit comments