[LLVMdev] support for attach embedded metadata to function/argument/basicblock proposal
ether
etherzhhb at gmail.com
Mon Jan 4 04:14:10 PST 2010
hi all,
As i know attach embedded metadata nodes to function/argument/basicblock
is not support yet, but such feature maybe useful to us. for example, we
got the conversation
"
> Sorry, forgot to post to list.
>
> For 2.7 I'm wondering if you could use custom metadata attached to the first instruction of a "special" block? You could register a unique kind (not sure how to guarantee uniqueness), and attach a metadata node via the context to the first instruction with this kind. Your pass would look for this. I have never tried this, so I don't know if predecessor passes that your pass would depend on would affect this metadata; if different threads with their own context would see metadata attached via a specific context; and what the resultant performance effect would be.
>
> Just a thought
>
> Garrison
>
> On Jan 2, 2010, at 10:52, Yannis Mantzouratos wrote:
>
>
> > Hi,
> >
> > We 're working on an llvm interpreter. We perform some static analysis
> > to detect some blocks with a specific property, and we need the
> > interpreter to be able to recognise these blocks fast in time it
> > reaches them. We thought of adding a new instruction in the LLVM
> > instruction set and put it in the beginning of such blocks, so that
> > the interpreter would be instantly alerted that the current block is
> > 'special'. Is there an easier/quicker way to do this?
> >
> > Cheers,
> > yannis
>
"
if we could attach metadata to a basicblock, this problem will be easily
done.
so i am going to add support for attaching metadata to
function/argument/basicblock.
the syntax of attaching metadata to a basicblock will go like this:
bbname, !mdname !md [, !othermdname !othermd ...]:
for example:
entry, !foo !bar: ; attach bar to entry block
and
entry, !foo !bar, !foo1 !bar1: ; attach bar and bar1 to entry block
and we could add a function/argument attribute named "metadata" for
attaching metadata to function or argument.
define void @functionname() metadata(!mdname !md, [, !othermdname !othermd ...]) [other funtion attributes] { ... }
declare i32 @functionname(i8 metadata(!mdname !md, [, !othermdname !othermd ...]) [other parameter attributes])
for example:
define void @f() metadata(!foo !bar) { ... } ;attach bar to function f
define void @f(i8 metadata(!foo !bar) a) { ... } ;attach bar to argument a
so, i think i shoud:
1.change "typedef DenseMap<const Instruction *, MDMapTy> MDStoreTy; in MetadataContextImpl"
to
"typedef DenseMap<const Value *, MDMapTy> MDStoreTy;"
and the corresponding method in MetadataContextImpl and MetadataContext?
2.modify the code of asm reader/writer
3.modify bitcode reader/writer
any comment or advice is appreciate
best regards
--ether
More information about the llvm-dev
mailing list