1; RUN: llc < %s -mtriple=armv7-none-linux-gnueabi -pre-RA-sched=source | FileCheck %s
2; Test that we correctly align elements when using va_arg
3
4; CHECK-LABEL: test1:
5; CHECK-NOT: bfc
6; CHECK: add	[[REG:(r[0-9]+)|(lr)]], {{(r[0-9]+)|(lr)}}, #7
7; CHECK: bfc	[[REG]], #0, #3
8; CHECK-NOT: bfc
9
10define i64 @test1(i32 %i, ...) nounwind optsize {
11entry:
12  %g = alloca i8*, align 4
13  %g1 = bitcast i8** %g to i8*
14  call void @llvm.va_start(i8* %g1)
15  %0 = va_arg i8** %g, i64
16  call void @llvm.va_end(i8* %g1)
17  ret i64 %0
18}
19
20; CHECK-LABEL: test2:
21; CHECK-NOT: bfc
22; CHECK: add	[[REG:(r[0-9]+)|(lr)]], {{(r[0-9]+)|(lr)}}, #7
23; CHECK: bfc	[[REG]], #0, #3
24; CHECK-NOT:	bfc
25; CHECK: bx	lr
26
27define double @test2(i32 %a, i32* %b, ...) nounwind optsize {
28entry:
29  %ap = alloca i8*, align 4                       ; <i8**> [#uses=3]
30  %ap1 = bitcast i8** %ap to i8*                  ; <i8*> [#uses=2]
31  call void @llvm.va_start(i8* %ap1)
32  %0 = va_arg i8** %ap, i32                       ; <i32> [#uses=0]
33  store i32 %0, i32* %b
34  %1 = va_arg i8** %ap, double                    ; <double> [#uses=1]
35  call void @llvm.va_end(i8* %ap1)
36  ret double %1
37}
38
39
40declare void @llvm.va_start(i8*) nounwind
41
42declare void @llvm.va_end(i8*) nounwind
43