Bernard Nongpoh via llvm-dev
2018-Jan-09 07:08 UTC
[llvm-dev] Passing Array base address/pointer to runtime function in LLVM IR
Hello LLVM, I am a beginner in LLVM My Goal is to initialize array element with random values. llvm::Type *i32_type = llvm::IntegerType::getInt32Ty(allocaInst->getContext()); llvm::Value *value = llvm::ConstantInt::get(i32_type, numberOfElement); args.push_back(getElementPtrInst->getPointerOperand()); args.push_back(value); callInst = llvm::CallInst::Create(runtimeInitializeRandomIntegerArrayValue, args,"" , allocaInst->getNextNode()); Tried the above code but no luck .. Any method that can easily pass array base address/pointer to function. Question on stackoverlfow: https://stackoverflow.com/questions/48162515/passing-array-base-address-pointer-to-runtime-function-in-llvm-ir Thanks in advance.. Bernard Nongpoh -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180109/9d999b9b/attachment.html>
Tim Northover via llvm-dev
2018-Jan-09 09:54 UTC
[llvm-dev] Passing Array base address/pointer to runtime function in LLVM IR
Hi Bernard, On 9 January 2018 at 07:08, Bernard Nongpoh via llvm-dev <llvm-dev at lists.llvm.org> wrote:> Tried the above code but no luck ..I'm afraid there's not enough context here to answer the question. The code you posted looks like it could work, but a lot would depend on the definitions you omitted: getElementPtrInst especially, though a dump of the whole Module as it exists when this code is executed would be even better. Knowing exactly what went wrong (error, assertion (which?), segfault, ...) would also be very helpful. Cheers. Tim.
Bernard Nongpoh via llvm-dev
2018-Jan-09 10:06 UTC
[llvm-dev] Passing Array base address/pointer to runtime function in LLVM IR
Thanks Tim, I figure it out and successfully retrieved the base pointer and pass it to the function. Thanks a lot Bernard Nongpoh On Tue, Jan 9, 2018 at 3:24 PM, Tim Northover <t.p.northover at gmail.com> wrote:> Hi Bernard, > > On 9 January 2018 at 07:08, Bernard Nongpoh via llvm-dev > <llvm-dev at lists.llvm.org> wrote: > > Tried the above code but no luck .. > > I'm afraid there's not enough context here to answer the question. The > code you posted looks like it could work, but a lot would depend on > the definitions you omitted: getElementPtrInst especially, though a > dump of the whole Module as it exists when this code is executed would > be even better. > > Knowing exactly what went wrong (error, assertion (which?), segfault, > ...) would also be very helpful. > > Cheers. > > Tim. >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180109/7f43a31a/attachment.html>