I am a bit confused about the nature of LLVM’s SSA and IR in general.
- Is it possible to get LLVM to generate code as in /2/ (bellow)?
- if not, how can I tell if an operand has been previously defined?
Here is why:
I thought (wrongly) that all operands of an instruction must have been
previously defined or some constants.
I see that the ‘bitcast’ instruction is certainly standalone in certain cases, such as
%“alloca point” = bitcast i32 0 to i32; [#uses=0]
However the following instruction has a ‘bitcast’ inserted as an operand,
rather then the result of a previous bitcast:
(void)store i32 (…)* bitcast (i32 ()* @pf to i32 (…)*), i32 (…)** @pf0, align 8
In this case, the bitcast is a constant, but it does DEFINE a new value
and that value is the operand. I would have thought that the above code
should have been “pure IR/SSA”:
%TMP = bitcast (i32 ()* @pf to i32 (…))
(void)store i32 (…) %TMP, i32 (…)** @pf0, align 8
or something like that…