Hi everybody, Is there a clean way to attach metadata nodes to Arguments and/or BasicBlocks? It looks to me like one can directly attach metadata only to instructions. My current workaround is to insert a call to a dummy function that holds metadata for its parent block - pretty ugly, but manageable. The same problem arises when I want to store specific information about the arguments of a function. Does anybody have a suggestion how I could do this more elegantly? Thanks, Ralf
Hi Ralf,> Is there a clean way to attach metadata nodes to Arguments and/or > BasicBlocks?not at the moment. Feel free to work on adding this functionality!> It looks to me like one can directly attach metadata only to instructions. > My current workaround is to insert a call to a dummy function that holds > metadata for its parent block - pretty ugly, but manageable. The same > problem arises when I want to store specific information about the > arguments of a function. > > Does anybody have a suggestion how I could do this more elegantly?Maybe you could take the address of the basic block (using blockaddress), and use that as an argument for a module level metadatum. Ciao, Duncan.
Hi Duncan, On 5/6/12 6:12 PM, Duncan Sands wrote:> Hi Ralf, > >> Is there a clean way to attach metadata nodes to Arguments and/or >> BasicBlocks? > > not at the moment. Feel free to work on adding this functionality!I am looking into that now. I decided to temporarily go for the following syntax for BasicBlock metadata (subject to discussion): entry: !property_1 !0, !property_2 !1 %x = fadd float %a, %b It seems that I have to touch lots of files for this: BasicBlock.h/.cpp, Metadata.cpp, LLParser.cpp, AsmParser, AsmWriter, BitcodeReader.cpp, BitcodeWriter.cpp so far. I basically went and duplicated code that handles metadata attached to instructions. Concerning Argument metadata, I am unsure of how to best represent this in LLVM IR. The following seems to be better than putting the metadata somewhere before the first block or anywhere else, but the space in the parameter list looks a bit crowded... declare void test(i32 %param1 !property1 !0, !property2 !1, float* %param2 readonly !property2 !1) Cheers, Ralf