I’d like to add a custom #pragma directive in clang for research purposes. I’m familiar with the LLVM pass-writing interface but new to the rest of LLVM and clang. I’ve looked into Simone Pellegrini’s work on a #pragma interface (https://github.com/motonacciu/clomp and http://llvm.org/devmtg/2013-04/pellegrini-slides.pdf), but I’m in no position to determine if this approach is applicable for the latest version of clang, or how to go about updating things. Any advice would be greatly appreciated.
A number of new pragmas were added recently to clang to support loop optimization hints. The syntax is “#pragma clang loop …” where “…” is a sequence of hints such as “unroll(4)”. These hints result in llvm.loop metadata being added to the IR to annotate the loop. Depending upon what you’re doing this may be a good model to follow.
I’m giving annotation attributes a shot right now: attribute((annotate(“my_annotation”))) gets lowered to llvm.___annotation intrinsics and seems good for what I’m trying to do. I’ll definitely look into the loop pragma as a backup though.