I have a pointer to a floating point numeric variable in my c ++ code. I would like to issue an IR llvm instruction that dereferences this pointer in order to access this variable from jited code. How can I issue such an instruction?
I tried to convert the pointer to an integer constant of 64 bits, then to a floating pointer. But when I get a malformed IR code.
auto *pointer_as_integer = ConstantInt::get( context, APInt(64, reinterpret_cast
(&variable))); auto *pointer = builder.CreateIntToPtr( pointer_as_integer, Type::getFloatTy(context)); return builder.CreateLoad( Type::getFloatTy(context), pointer);
Instruction does not dominate all uses!
= fadd float %PTR, 4.100000e+01 ret float
When I apply the verification pass. What is wrong with me?