Source code annotations on loops


I'm writing an analysis pass that needs to know an upper bound on all loops. LLVM can determine loop bounds in some situations (Loop::getTripCount), but in other cases the developer of the analyzed code will need to supply them. One way this is accomplished is with commented annotations like:

// @loopBound=10
while (i < j) { ... }

I could use LLVM's debug info metadata to locate the source file and line number associated with this loop, then read the file and extract the comment, but I'm wondering if there's a better, more structured way. For example, there's the standard __attribute__ annotation facility in C:

But it can only annotate functions, not loops.

Is there another approach? Thanks,