[LLVMdev] set of integers to metadata
David Blaikie
dblaikie at gmail.com
Fri May 3 13:32:06 PDT 2013
On May 3, 2013 5:30 AM, "Alexandru Ionut Diaconescu" <
alexandruionutdiaconescu at gmail.com> wrote:
>
> I also tried the following, with no compilation errors, but segfault,
core dumped:
>
> LLVMContext& C = is->getContext();
>
> Value* values[size];
>
> for(int gy=0;gy<size;gy++){
>
values[gy]=ConstantInt::getSigned(Type::getInt64Ty(C),array[gy]);
> }
>
> llvm::ArrayRef<Value*> bla = values[size];
This is most likely wrong. I not even entirely sure which array ref actor
that USS and who it compiled at all.
>
> is->setMetadata("path",MDNode::get(C,bla));
Skip the explicit array ref and just write:
MDNode::get(C, values)
Here
>
>
>
>
> On Fri, May 3, 2013 at 1:18 PM, Alexandru Ionut Diaconescu <
alexandruionutdiaconescu at gmail.com> wrote:
>>
>> Hello everyone,
>>
>> I want to pass a set of integers using metadata but I don't know how. I
have tried:
>>
>> the integers are in array[]
>>
>> 1.
>> LLVMContext& C = is->getContext();
>> Value* values[size];
>> for(int gy=0;gy<size;gy++){
>> values[gy]=ConstantInt::getSigned(Type::getInt64Ty(C),array[gy]);
>> }
>> is->setMetadata("path",MDNode::get(C,values));
>>
>> failes when setMetadata(), since
>>
>> Hello.cpp:706:56: error: no matching function for call to
‘llvm::MDNode::get(llvm::LLVMContext&, llvm::Value* [(((unsigned
int)(((int)cebagcnt) + -0x00000000000000001)) + 1)])’
>> Hello.cpp:706:56: note: candidate is:
>> /home/alex/llvm/include/llvm/Metadata.h:120:18: note: static
llvm::MDNode* llvm::MDNode::get(llvm::LLVMContext&,
llvm::ArrayRef<llvm::Value*>)
>> /home/alex/llvm/include/llvm/Metadata.h:120:18: note: no known
conversion for argument 2 from ‘llvm::Value* [(((unsigned
int)(((int)cebagcnt) + -0x00000000000000001)) + 1)]’ to
‘llvm::ArrayRef<llvm::Value*>’
>>
>> 2.
>> It works manually when I have
>>
>> Value* values[]{
>> ConstantInt::getSigned(Type::getInt64Ty(C),2),
>> ConstantInt::getSigned(Type::getInt64Ty(C),3)
>> };
>> but I want to add metadata using the array[] elements with integers.
>>
>> 3. also, not so appropriate, I tried to convert the concatenated array
elements into a StringRef tsts = llvm::Twine(srsr).str();, but I have
segfault errors. In addition, this method is not exactly what I need.
>>
>> How should I add all the array elements to metadata one by one, like I
am trying to do using values[] ?
>>
>> Thank you much !
>
>
>
>
> --
> Best regards,
> Alexandru Ionut Diaconescu
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130503/1546ab07/attachment.html>
More information about the llvm-dev
mailing list