[LLVMdev] Metadata for Argument, BasicBlock

Ralf Karrenberg Chareos at gmx.de
Mon May 7 07:21:53 PDT 2012


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



More information about the llvm-dev mailing list