I’m doing exploratory work where I’d like to be able to add annotations to Rust function and data declarations that I’d like to be able to look for in the generated LLVM.
I am still new to rust, but one design would be to define new Rust attributes via the plugin API, and then have annotations on top-level attributes translate into appends to @llvm.global.annotations. Annotations on data could then translate into calls of @llvm.var.annotation. This would make the Rust LLVM pretty similar to what I currently see with clang when attaching annotations via __attribute__((annotate("...")).
I haven’t been able to find an existing project that does something like this, but I’m still getting up to speed with what’s out there. Are there any current projects that provide a way of passing Rust source annotations onto LLVM? All the analysis I’d like to do is at the LLVM representation, so I just want a minimally disruptive way of doing this.