[LLVMdev] Annotate attribute

Tanya M. Lattner tonic at nondot.org
Mon Jun 18 16:44:54 PDT 2007


Many of you on the llvm-dev list have requested this, so I've added a new 
attribute to llvm-gcc. The "annotate" attribute can be used to annotate 
functions, global and local variables with arbitrary strings. This can be 
useful for special purpose optimizations and are ignored by code generation.

For functions and global variables, the annotations are represented in a 
global array "llvm.global.annotations". This is an array of structs that 
contain four elements: pointer to the value, pointer to the string, 
pointer to a string which is the source file, and the line number.

Annotations for local variables use the "llvm.var.annotation" Intrinsic. This 
intrinsic has 4 arguments which are the same as the 4 elements in the struct 
for the global case.

If you would like to see an example of this, please run the following test:
lvm-gcc -c -emit-llvm test/CFrontend/2007-06-15-AnnotateAttribute.c -O -o -
|  llvm-dis

If you have any questions, please let me know.

Thanks,
Tanya



More information about the llvm-dev mailing list