[LLVMdev] giving metadata a function parameter as an operand

Eli Bendersky eliben at google.com
Tue Feb 12 08:23:32 PST 2013


On Tue, Feb 12, 2013 at 4:33 AM, Shemer, Anat <anat.shemer at intel.com> wrote:
> Hi,
>
> Is it possible to give an instruction metadata that accepts function
> argument as operand? The 2 functions are in the same module so the metadata
> operand can be resolved. Here is how I imagine it should look like:
>
> define i32 @f(i32 %v) {
>   %v0 = call i32 @f1 (i32 %v, metadata !0) ; this ok
>   ret i32 %v0
> }
>
> define i32 @f1 (i32 %v, metadata %md) { ; and this is ok too
>   %t0 = add i32 %v, 1, !md !%md
> ;                          ^ here it says it expects an integer
>   ret i32 %t0
> }
>
> !0 = metadata !{i32 4}

>From a cursory look at LLParser.cpp, this is not supported, since only
constant (= known at compile time) metadata nodes can be attached to
instructions. This makes sense, because metadata attached to
instructions are a complile-time property that should be available to
LLVM optimization passes and backends. What are the semantics of
having this value only known at runtime? Perhaps there's a better way
to achieve what you're trying to do.

Eli



More information about the llvm-dev mailing list