[cfe-users] What are the ll lines starting with '!0', '!1', etc? How to retrieve them?

Hugh Perkins via cfe-users cfe-users at lists.llvm.org
Tue Sep 27 07:22:45 PDT 2016


In the IR text, I see lines like:

!0 = !{void (float*)* @_Z11somekernel1Pf, !"kernel", i32 1}
!1 = !{void (float*)* @_Z3fooPf, !"kernel", i32 1}

What are these?  How to retrieve them, given eg a Module *.  I've tried
iterating over the global variables, named metadata, and aliases, but
nothing.  I'm trying:

    for(auto it=M->named_metadata_begin(); it != M->named_metadata_end();
it++) {
        NamedMDNode *namedMDNode = &*it;
        cout << "namedmdnode " << namedMDNode << endl;
        cout << "name " << string(namedMDNode->getName()) << endl;
    }

    for(auto it=M->global_begin(); it != M->global_end(); it++) {
        GlobalVariable *global = &*it;
        cout << "global " << global << endl;
        cout << string(global->getName()) << endl;
    }

    for(auto it=M->alias_begin(); it != M->alias_end(); it++) {
        GlobalAlias *alias = &*it;
        cout << "alias " << alias << endl;
        cout << string(alias->getName()) << endl;
    }

Result:

namedmdnode 0x1655cf0
name nvvm.annotations
namedmdnode 0x1658a00
name llvm.ident
namedmdnode 0x1658c10
name nvvm.internalize.after.link
namedmdnode 0x1658cd0
name nvvmir.version
global 0x164f468
.str
global 0x1650ac8
llvm.used

It seems like what I want is 'annotations', because in the ll, the
nvvm.annotations looks like:

!nvvm.annotations = !{!0, !1, !2, !3, !2, !4, !4, !4, !4, !5, !5, !4}

... and that seems like it references these !0, !1 lines somehow?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20160927/32f267b8/attachment.html>


More information about the cfe-users mailing list