Metadata nodes and C API

Hi,

I'm relatively new to using LLVM, and I'm working on a front end for a
language I'm designing. I have a couple of questions about metadata:

1. I'd like to be able to store some high level program structure in
bitcode files, to be imported by future runs of my compiler, in order
to keep everything in one place (so my bitcode files become something
akin to Java's class files). I was thinking of using named metadata to
store that structure. I read in an old blog post that "use of metadata
is only safe if the program retains its semantics when the metadata is
silently dropped". Since it doesn't change the actual function of any
of the code (and the metadata nodes don't reference the code at all),
would this be a safe/practical way to store that high level structure
in the long term?

2. I couldn't find any way to extract data from (non-named) metadata
nodes from the C API. Is the attached patch an acceptable way to add
that functionality? If so, could someone commit it?

Thanks,
Anthony Bryant.

mdnode_operands.patch (1.65 KB)

Could someone take a look at this patch please? It only adds a couple
of short functions to the C bindings.

Thanks,
Anthony Bryant.

mdnode_operands.patch (1.65 KB)

Hi Anthony,

You need to send patches to the llvm-commits mailing list to get them
reviewed and committed.

-Dave

-- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted
by The Linux Foundation

From: llvmdev-bounces@cs.uiuc.edu [mailto:llvmdev-bounces@cs.uiuc.edu]
On Behalf Of Anthony Bryant
Sent: Wednesday, September 12, 2012 8:53 AM
To: llvmdev@cs.uiuc.edu
Subject: Re: [LLVMdev] [Patch] Metadata nodes and C API

> Hi,
>
> I'm relatively new to using LLVM, and I'm working on a front end for a
> language I'm designing. I have a couple of questions about metadata:
>
> 1. I'd like to be able to store some high level program structure in
> bitcode files, to be imported by future runs of my compiler, in order
> to keep everything in one place (so my bitcode files become something
> akin to Java's class files). I was thinking of using named metadata to
> store that structure. I read in an old blog post that "use of metadata
> is only safe if the program retains its semantics when the metadata is
> silently dropped". Since it doesn't change the actual function of any
> of the code (and the metadata nodes don't reference the code at all),
> would this be a safe/practical way to store that high level structure
> in the long term?
>
> 2. I couldn't find any way to extract data from (non-named) metadata
> nodes from the C API. Is the attached patch an acceptable way to add
> that functionality? If so, could someone commit it?
>
> Thanks,
> Anthony Bryant.

Could someone take a look at this patch please? It only adds a couple of

short

David Peixotto wrote:

Hi Anthony,

You need to send patches to the llvm-commits mailing list to get them
reviewed and committed.

This should probably be mentioned here:
http://llvm.org/docs/DeveloperPolicy.html#making-a-patch

It's at the top of the document, but easy to miss for those of us who just
want to cut to the information they need.

I myself have just made the same mistake, and I'm sure I've seen reviews
happen here before.