Hello, I am a bit confused about the nature of LLVM's SSA and IR in general. Questions: 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; <i32> [#uses=0] However the following instruction has a 'bitcast' inserted as an operand, rather then the result of a previous bitcast: /*1*/ (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": /*2*/ %TMP = bitcast (i32 ()* @pf to i32 (...)*) (void)store i32 (...)* %TMP, i32 (...)** @[2]pf0, align 8 or something like that... Thank you, Dan _________________________________________________________________ Hotmail: Trusted email with powerful SPAM protection. http://clk.atdmt.com/GBL/go/177141665/direct/01/ -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20091126/8dcd364f/attachment.html>
On Wed, Nov 25, 2009 at 5:18 PM, dan mihai <dnmh68 at hotmail.com> wrote:> However the following instruction has a 'bitcast' inserted as an operand, > rather then the result of a previous bitcast: > /*1*/ > (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": > /*2*/ > %TMP = bitcast (i32 ()* @pf to i32 (...)*) > (void)store i32 (...)* %TMP, i32 (...)** @[2]pf0, align 8 > or something like that...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. -Eli