[LLVMdev] Source code annotations on loops
Trevor Harmon
trevor.w.harmon at nasa.gov
Wed Mar 10 12:17:48 PST 2010
Hi,
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:
http://clang-analyzer.llvm.org/annotations.html
But it can only annotate functions, not loops.
Is there another approach? Thanks,
Trevor
More information about the llvm-dev
mailing list