[clang] [Clang][HTO] Add clang attribute for propagating llvm-level information (PR #83059)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 28 05:44:57 PST 2024
AaronBallman wrote:
> Hm actually reopening, the metadata isn't emitted if the defnition isn't available [e.g. for `extern int X;` when given an annotation
That seems like a bug (so long as the declaration is actually emitted to LLVM IR at all).
> @AaronBallman @erichkeane, do you have any suggestions for paths forward, for use cases where it is guaranteed that the attribute is valid and the user (or perhaps more specifically, another Clang-tool) needs to provide information to LLVM through Clang AST/source.
If it's a Clang-based tool, that might open up other options. I think it could be reasonable to have an internal-use-only Clang attribute (one with no `Spelling` so users have no way to access it) that wraps LLVM IR attributes. You could use `MySpecialLLVMAttr::CreateImplicit()` to create the attributes as-needed from within the tool, rather than modifying source code and feeding it in to the compiler. Would that perhaps be workable for you? (No idea what @erichkeane thinks of this idea, but if we went this route, I would want a nice comment on the attribute definition explaining why it intentionally has no spelling so nobody comes along later and adds a spelling for it without realizing the concerns.)
https://github.com/llvm/llvm-project/pull/83059
More information about the cfe-commits
mailing list