Description
I understand how custom annotations work on instructions, but I am confused about functions, and I see multiple options in the ecosystem. The tool-conventions repo has this example, annotation before the name:
;; option A
(func (@metadata.code.hotness "\01") $test (type 0).
The annotations repo has this example, annotation after the name:
;; option B
(func $lambda (@name "λ") (param $x (@name "α βγ δ") i32) (result i32) (local.get $x))
The first one is for the function, surely, given the name matches the function, and also the param has its own annotation later...? But that seems ambiguous in a function with no params or results: (func $foo (@something) (nop))
- is that annotation on the nop, or the function..?
The binaryen parser expects annotations before the entire function (same as for instructions):
;; option C
(@metadata.code.inline "\12") (func $annotated-func
(local $x i32)
(@metadata.code.branch_hint "\01")
(if .. ;; annotated instruction in function
I can't figure out which of A, B, C is correct from the spec text. I may be misreading it, though, or not reading the right place? (In particular, I don't see details about how annotations work on instructions, like branch hinting or compilation hints use annotations - is that documented elsewhere?)