Skip to content

Conversation

@pmur
Copy link

@pmur pmur commented Feb 10, 2026

This RFC proposes to add support for instrumenting function calls using mcount fentry or xray, and adding a new builtin attribute to toggle instrumentation.

Today, mcount and xray enjoy experimental support, but I was unable to find any RFC proposing their inclusion.

Rendered

* [XRay](https://llvm.org/docs/XRay.html), an LLVM project to instrument both entry and exit of functions,
with dynamic enablement.

These features are all very similar, are effectively mutually exclusive (e.g., mcount and fentry).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
These features are all very similar, are effectively mutually exclusive (e.g., mcount and fentry).
These features are all very similar, and are effectively mutually exclusive (e.g., mcount and fentry).


### Language additions

A single builtin attribute, `instrument_fn`, will be added. It will be applied to functions and methods
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe there should be #[instrument_fn = "off"] or similar to opt out of all function instrumentation, not just entry/exit (you mentioned loop instrumentation earlier), that would be useful when implementing the instrumentation function to avoid recursively calling itself.

@ehuss ehuss added T-lang Relevant to the language team, which will review and decide on the RFC. T-compiler Relevant to the compiler team, which will review and decide on the RFC. labels Feb 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-compiler Relevant to the compiler team, which will review and decide on the RFC. T-lang Relevant to the language team, which will review and decide on the RFC.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants