From cc494e8312c8e654be348d0f1dc0b0d73b87cb49 Mon Sep 17 00:00:00 2001 From: Andrew Lenharth Date: Sat, 18 Jun 2005 18:30:37 +0000 Subject: [PATCH] new vararg test git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22252 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Feature/varargs_new.ll | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 test/Feature/varargs_new.ll diff --git a/test/Feature/varargs_new.ll b/test/Feature/varargs_new.ll new file mode 100644 index 00000000000..df6b38e0cc0 --- /dev/null +++ b/test/Feature/varargs_new.ll @@ -0,0 +1,33 @@ +; RUN: llvm-as %s -o - | llvm-dis > %t1.ll +; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll +; RUN: diff %t1.ll %t2.ll + +; Demonstrate all of the variable argument handling intrinsic functions plus +; the va_arg instruction. + +implementation ; Functions: +declare void %llvm.va_start(sbyte**) +declare void %llvm.va_copy(sbyte**, sbyte*) +declare void %llvm.va_end(sbyte**) + +int %test(int %X, ...) { + ; Allocate two va_list items. On this target, va_list is of type sbyte* + %ap = alloca sbyte* ; [#uses=4] + %aq = alloca sbyte* ; [#uses=2] + + ; Initialize variable argument processing + call void %llvm.va_start(sbyte** %ap) + + ; Read a single integer argument + %tmp = vaarg sbyte** %ap, int ; [#uses=1] + + ; Demonstrate usage of llvm.va_copy and llvm_va_end + %apv = load sbyte** %ap ; [#uses=1] + call void %llvm.va_copy(sbyte** %aq, sbyte* %apv) + call void %llvm.va_end(sbyte** %aq) + + ; Stop processing of arguments. + call void %llvm.va_end(sbyte** %ap) + ret int %tmp + +}