David Terei
2009-Aug-21 06:27 UTC
[LLVMdev] What is the purpose of the %”alloca point” line which occurs in llvm code
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.
Eli Friedman
2009-Aug-21 06:48 UTC
[LLVMdev] What is the purpose of the %”alloca point” line which occurs in llvm code
On Thu, Aug 20, 2009 at 11:27 PM, David Terei<davidterei at gmail.com> wrote:> I'm interested in the purpose of the line: > > %"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0]It's there as a placeholder for where to insert temporaries: alloca's go before the bitcast, and actual code generation starts after it. It's simply a convenience for the front-end; instcombine will eliminate it, and basically everything else will simply ignore it. -Eli
Possibly Parallel Threads
- [LLVMdev] Adding support to LLVM for data & code layout (needed by GHC)
- [LLVMdev] Adding support to LLVM for data & code layout (needed by GHC)
- [LLVMdev] Adding support to LLVM for data & code layout (needed by GHC)
- [LLVMdev] Adding support to LLVM for data & code layout (needed by GHC)
- [LLVMdev] Any experiemnts/evaluations on LLVM and graph rewriting (term-rewriting) systems?