I've seen one post on here about the "use of instruction is not an instruction" error, and I'm running into a similar issue, but without a good reason.
I'm using moe (https://llvm.moe/ocaml/Llvm.html) to write LLVM to build a compiler and my issue basically comes down to 3 lines:
let pointer = L.build_alloca float_t ("reg") builder in L.dump_value(pointer);
let test = L.build_store (L.const_float float_t 32.3) pointer builder in L.dump_value(test);
let loaded = L.build_load pointer ("reg") builder in L. dump_value(loaded);
what I'm doing here is basically using alloc to get some space in memory, then storing the value of 32.3 to that space, and trying to load it back into the place I allocated in memory.
LLVM wise, it looks pretty good, as, after the dump_module, output, I get something like this:
align 8 %reg = alloca double, align 8
store double 3.230000e+01, double* %reg, align 8
%x13 = load double, double* %reg, align 8
which should be exactly what I want -- I even tested this out by writing up a similar C program and it does something very similar to this in LLVM.
However, when I run my program I get the following error:
Use of instruction is not an instruction!
%x13 = load double, double* %reg, align 8
which really doesn't seem to make sense. I check out the error a bit more, and it seems like it's caused by a few lines in the LLVM source code:
if (Instruction *Used = dyn_cast<Instruction>(U.getUser()))
Assert(Used->getParent() != nullptr,
"Instruction referencing"
" instruction not embedded in a basic block!",
&I, Used);
else {
CheckFailed("Use of instruction is not an instruction!", U);
return;
}
}
which seem to imply it happens if the instructions don't have a parent, but I'm not sure why that would be the case.
Any help here would be very much appreciated!
%x12
? Can you dump it? – arrowdU.getUser()->dump()
. The problem is not with%reg
operand, but with a user of%x13
. – arrowd