[LLVMdev] new annotations in IR?
Julien Lerouge
jlerouge at apple.com
Thu Sep 22 11:22:41 PDT 2011
On Thu, Sep 22, 2011 at 01:35:33PM -0400, Mark Brown wrote:
> How can they processed? I cant seem to find any solid information about how
> they exist in IR form from a Passes perspective. I see things like
> @llvm.var.annotation in dumps but no relevant sounding methods to get at
> these.
>
> Thank you
The llvm.var.annotation and llvm.annotation intrinsics are documented here:
http://llvm.org/docs/LangRef.html#int_var_annotation
I couldn't find any documentation for the llvm.ptr.annotation.*
intrinsics in the language reference, but they follow the same model as
llvm.var.annotation except the first argument is a pointer to the field struct.
The llvm.global.annotation array does't seem to be documented either, but from
clang sources:
/// EmitAnnotateAttr - Generate the llvm::ConstantStruct which contains the
/// annotation information for a given GlobalValue. The annotation struct is
/// {i8 *, i8 *, i8 *, i32}. The first field is a constant expression, the
/// GlobalValue being annotated. The second field is the constant string
/// created from the AnnotateAttr's annotation. The third field is a constant
/// string containing the name of the translation unit. The fourth field is
/// the line number in the file of the annotated value declaration.
So, you would process those annotations like you would process regular IR
instructions & globals. For e.g., for the intrinsics, you can iterate over all
their uses, and for the global annotation array, iterator over all the operands
of the initializer. Intrinsics processing can be done like this for e.g.:
Function *F = Mod->getFunction("lvm.var.annotation");
// Assuming lvm.var.annotation was indeed used in the module
for (Value::use_iterator u = F->use_begin(), ...) {
// Do something with u.
Feel free to submit patches for the language reference ;-)
Hope this helps,
Julien
--
Julien Lerouge
PGP Key Id: 0xB1964A62
PGP Fingerprint: 392D 4BAD DB8B CE7F 4E5F FA3C 62DB 4AA7 B196 4A62
PGP Public Key from: keyserver.pgp.com
More information about the llvm-dev
mailing list