Thanks David, I don't want my pass to get any surprise when some front-ends emit va_arg.  Can you please point out the link of your beta versions? Thanks, Neal. <br><br><div class="gmail_quote">On Mon, Jul 19, 2010 at 2:18 PM, David Meyer <span dir="ltr"><<a href="mailto:pdox@google.com">pdox@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Neal,<br>
<br>
FYI, my group has added a flag to llvm-gcc for emitting the va_arg<br>
instruction (instead of lowering in the front-end),<br>
and we also have an implementation of the VAARG instruction for<br>
X86-64. (which is currently not implemented in the LLVM backend).<br>
<br>
Both of these things will be sent upstream to LLVM soon, pending some<br>
more testing and review.<br>
<br>
If you are dire need of these features now, I can point you to the<br>
(public) repository where we have the beta versions.<br>
<br>
- David M<br>
<div><div></div><div class="h5"><br>
<br>
On Mon, Jul 19, 2010 at 11:57 AM, Neal  N. Wang <<a href="mailto:neal.wang@gmail.com">neal.wang@gmail.com</a>> wrote:<br>
> Hi folk,<br>
><br>
> I'm writing a set of small C code to verify whether my pass handle some<br>
> instruction correctly.   One of the instruction I want to test is "va_arg",<br>
> but compiling my variadic function does not generate any va_arg instruction.<br>
> Is va_arg deprecated? Will va_arg instruction ever be generated by any<br>
> front-end?  The source code and llvm instructions are appended as follows.<br>
><br>
> the c code<br>
> #include<stdarg.h><br>
> #include<stdio.h><br>
> #include<stdlib.h><br>
><br>
> void printValue(char * fmt, ...) {<br>
>   va_list args;<br>
>   va_start(args, fmt);<br>
>   int i;<br>
>   double d;<br>
>   i = va_arg(args, int);<br>
>   d = va_arg(args, double);<br>
>   va_end(args);<br>
> }<br>
><br>
> the generated llvm instructions:<br>
> ; ModuleID = 'i.bc'<br>
> target datalayout =<br>
> "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"<br>
> target triple = "i386-pc-linux-gnu"<br>
><br>
> define void @printValue(i8* %fmt, ...) nounwind {<br>
> entry:<br>
>   %fmt_addr = alloca i8*                          ; <i8**> [#uses=1]<br>
>   %args.2 = alloca i8*                            ; <i8**> [#uses=3]<br>
>   %args.0 = alloca i8*                            ; <i8**> [#uses=3]<br>
>   %args = alloca i8*                              ; <i8**> [#uses=6]<br>
>   %i = alloca i32                                 ; <i32*> [#uses=1]<br>
>   %d = alloca double, align 8                     ; <double*> [#uses=1]<br>
>   %"alloca point" = bitcast i32 0 to i32          ; <i32> [#uses=0]<br>
>   store i8* %fmt, i8** %fmt_addr<br>
>   %args1 = bitcast i8** %args to i8*              ; <i8*> [#uses=1]<br>
>   call void @llvm.va_start(i8* %args1)<br>
>   %0 = load i8** %args, align 4                   ; <i8*> [#uses=1]<br>
>   store i8* %0, i8** %args.0, align 4<br>
>   %1 = load i8** %args.0, align 4                 ; <i8*> [#uses=1]<br>
>   %2 = getelementptr inbounds i8* %1, i64 4       ; <i8*> [#uses=1]<br>
>   store i8* %2, i8** %args, align 4<br>
>   %3 = load i8** %args.0, align 4                 ; <i8*> [#uses=1]<br>
>   %4 = bitcast i8* %3 to i32*                     ; <i32*> [#uses=1]<br>
>   %5 = load i32* %4, align 4                      ; <i32> [#uses=1]<br>
>   store i32 %5, i32* %i, align 4<br>
>   %6 = load i8** %args, align 4                   ; <i8*> [#uses=1]<br>
>   store i8* %6, i8** %args.2, align 4<br>
>   %7 = load i8** %args.2, align 4                 ; <i8*> [#uses=1]<br>
>   %8 = getelementptr inbounds i8* %7, i64 8       ; <i8*> [#uses=1]<br>
>   store i8* %8, i8** %args, align 4<br>
>   %9 = load i8** %args.2, align 4                 ; <i8*> [#uses=1]<br>
>   %10 = bitcast i8* %9 to double*                 ; <double*> [#uses=1]<br>
>   %11 = load double* %10, align 4                 ; <double> [#uses=1]<br>
>   store double %11, double* %d, align 8<br>
>   %args2 = bitcast i8** %args to i8*              ; <i8*> [#uses=1]<br>
>   call void @llvm.va_end(i8* %args2)<br>
>   br label %return<br>
><br>
> return:                                           ; preds = %entry<br>
>   ret void<br>
> }<br>
><br>
> declare void @llvm.va_start(i8*) nounwind<br>
><br>
> declare void @llvm.va_end(i8*) nounwind<br>
><br>
><br>
><br>
</div></div><div><div></div><div class="h5">> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
><br>
><br>
</div></div></blockquote></div><br>