The __xray_* functions described in
https://llvm.org/docs/XRay.html can trigger patching, unpatching, mode changes, etc.
"If you choose to not use the default logging implementation that comes with the XRay runtime and/or control when/how the XRay instrumentation runs, you may use the XRay APIs directly for doing so.
...
If all you need is runtime control over which functions are being traced at any given time it is better to selectively patch and unpatch the individual functions you need using the XRay Runtime Library’s __xray_patch_function() method."