Hi,
My application generates some LLVM assembly code which I then convert to IR code using ParseAssemblyString. If I have the following LLVM assembly code:
define double @test() {
ret double 1.230000e+02
}
then, using ExecutionEngine::runFunction, I get a GenericValue return value which DoubleVal property is indeed equal to 123. So, all is fine there. However, if I have the following LLVM assembly code:
define void @test(double* %data) {
%1 = getelementptr inbounds double* %data, i64 1
store double 1.230000e+02, double* %1, align 8
%2 = getelementptr inbounds double* %data, i64 3
store double 1.230000e+02, double* %2, align 8
ret void
}
then, I thought I could declare an array of doubles and pass it to ExecutionEngine::runFunction as follows:
double data[4];
data[0] = 100;
data[1] = 101;
data[2] = 102;
data[3] = 103;
std::vectorllvm::GenericValue args;
args.push_back(llvm::GenericValue(data));
executionEngine->runFunction(function, args);
As expected, data[1] and data[3] get updated, but… not to 123 but to 6.22870535974643e-317 (!!). I am still relatively new to LLVM so I wouldn’t exclude the fact that I might have done something wrong while trying to pass my data array to my function…?
Anyway, any help would be much appreciated…
Cheers, Alan.
PS: I have tried the getPointerToFunction(), but it just crashes my application…!?