@@ -28,8 +28,9 @@ use crate::back::write::{
28
28
use crate :: errors:: {
29
29
DynamicLinkingWithLTO , LlvmError , LtoBitcodeFromRlib , LtoDisallowed , LtoDylib , LtoProcMacro ,
30
30
} ;
31
- use crate :: llvm:: { self , build_string} ;
32
- use crate :: { LlvmCodegenBackend , ModuleLlvm } ;
31
+ use crate :: llvm:: AttributePlace :: Function ;
32
+ use crate :: llvm:: { self , build_string, get_value_name} ;
33
+ use crate :: { LlvmCodegenBackend , ModuleLlvm , SimpleCx , attributes} ;
33
34
34
35
/// We keep track of the computed LTO cache keys from the previous
35
36
/// session to determine which CGUs we can reuse.
@@ -664,6 +665,19 @@ pub(crate) fn run_pass_manager(
664
665
unsafe { llvm:: LLVMDumpModule ( module. module_llvm . llmod ( ) ) } ;
665
666
}
666
667
668
+ let cx =
669
+ SimpleCx :: new ( module. module_llvm . llmod ( ) , & module. module_llvm . llcx , cgcx. pointer_size ) ;
670
+
671
+ for function in cx. get_functions ( ) {
672
+ let name = get_value_name ( function) ;
673
+ let name = std:: str:: from_utf8 ( name) . unwrap ( ) ;
674
+
675
+ if name. starts_with ( "__enzyme" ) {
676
+ let attr = llvm:: AttributeKind :: AlwaysInline . create_attr ( cx. llcx ) ;
677
+ attributes:: apply_to_llfn ( function, Function , & [ attr] ) ;
678
+ }
679
+ }
680
+
667
681
let opt_stage = llvm:: OptStage :: FatLTO ;
668
682
let stage = write:: AutodiffStage :: PostAD ;
669
683
unsafe {
0 commit comments