I am a bit confused about the nature of LLVM’s SSA and IR in general.

  1. Is it possible to get LLVM to generate code as in /2/ (bellow)?
  2. 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
%[65]“alloca point” = bitcast i32 [34]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 (…)** @[2]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 (…)** @[2]pf0, align 8
or something like that…

Thank you,

A constant expression is assumed to be unique and defined everywhere,
just like a constant integer or the address of a global. Think of it
as the result of the bitcast being defined everywhere, but written
inside of the instruction for convenience.