OSDN Git Service

092fd686a6755b289d42be07930c178657131e9f
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / opt / devirt2.C
1 // { dg-do compile }
2 // { dg-options "-O2" }
3 /* Using -mshort-calls avoids loading the function addresses in
4    registers and thus getting the counts wrong.  */
5 // { dg-additional-options "-mshort-calls" {target epiphany-*-*} }
6 // Using -mno-abicalls avoids a R_MIPS_JALR .reloc.
7 // { dg-additional-options "-mno-abicalls" { target mips*-*-* } }
8 // { dg-final { scan-assembler-times "xyzzy" 2 { target { ! { alpha*-*-* hppa*-*-* ia64*-*-hpux* sparc*-*-* } } } } }
9 // The IA64 and HPPA compilers generate external declarations in addition
10 // to the call so those scans need to be more specific.
11 // { dg-final { scan-assembler-times "br\[^\n\]*xyzzy" 2 { target ia64*-*-hpux* } } }
12 // { dg-final { scan-assembler-times "xyzzy\[^\n\]*,%r" 2 { target hppa*-*-* } } }
13 // If assembler supports explicit relocation directives, the alpha compiler generates
14 // literal/lituse_jsr pairs, so the scans need to be more specific.
15 // { dg-final { scan-assembler-times "jsr\[^\n\]*xyzzy" 2 { target alpha*-*-* } } }
16 // Unless the assembler supports -relax, the 32-bit SPARC compiler generates
17 // sethi/jmp instead of just call, so the scans need to be more specific.
18 // With subexpressions, Tcl regexp -inline -all returns both the complete
19 // match and the subexpressions, so double the count.
20 // { dg-final { scan-assembler-times "\(jmp|call\)\[^\n\]*xyzzy" 4 { target sparc*-*-* } } }
21
22 struct S { S(); virtual void xyzzy(); };
23 struct R { int a; S s; R(); };
24 S s;
25 R r;
26 inline void foo(S *p) { p->xyzzy(); }
27 void bar() {foo(&s);}
28 void bah() {foo(&r.s);}