1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc  -O0 -mtriple=mipsel-linux-gnu -global-isel  -verify-machineinstrs %s -o -| FileCheck %s -check-prefixes=MIPS32
3
4@.str = private unnamed_addr constant [11 x i8] c"string %s\0A\00", align 1
5declare void @llvm.va_start(i8*)
6declare void @llvm.va_copy(i8*, i8*)
7declare i32 @printf(i8*, ...)
8
9define void @testVaCopyArg(i8* %fmt, ...) {
10; MIPS32-LABEL: testVaCopyArg:
11; MIPS32:       # %bb.0: # %entry
12; MIPS32-NEXT:    addiu $sp, $sp, -40
13; MIPS32-NEXT:    .cfi_def_cfa_offset 40
14; MIPS32-NEXT:    sw $ra, 36($sp) # 4-byte Folded Spill
15; MIPS32-NEXT:    .cfi_offset 31, -4
16; MIPS32-NEXT:    move $3, $4
17; MIPS32-NEXT:    addiu $1, $sp, 44
18; MIPS32-NEXT:    sw $5, 0($1)
19; MIPS32-NEXT:    addiu $1, $sp, 48
20; MIPS32-NEXT:    sw $6, 0($1)
21; MIPS32-NEXT:    addiu $1, $sp, 52
22; MIPS32-NEXT:    sw $7, 0($1)
23; MIPS32-NEXT:    lui $1, %hi($.str)
24; MIPS32-NEXT:    addiu $4, $1, %lo($.str)
25; MIPS32-NEXT:    addiu $6, $sp, 32
26; MIPS32-NEXT:    addiu $2, $sp, 28
27; MIPS32-NEXT:    addiu $5, $sp, 24
28; MIPS32-NEXT:    addiu $1, $sp, 20
29; MIPS32-NEXT:    sw $3, 0($6)
30; MIPS32-NEXT:    addiu $3, $sp, 44
31; MIPS32-NEXT:    sw $3, 0($2)
32; MIPS32-NEXT:    lw $2, 0($2)
33; MIPS32-NEXT:    sw $2, 0($5)
34; MIPS32-NEXT:    lw $2, 0($5)
35; MIPS32-NEXT:    ori $3, $zero, 4
36; MIPS32-NEXT:    addu $3, $2, $3
37; MIPS32-NEXT:    sw $3, 0($5)
38; MIPS32-NEXT:    lw $2, 0($2)
39; MIPS32-NEXT:    sw $2, 0($1)
40; MIPS32-NEXT:    lw $5, 0($1)
41; MIPS32-NEXT:    jal printf
42; MIPS32-NEXT:    nop
43; MIPS32-NEXT:    lw $ra, 36($sp) # 4-byte Folded Reload
44; MIPS32-NEXT:    addiu $sp, $sp, 40
45; MIPS32-NEXT:    jr $ra
46; MIPS32-NEXT:    nop
47entry:
48  %fmt.addr = alloca i8*, align 4
49  %ap = alloca i8*, align 4
50  %aq = alloca i8*, align 4
51  %s = alloca i8*, align 4
52  store i8* %fmt, i8** %fmt.addr, align 4
53  %ap1 = bitcast i8** %ap to i8*
54  call void @llvm.va_start(i8* %ap1)
55  %0 = bitcast i8** %aq to i8*
56  %1 = bitcast i8** %ap to i8*
57  call void @llvm.va_copy(i8* %0, i8* %1)
58  %argp.cur = load i8*, i8** %aq, align 4
59  %argp.next = getelementptr inbounds i8, i8* %argp.cur, i32 4
60  store i8* %argp.next, i8** %aq, align 4
61  %2 = bitcast i8* %argp.cur to i8**
62  %3 = load i8*, i8** %2, align 4
63  store i8* %3, i8** %s, align 4
64  %4 = load i8*, i8** %s, align 4
65  %call = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i32 0, i32 0), i8* %4)
66  ret void
67}
68