[LLVMdev] Why extra 4 bytes on stack ???

Duncan Sands baldrick at free.fr
Thu Feb 2 01:30:50 PST 2012


Hi Alexander,

> For some reason even the simplest "int main() { return 0; }" program
> allocates those four bytes:
>
> ; ModuleID = '/tmp/webcompile/_29079_0.bc'
> target datalayout =
> "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
> target triple = "x86_64-unknown-linux-gnu"
>
> define i32 @main() nounwind uwtable {
>    %1 = alloca i32, align 4
>    store i32 0, i32* %1
>    ret i32 0
> }

this is a clang oddity (dragonegg doesn't do this).  Presumably the clang
developers found it convenient to do this.  It doesn't matter since the
optimizers will zap the useless alloca.

Ciao, Duncan.



More information about the llvm-dev mailing list