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
Hi Tanya, In the long term, how are different uses of this string going to be kept from conflicting? Is this going to introduce another mini-syntax into LLVM, to allow different passes to recognize which pass the string is intended for, or to allow passes to pull out selected substrings and ignore the rest? Dan On Mon, Jun 18, 2007 at 04:44:54PM -0700, Tanya M. Lattner wrote:> > 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-- Dan Gohman, Cray Inc.
> In the long term, how are different uses of this string going to be > kept from conflicting? Is this going to introduce another mini-syntax > into LLVM, to allow different passes to recognize which pass the string > is intended for, or to allow passes to pull out selected substrings and > ignore the rest?I am also curious to know what this is intended for precisely. Couldn't it be done using debug intrinsics instead? Ciao, Duncan.
> In the long term, how are different uses of this string going to be > kept from conflicting? Is this going to introduce another mini-syntax > into LLVM, to allow different passes to recognize which pass the string > is intended for, or to allow passes to pull out selected substrings and > ignore the rest?I should have clarified: This is not something that would be used in mainline llvm. This is mainly for people doing something research orientated and need the annotate attribute. If they need to prevent strings from conflicting, they would do so. -Tanya