Hi, I am trying to write a Pass that reads metadata passed as a argument to a function. I have written them by hand in the .s file in the same way of the IR reference (http://llvm.org/docs/LangRef.html#named-metadata) : define i32 @function(i32 %argInt, metadata !3) nounwind {entry: %argInt.addr = alloca i32, align 4 store i32 %argInt, i32* %argInt.addr, align 4 %1 = load i32* %argInt.addr, align 4 %add = add nsw i32 %1, 1 ret i32 %add} !3 = metadata !{metadata !"metadata text"} but when I run my pass with opt on the .s file I get this error: 29:44: error: expected ')' at end of argument list define i32 @function(i32 %argInt, metadata !3) nounwind { How should I write a metadata in order to be able to get it from a function?There's eventually another way to attach a metadata to a function? Thank you in advance, Niko -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130211/ae187a0a/attachment.html>
On Mon, Feb 11, 2013 at 1:32 PM, Niko Zarzani <koni10 at hotmail.it> wrote:> Hi, I am trying to write a Pass that reads metadata passed as a argument to > a function. > > I have written them by hand in the .s file in the same way of the IR > reference (http://llvm.org/docs/LangRef.html#named-metadata) : > > define i32 @function(i32 %argInt, metadata !3) nounwind {This seems wrong. "metadata" is a type (like i32), and the exclamation mark is only used to refer to metadata nodes, not to declare functions with them. Eli
> > I have written them by hand in the .s file in the same way of the IR > > reference (http://llvm.org/docs/LangRef.html#named-metadata) : > > > > define i32 @function(i32 %argInt, metadata !3) nounwind { > > This seems wrong. "metadata" is a type (like i32), and the exclamation > mark is only used to refer to metadata nodes, not to declare functions > with them.I'm only interested in attaching a metadata string to a function with wirtten its precondition...Since here in the IR reference (http://llvm.org/docs/LangRef.html#metadata-nodes-and-metadata-strings) there is written: Metadata can be used as function arguments. Here llvm.dbg.value function is using two metadata arguments:call void @llvm.dbg.value(metadata !24, i64 0, metadata !25) I thought that maybe writing them as a function argument and then reading them could work... there is any other way to do that?Thank you :) Niko -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130211/d60b9248/attachment.html>