@@ -855,7 +855,8 @@ Functions
855
855
::
856
856
857
857
decl ::= sil-function
858
- sil-function ::= 'sil' sil-linkage? sil-function-name ':' sil-type
858
+ sil-function ::= 'sil' sil-linkage? sil-function-attribute+
859
+ sil-function-name ':' sil-type
859
860
'{' sil-basic-block+ '}'
860
861
sil-function-name ::= '@' [A-Za-z_0-9]+
861
862
@@ -867,6 +868,134 @@ The ``sil`` syntax declares the function's name and SIL type, and
867
868
defines the body of the function inside braces. The declared type must
868
869
be a function type, which may be generic.
869
870
871
+
872
+ Function Attributes
873
+ ```````````````````
874
+ ::
875
+
876
+ sil-function-attribute ::= '[canonical]'
877
+
878
+ The function is in canonical SIL even if the module is still in raw SIL.
879
+ ::
880
+
881
+ sil-function-attribute ::= '[ossa]'
882
+
883
+ The function is in OSSA (ownership SSA) form.
884
+ ::
885
+
886
+ sil-function-attribute ::= '[transparent]'
887
+
888
+ Transparent functions are always inlined and don't keep their source
889
+ information when inlined.
890
+ ::
891
+
892
+ sil-function-attribute ::= '[' sil-function-thunk ']'
893
+ sil-function-thunk ::= 'thunk'
894
+ sil-function-thunk ::= 'signature_optimized_thunk'
895
+ sil-function-thunk ::= 'reabstraction_thunk'
896
+
897
+ The function is a compiler generated thunk.
898
+ ::
899
+
900
+ sil-function-attribute ::= '[dynamically_replacable]'
901
+
902
+ The function can be replaced at runtime with a different implementation.
903
+ Optimizations must not assume anything about such a function, even if the SIL
904
+ of the function body is available.
905
+ ::
906
+
907
+ sil-function-attribute ::= '[dynamic_replacement_for' identifier ']'
908
+ sil-function-attribute ::= '[objc_replacement_for' identifier ']'
909
+
910
+ Specifies for which function this function is a replacement.
911
+ ::
912
+
913
+ sil-function-attribute ::= '[exact_self_class]'
914
+
915
+ The function is a designated initializers, where it is known that the static
916
+ type being allocated is the type of the class that defines the designated
917
+ initializer.
918
+ ::
919
+
920
+ sil-function-attribute ::= '[without_actually_escaping]'
921
+
922
+ The function is a thunk for closures which are not actually escaping.
923
+ ::
924
+
925
+ sil-function-attribute ::= '[' sil-function-purpose ']'
926
+ sil-function-purpose ::= 'global_init'
927
+
928
+ The implied semantics are:
929
+
930
+ - side-effects can occur any time before the first invocation.
931
+ - all calls to the same ``global_init `` function have the same side-effects.
932
+ - any operation that may observe the initializer's side-effects must be
933
+ preceded by a call to the initializer.
934
+
935
+ This is currently true if the function is an addressor that was lazily
936
+ generated from a global variable access. Note that the initialization
937
+ function itself does not need this attribute. It is private and only
938
+ called within the addressor.
939
+ ::
940
+
941
+ sil-function-attribute ::= '[weak_imported]'
942
+
943
+ Cross-module references to this function should always use weak linking.
944
+ ::
945
+
946
+ sil-function-attribute ::= '[available' sil-version-tuple ']'
947
+ sil-version-tuple ::= [0-9]+ ('.' [0-9]+)*
948
+
949
+ The minimal OS-version where the function is available.
950
+ ::
951
+
952
+ sil-function-attribute ::= '[' sil-function-inlining ']'
953
+ sil-function-inlining ::= 'never'
954
+
955
+ The function is never inlined.
956
+ ::
957
+
958
+ sil-function-inlining ::= 'always'
959
+
960
+ The function is always inlined, even in a ``Onone `` build.
961
+ ::
962
+
963
+ sil-function-attribute ::= '[' sil-function-optimization ']'
964
+ sil-function-inlining ::= 'Onone'
965
+ sil-function-inlining ::= 'Ospeed'
966
+ sil-function-inlining ::= 'Osize'
967
+
968
+ The function is optimized according to this attribute, overriding the setting
969
+ from the command line.
970
+ ::
971
+
972
+ sil-function-attribute ::= '[' sil-function-effects ']'
973
+ sil-function-effects ::= 'readonly'
974
+ sil-function-effects ::= 'readnone'
975
+ sil-function-effects ::= 'readwrite'
976
+ sil-function-effects ::= 'releasenone'
977
+
978
+ The specified memory effects of the function.
979
+ ::
980
+
981
+ sil-function-attribute ::= '[_semantics "' [A-Za-z._0-9]+ '"]'
982
+
983
+ The specified high-level semantics of the function. The optimizer can use this
984
+ information to perform high-level optimizations before such functions are
985
+ inlined. For example, ``Array `` operations are annotated with semantic
986
+ attributes to let the optimizer perform redundant bounds check elimination and
987
+ similar optimizations.
988
+ ::
989
+
990
+ sil-function-attribute ::= '[_specialize "' [A-Za-z._0-9]+ '"]'
991
+
992
+ Specifies for which types specialized code should be generated.
993
+ ::
994
+
995
+ sil-function-attribute ::= '[clang "' identifier '"]'
996
+
997
+ The clang node owner.
998
+
870
999
Basic Blocks
871
1000
~~~~~~~~~~~~
872
1001
::
0 commit comments