1 /* Test for PR 69625; make sure that a leaf vararg function does not overwrite
2 the caller's r6. */
3 /* { dg-do run } */
4 /* { dg-options "-O2" } */
5
6 extern void abort (void);
7
8 __attribute__ ((noinline))
9 int
foo(int x,...)10 foo (int x, ...)
11 {
12 __builtin_va_list vl;
13 int i;
14
15 __asm__ __volatile__ ("lhi %%r6,1" : : : "r6");
16 __builtin_va_start(vl, x);
17 for (i = 2; i <= 6; i++)
18 x += __builtin_va_arg(vl, int);
19 __builtin_va_end (vl);
20
21 return x;
22 }
23
24 __attribute__ ((noinline))
25 void
bar(int r2,int r3,int r4,int r5,int r6)26 bar (int r2, int r3, int r4, int r5, int r6)
27 {
28 foo (r2, r3, r4, r5, r6);
29 if (r6 != 6)
30 abort ();
31 }
32
33 int
main(void)34 main (void)
35 {
36 bar (2, 3, 4, 5, 6);
37 }
38