[LLVMdev] Declaration of a va_list should be an intrinsic?

Nicolas Geoffray nicolas.geoffray at lip6.fr
Mon Apr 2 04:50:35 PDT 2007


Hi everyone,

Currently, when declaring a va_list in llvm, one only needs to do:

%ap = alloca i8 * (Reference : llvm/docs/LangRef.html#int_varargs)

This is OK for x86 and PPC/Darwin ABI because a va_list in these architectures is
just a pointer to the stack. The va_start intrinsic just initializes where
the pointer points at in the stack. I do not know how the other backends operate,
but I suppose it's the same.

However, on the PPC/ELF ABI, a va_list is a struct (referring to http://refspecs.freestandards.org/elf/elfspec_ppc.pdf)
of 12 bytes allocated on stack. The struct *should* not be allocated by va_start because a va_copy would not know
if the struct is allocated or not.

Therefore, I think there should be a special intrinsic for declaring a va_list. This unfortunately requires changes to all
backends, but i do not see how this can be handled differently. If an other backend already handles this correctly, please
tell me which one.

For X86 and PPC/Darwin (and others), the intrinsic will do:
alloca i8*

And for PPC/ELF it does:
alloca [12 * i8]

Does this sound correct?

Best,
Nicolas




More information about the llvm-dev mailing list