summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTim Northover <tnorthover@apple.com>2013-06-09 02:17:27 +0000
committerTim Northover <tnorthover@apple.com>2013-06-09 02:17:27 +0000
commitd84b17e157bb27bed236a400cccf4562d0b19d96 (patch)
tree0e00c7bb41f39ab536f58add300d86e0e49003f7 /test
parent1fe907e7f2de32df894373e24a10c8f54534d770 (diff)
downloadllvm-d84b17e157bb27bed236a400cccf4562d0b19d96.tar.gz
llvm-d84b17e157bb27bed236a400cccf4562d0b19d96.tar.bz2
llvm-d84b17e157bb27bed236a400cccf4562d0b19d96.tar.xz
Make DeadArgumentElimination more conservative on variadic functions
Variadic functions are particularly fragile in the face of ABI changes, so this limits how much the pass changes them git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183625 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/Transforms/DeadArgElim/variadic_safety.ll38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/Transforms/DeadArgElim/variadic_safety.ll b/test/Transforms/DeadArgElim/variadic_safety.ll
new file mode 100644
index 0000000000..15f57bcfdc
--- /dev/null
+++ b/test/Transforms/DeadArgElim/variadic_safety.ll
@@ -0,0 +1,38 @@
+; RUN: opt < %s -deadargelim -S | FileCheck %s
+
+declare void @llvm.va_start(i8*)
+
+define internal i32 @va_func(i32 %a, i32 %b, ...) {
+ %valist = alloca i8
+ call void @llvm.va_start(i8* %valist)
+
+ ret i32 %b
+}
+
+; Function derived from AArch64 ABI, where 8 integer arguments go in
+; registers but the 9th goes on the stack. We really don't want to put
+; just 7 args in registers and then start on the stack since any
+; va_arg implementation already present in va_func won't be expecting
+; it.
+define i32 @call_va(i32 %in) {
+ %stacked = alloca i32
+ store i32 42, i32* %stacked
+ %res = call i32(i32, i32, ...)* @va_func(i32 %in, i32 %in, [6 x i32] undef, i32* byval %stacked)
+ ret i32 %res
+; CHECK: call i32 (i32, i32, ...)* @va_func(i32 undef, i32 %in, [6 x i32] undef, i32* byval %stacked)
+}
+
+define internal i32 @va_deadret_func(i32 %a, i32 %b, ...) {
+ %valist = alloca i8
+ call void @llvm.va_start(i8* %valist)
+
+ ret i32 %a
+}
+
+define void @call_deadret(i32 %in) {
+ %stacked = alloca i32
+ store i32 42, i32* %stacked
+ call i32 (i32, i32, ...)* @va_deadret_func(i32 undef, i32 %in, [6 x i32] undef, i32* byval %stacked)
+ ret void
+; CHECK: call void (i32, i32, ...)* @va_deadret_func(i32 undef, i32 undef, [6 x i32] undef, i32* byval %stacked)
+}