set of integers to metadata

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::ArrayRefllvm::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::ArrayRefllvm::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 !

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));

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