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](https://stackoverflow.com/questions/48162515/passing-array-base-address-pointer-to-runtime-function-in-llvm-ir)

 Thanks in advance..

Bernard Nongpoh


Hi Bernard,

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.

Thanks Tim,

I figure it out and successfully retrieved the base pointer and pass it to the function.

Thanks a lot

Bernard Nongpoh