[LLVMdev] Wrong calling convention?

Duncan Sands baldrick at free.fr
Wed Mar 26 01:06:17 PDT 2008


Hi,

> define internal i1 @Addr_045442A0() {
> 	alloca [8 x i8], align 4		; <[8 x i8]*>:1 [#uses=2]
> 	alloca i1, align 4		; <i1*>:2 [#uses=2]
> 	tail call void @F95478DA5_FFI_FN( [8 x i8]* %1 sret  )

this call uses the "struct-return" convention (due to the sret attribute).
On x86 this means that the caller is responsible for adjusting the stack
pointer after the call for the sret parameter.  If the callee is not following
the sret convention then the stack pointer will be adjusted wrongly and your
program will die horribly.

> 0x0e8d937b:     call   0x5053b0 <_ZN3lp04OpF0IN5IncDB9TDateTimeEXadL_ZNS2_3NowEvEEE1wEv>
> 0x0e8d9380:     sub    $0x4,%esp

Here you see the sret stack adjustment.

Ciao,

Duncan.



More information about the llvm-dev mailing list