@@ -29,7 +29,7 @@ use crate::errors::{
29
29
DynamicLinkingWithLTO , LlvmError , LtoBitcodeFromRlib , LtoDisallowed , LtoDylib , LtoProcMacro ,
30
30
} ;
31
31
use crate :: llvm:: AttributePlace :: Function ;
32
- use crate :: llvm:: { self , build_string, get_value_name } ;
32
+ use crate :: llvm:: { self , build_string} ;
33
33
use crate :: { LlvmCodegenBackend , ModuleLlvm , SimpleCx , attributes} ;
34
34
35
35
/// We keep track of the computed LTO cache keys from the previous
@@ -669,23 +669,26 @@ pub(crate) fn run_pass_manager(
669
669
SimpleCx :: new ( module. module_llvm . llmod ( ) , & module. module_llvm . llcx , cgcx. pointer_size ) ;
670
670
671
671
for function in cx. get_functions ( ) {
672
- let name = get_value_name ( function ) ;
673
- let name = std :: str :: from_utf8 ( name ) . unwrap ( ) ;
672
+ let enzyme_marker = CString :: new ( "enzyme_marker" ) . unwrap ( ) ;
673
+ let marker_ptr = enzyme_marker . as_ptr ( ) ;
674
674
675
- if name. starts_with ( "__enzyme" ) {
676
- // Ensure `noinline` is present before replacing it.
677
- // This is not strictly necessary for correctness, but serves as a sanity check
678
- // in case the autodiff pass stops injecting `noinline` in the future.
675
+ if attributes:: has_string_attr ( function, marker_ptr) {
676
+ // Sanity check: Ensure 'noinline' is present before replacing it.
679
677
assert ! (
680
678
!attributes:: has_attr( function, Function , llvm:: AttributeKind :: NoInline ) ,
681
679
"Expected __enzyme function to have 'noinline' before adding 'alwaysinline'"
682
680
) ;
683
681
684
- // Removing inline from function.
685
682
attributes:: remove_from_llfn ( function, Function , llvm:: AttributeKind :: NoInline ) ;
683
+ attributes:: remove_string_attr_from_llfn ( function, marker_ptr) ;
686
684
687
- let attr = llvm:: AttributeKind :: AlwaysInline . create_attr ( cx. llcx ) ;
688
- attributes:: apply_to_llfn ( function, Function , & [ attr] ) ;
685
+ assert ! (
686
+ !attributes:: has_string_attr( function, marker_ptr) ,
687
+ "Expected function to not have 'enzyme_marker'"
688
+ ) ;
689
+
690
+ let always_inline = llvm:: AttributeKind :: AlwaysInline . create_attr ( cx. llcx ) ;
691
+ attributes:: apply_to_llfn ( function, Function , & [ always_inline] ) ;
689
692
}
690
693
}
691
694
0 commit comments