@@ -237,13 +237,33 @@ impl WriteBackendMethods for LlvmCodegenBackend {
237237 diff_fncs : Vec < AutoDiffItem > ,
238238 config : & ModuleConfig ,
239239 ) -> Result < ( ) , FatalError > {
240- if cgcx. lto != Lto :: Fat {
241- let dcx = cgcx. create_dcx ( ) ;
242- return Err ( dcx. handle ( ) . emit_almost_fatal ( AutoDiffWithoutLTO ) ) ;
243- }
240+ // if cgcx.lto != Lto::Fat {
241+ // let dcx = cgcx.create_dcx();
242+ // return Err(dcx.handle().emit_almost_fatal(AutoDiffWithoutLTO));
243+ // }
244244 let module_llvm = & module. module_llvm ;
245245 builder:: autodiff:: differentiate ( module_llvm, cgcx, diff_fncs, config)
246246 }
247+ fn autodiff_thin (
248+ cgcx : & CodegenContext < Self > ,
249+ thin_module : & ThinModule < Self > ,
250+ diff_fncs : Vec < AutoDiffItem > ,
251+ config : & ModuleConfig ,
252+ ) -> Result < ( ) , FatalError > {
253+ let dcx = cgcx. create_dcx ( ) ;
254+ let dcx = dcx. handle ( ) ;
255+
256+ let module_name = & thin_module. shared . module_names [ thin_module. idx ] ;
257+
258+ // Right now the implementation we've got only works over serialized
259+ // modules, so we create a fresh new LLVM context and parse the module
260+ // into that context. One day, however, we may do this for upstream
261+ // crates but for locally codegened modules we may be able to reuse
262+ // that LLVM Context and Module.
263+ let module_llvm = ModuleLlvm :: parse ( cgcx, module_name, thin_module. data ( ) , dcx) ?;
264+
265+ builder:: autodiff:: differentiate ( & module_llvm, cgcx, diff_fncs, config)
266+ }
247267}
248268
249269impl LlvmCodegenBackend {
0 commit comments