[LLVMdev] What is the purpose of the %”alloca point” line which occurs in llvm code

David Terei davidterei at gmail.com
Thu Aug 20 23:27:10 PDT 2009


Hi all,

I've been looking at some LLVM assembly produced by llvm-gcc lately
and I've noticed a recurring statement of which I'm not sure its
purpose.

For example, the following C program:

int main(void)
{
   void (*f)(void) = (0x21332);
   f();
}

When compiled with "llvm-gcc -emit-llvm -S" will produce the following
code (irrelevant parts removed):

define i32 @main() nounwind {
entry:
   %retval = alloca i32         ; <i32*> [#uses=1]
   %f = alloca void ()*         ; <void ()**> [#uses=2]
   %"alloca point" = bitcast i32 0 to i32       ; <i32> [#uses=0]
   store void ()* inttoptr (i64 135986 to void ()*), void ()** %f, align 4
   %0 = load void ()** %f, align 4      ; <void ()*> [#uses=1]
   call void %0() nounwind
   br label %return

I'm interested in the purpose of the line:

%"alloca point" = bitcast i32 0 to i32          ; <i32> [#uses=0]

Doesn't seem to do anything as the variable it assigns to is never
used again and the bitcast itself is pointless. All I can think of is
that its inserted really as a nop for later code generation / analysis
purposes, indicating interesting parts of the code.

Cheers,
David T.



More information about the llvm-dev mailing list