set of integers to metadata

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

set of integers to metadata

Alexandru Ionut Diaconescu
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 ! 

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: set of integers to metadata

Alexandru Ionut Diaconescu
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];

  is->setMetadata("path",MDNode::get(C,bla));





On Fri, May 3, 2013 at 1:18 PM, Alexandru Ionut Diaconescu <[hidden email]> 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
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: set of integers to metadata

David Blaikie


On May 3, 2013 5:30 AM, "Alexandru Ionut Diaconescu" <[hidden email]> 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 <[hidden email]> 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
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev