Skip to content

Commit 00e5297

Browse files
authored
Smaller attr (#2605)
* Smaller attr * and a few more
1 parent 7a01369 commit 00e5297

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed

src/compiler.jl

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,10 @@ end
648648
StringAttribute("enzyme_inactive"),
649649
EnumAttribute("readnone"),
650650
EnumAttribute("speculatable"),
651+
EnumAttribute("willreturn"),
652+
EnumAttribute("nosync"),
653+
EnumAttribute("nofree"),
654+
EnumAttribute("nounwind"),
651655
StringAttribute("enzyme_shouldrecompute"),
652656
],
653657
)
@@ -662,6 +666,10 @@ end
662666
StringAttribute("enzyme_inactive"),
663667
EnumAttribute("memory", NoEffects.data),
664668
EnumAttribute("speculatable"),
669+
EnumAttribute("willreturn"),
670+
EnumAttribute("nosync"),
671+
EnumAttribute("nofree"),
672+
EnumAttribute("nounwind"),
665673
StringAttribute("enzyme_shouldrecompute"),
666674
],
667675
)
@@ -680,6 +688,9 @@ end
680688
EnumAttribute("readonly"),
681689
EnumAttribute("inaccessiblememonly", 0),
682690
EnumAttribute("speculatable", 0),
691+
EnumAttribute("willreturn"),
692+
EnumAttribute("nosync"),
693+
EnumAttribute("nofree"),
683694
StringAttribute("enzyme_shouldrecompute"),
684695
StringAttribute("enzyme_inactive"),
685696
],
@@ -700,6 +711,9 @@ end
700711
(MRI_NoModRef << getLocationPos(Other)),
701712
).data,
702713
),
714+
EnumAttribute("willreturn"),
715+
EnumAttribute("nosync"),
716+
EnumAttribute("nofree"),
703717
EnumAttribute("inaccessiblememonly", 0),
704718
EnumAttribute("speculatable", 0),
705719
StringAttribute("enzyme_shouldrecompute"),
@@ -722,6 +736,8 @@ end
722736
StringAttribute("enzyme_shouldrecompute"),
723737
StringAttribute("enzyme_inactive"),
724738
StringAttribute("enzyme_no_escaping_allocation"),
739+
EnumAttribute("willreturn"),
740+
EnumAttribute("nosync"),
725741
EnumAttribute("nofree"),
726742
StringAttribute("enzyme_ta_norecur"),
727743
],
@@ -740,6 +756,8 @@ end
740756
StringAttribute("enzyme_shouldrecompute"),
741757
StringAttribute("enzyme_inactive"),
742758
StringAttribute("enzyme_no_escaping_allocation"),
759+
EnumAttribute("willreturn"),
760+
EnumAttribute("nosync"),
743761
EnumAttribute("nofree"),
744762
StringAttribute("enzyme_ta_norecur"),
745763
],
@@ -762,6 +780,10 @@ end
762780
EnumAttribute("readonly"),
763781
EnumAttribute("inaccessiblememonly"),
764782
EnumAttribute("speculatable"),
783+
EnumAttribute("willreturn"),
784+
EnumAttribute("nosync"),
785+
EnumAttribute("nofree"),
786+
EnumAttribute("nounwind"),
765787
StringAttribute("enzyme_shouldrecompute"),
766788
StringAttribute("enzyme_inactive"),
767789
StringAttribute("enzyme_no_escaping_allocation"),
@@ -784,6 +806,10 @@ end
784806
).data,
785807
),
786808
EnumAttribute("speculatable"),
809+
EnumAttribute("willreturn"),
810+
EnumAttribute("nosync"),
811+
EnumAttribute("nofree"),
812+
EnumAttribute("nounwind"),
787813
StringAttribute("enzyme_shouldrecompute"),
788814
StringAttribute("enzyme_inactive"),
789815
StringAttribute("enzyme_no_escaping_allocation"),
@@ -994,9 +1020,18 @@ end
9941020
name = T == Float32 ? name * "f" : name
9951021

9961022
attrs = if LLVM.version().major <= 15
997-
LLVM.Attribute[LLVM.EnumAttribute("readnone"), StringAttribute("enzyme_shouldrecompute")]
1023+
LLVM.Attribute[LLVM.EnumAttribute("readnone"), StringAttribute("enzyme_shouldrecompute"),
1024+
EnumAttribute("willreturn"),
1025+
EnumAttribute("nosync"),
1026+
EnumAttribute("nounwind"),
1027+
EnumAttribute("nofree"),
1028+
]
9981029
else
999-
LLVM.Attribute[EnumAttribute("memory", NoEffects.data), StringAttribute("enzyme_shouldrecompute")]
1030+
LLVM.Attribute[EnumAttribute("memory", NoEffects.data), StringAttribute("enzyme_shouldrecompute"),
1031+
EnumAttribute("willreturn"),
1032+
EnumAttribute("nosync"),
1033+
EnumAttribute("nounwind"),
1034+
EnumAttribute("nofree")]
10001035
end
10011036
handleCustom(state, custom, k_name, llvmfn, name, attrs)
10021037
return

src/llvm/attributes.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,10 @@ function annotate!(mod::LLVM.Module)
579579
push!(function_attributes(fn), EnumAttribute("memory", NoEffects.data))
580580
end
581581
push!(function_attributes(fn), LLVM.StringAttribute("enzyme_shouldrecompute"))
582+
push!(function_attributes(fn), EnumAttribute("nounwind"))
583+
push!(function_attributes(fn), EnumAttribute("nosync"))
584+
push!(function_attributes(fn), EnumAttribute("nofree"))
585+
push!(function_attributes(fn), EnumAttribute("willreturn"))
582586
end
583587
end
584588
end
@@ -606,6 +610,19 @@ function annotate!(mod::LLVM.Module)
606610
end
607611
end
608612

613+
for fname in (
614+
"julia.safepoint",
615+
)
616+
if haskey(funcs, fname)
617+
for fn in funcs[fname]
618+
push!(function_attributes(fn), EnumAttribute("nofree"))
619+
push!(function_attributes(fn), EnumAttribute("nosync"))
620+
push!(function_attributes(fn), EnumAttribute("nounwind"))
621+
push!(function_attributes(fn), EnumAttribute("willreturn"))
622+
end
623+
end
624+
end
625+
609626
for fname in (
610627
"julia.safepoint",
611628
"ijl_pop_handler",

0 commit comments

Comments
 (0)