===================================================================
@@ -239,6 +239,27 @@ proc profopt-execute { src } {
set executable $tmpdir/[file tail [file rootname $src].x]
set basename [file tail $testcase]
set base [file rootname $basename]
+ set dir [file dirname $src]
+ # multiple file test base
+ set mbase [file rootname $basename]
+ regsub "_0" $mbase "" mbase
+ regsub "/" $mbase "" mbase
+ set src_list $src
+ set i 1
+ set done 0
+ while { !$done } {
+ set names [glob -nocomplain -types f -- "${dir}/${mbase}_${i}.*"]
+ if { [llength ${names}] > 1 } {
+ warning "profopt-execute: more than one file matched ${dir}/${mbase}_${i}.*"
+ }
+ if { [llength ${names}] == 1 } {
+ lappend src_list [lindex ${names} 0]
+ incr i
+ } else {
+ set num_srcs ${i}
+ set done 1
+ }
+ }
set count 0
foreach option $prof_option_list {
@@ -279,7 +300,8 @@ proc profopt-execute { src } {
set options "$extra_options"
lappend options "additional_flags=$option $extra_flags $profile_option"
set optstr "$option $profile_option"
- set comp_output [${tool}_target_compile "$src" "$execname1" executable $options]
+ verbose "Hey $src_list $execname1 executable $options"
+ set comp_output [${tool}_target_compile "$src_list" "$execname1" executable $options]
if ![${tool}_check_compile "$testcase compilation" $optstr $execname1 $comp_output] {
unresolved "$testcase execution, $optstr"
unresolved "$testcase compilation, $option $feedback_option"
@@ -294,15 +316,32 @@ proc profopt-execute { src } {
set missing_file 0
# Make sure the profile data was generated, and fail if not.
if { $status == "pass" } {
- foreach ext $prof_ext {
- remote_upload target $tmpdir/$base.$ext
- set files [glob -nocomplain $base.$ext]
- if { $files == "" } {
- set status "fail"
- set missing_file 1
- fail "$testcase execution: file $base.$ext does not exist, $option $profile_option"
- }
- }
+ set i 0
+ if { $num_srcs > 1 } {
+ foreach s $src_list {
+ foreach ext $prof_ext {
+ remote_upload target $tmpdir/${mbase}_${i}.$ext
+ set files [glob -nocomplain ${mbase}_${i}.$ext]
+ if { $files == "" } {
+ set status "fail"
+ set missing_file 1
+ fail "$testcase execution: file ${mbase}_${i}.$ext does not exist, $option $profile_option"
+ }
+ }
+ incr i
+ }
+ } else {
+ foreach ext $prof_ext {
+ remote_upload target $tmpdir/$base.$ext
+ set files [glob -nocomplain $base.$ext]
+ if { $files == "" } {
+ set status "fail"
+ set missing_file 1
+ fail "$testcase execution: file $base.$ext does not exist, $option $profile_option"
+ }
+ }
+ }
+
}
if { $missing_file == 0 } {
$status "$testcase execution, $optstr"
@@ -328,7 +367,7 @@ proc profopt-execute { src } {
set options "$extra_options"
lappend options "additional_flags=$option $extra_flags $feedback_option"
set optstr "$option $feedback_option"
- set comp_output [${tool}_target_compile "$src" "$execname2" "executable" $options]
+ set comp_output [${tool}_target_compile "$src_list" "$execname2" "executable" $options]
# Prune warnings we know are unwanted.
set comp_output [prune_warnings $comp_output]
@@ -379,7 +418,7 @@ proc profopt-execute { src } {
set options "$extra_options"
lappend options "additional_flags=$option"
set optstr "$option"
- set comp_output [${tool}_target_compile "$src" "$execname3" "executable" $options]
+ set comp_output [${tool}_target_compile "$src_list" "$execname3" "executable" $options]
if ![${tool}_check_compile "$testcase compilation" $optstr $execname3 $comp_output] {
unresolved "$testcase execution, $optstr"
unresolved "$testcase perf check, $optstr"
===================================================================
@@ -1,42 +0,0 @@
-/* { dg-options "-O2 -fdump-tree-optimized" } */
-int a;
-int b[100];
-void abort (void);
-
-inline void
-cold_function ()
-{
- int i;
- for (i = 0; i < 99; i++)
- if (b[i] / (b[i+1] + 1))
- abort ();
-}
-
-inline void
-hot_function ()
-{
- int i;
- for (i = 0; i < 99; i++)
- if (b[i] / (b[i+1] + 1))
- abort ();
-}
-
-main ()
-{
- int i;
- for (i = 0; i < 100; i++)
- {
- if (a)
- cold_function ();
- else
- hot_function ();
- }
- return 0;
-}
-
-/* cold function should be inlined, while hot function should not.
- Look for "cold_function () [tail call];" call statement not for the
- declaration or other apperances of the string in dump. */
-/* { dg-final-use { scan-tree-dump "cold_function ..;" "optimized"} } */
-/* { dg-final-use { scan-tree-dump-not "hot_function ..;" "optimized"} } */
-/* { dg-final-use { cleanup-tree-dump "optimized" } } */
===================================================================
@@ -1,5 +0,0 @@
-file /usr/local/google/davidxl/dev/gcc/gcc-gmain-native_64-linux/libexec/gcc/x86_64-linux/4.6.0-google-main/cc1
-set args -quiet -v indir-call-prof.c -march=core2 -mcx16 -msahf --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=4096 -mtune=core2 -quiet -dumpbase indir-call-prof.c -auxbase indir-call-prof -g -O2 -version -fprofile-generate -fripa -fdump-ipa-tree_profile_ipa -fdump-tree-optimized-blocks -o /tmp/ccdBoNgb.s
-b main
-b internal_error
-b fancy_abort
===================================================================
@@ -0,0 +1,23 @@
+/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-tree_profile_ipa" } */
+
+extern void setp (int (**pp) (void), int i);
+
+int
+main (void)
+{
+ int (*p) (void);
+ int i;
+
+ for (i = 0; i < 10; i ++)
+ {
+ setp (&p, i);
+ p ();
+ }
+
+ return 0;
+}
+
+/* { dg-final-use { scan-ipa-dump "Indirect call -> direct call.* a1" "tree_profile_ipa"} } */
+/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */
+/* { dg-final-use { cleanup-tree-dump "optimized" } } */
+/* { dg-final-use { cleanup-ipa-dump "tree_profile_ipa" } } */
===================================================================
@@ -0,0 +1,23 @@
+/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-tree_profile_ipa" } */
+
+int a1 (void)
+{
+ return 10;
+}
+
+int a2 (void)
+{
+ return 0;
+}
+
+typedef int (*tp) (void);
+
+tp aa [] = {a2, a1, a1, a1, a1};
+
+__attribute__((noinline)) void setp (int (**pp) (void), int i)
+{
+ if (!i)
+ *pp = aa [i];
+ else
+ *pp = aa [(i & 2) + 1];
+}
===================================================================
@@ -1,22 +0,0 @@
-/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-tree_profile_ipa" } */
-int a[1000];
-int b[1000];
-int size=1;
-int max=10000;
-main()
-{
- int i;
- for (i=0;i<max; i++)
- {
- __builtin_memcpy (a, b, size * sizeof (a[0]));
- asm("");
- }
- return 0;
-}
-/* { dg-final-use { scan-ipa-dump "Single value 4 stringop" "tree_profile_ipa"} } */
-/* Really this ought to simplify into assignment, but we are not there yet. */
-/* a[0] = b[0] is what we fold the resulting memcpy into. */
-/* { dg-final-use { scan-tree-dump " = MEM.*&b" "optimized"} } */
-/* { dg-final-use { scan-tree-dump "MEM.*&a\\\] = " "optimized"} } */
-/* { dg-final-use { cleanup-tree-dump "optimized" } } */
-/* { dg-final-use { cleanup-ipa-dump "tree_profile_ipa" } } */
===================================================================
@@ -1,21 +0,0 @@
-/* { dg-options "-O2 -fdump-ipa-tree_profile_ipa-blocks -fdump-tree-optimized-blocks" } */
-int max = 33333;
-int a[8];
-int
-main ()
-{
- int i;
- for (i = 0; i < max; i++)
- {
- a[i % 8]++;
- }
- return 0;
-}
-/* Loop header copying will peel away the initial conditional, so the loop body
- is once reached directly from entry point of function, rest via loopback
- edge. */
-/* { dg-final-use { scan-ipa-dump "count:33333" "tree_profile_ipa"} } */
-/* { dg-final-use { scan-tree-dump "count:33332" "optimized"} } */
-/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */
-/* { dg-final-use { cleanup-ipa-dump "tree_profile_ipa" } } */
-/* { dg-final-use { cleanup-tree-dump "optimized" } } */
===================================================================
@@ -1,20 +0,0 @@
-/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-tree_profile_ipa" } */
-int a[1000];
-int b[1000];
-int size=1;
-int max=10000;
-main()
-{
- int i;
- for (i=0;i<max; i++)
- {
- __builtin_memset (a, 10, size * sizeof (a[0]));
- asm("");
- }
- return 0;
-}
-/* { dg-final-use { scan-ipa-dump "Single value 4 stringop" "tree_profile_ipa"} } */
-/* The versioned memset of size 4 should be optimized to an assignment. */
-/* { dg-final-use { scan-tree-dump "a\\\[0\\\] = 168430090" "optimized"} } */
-/* { dg-final-use { cleanup-tree-dump "optimized" } } */
-/* { dg-final-use { cleanup-ipa-dump "tree_profile_ipa" } } */
===================================================================
@@ -1,19 +0,0 @@
-/* { dg-options "-O2 -fdump-ipa-tree_profile_ipa" } */
-/* { dg-additional-sources "ic-misattribution-1a.c" } */
-
-extern void other_caller (void);
-
-void
-callee (void)
-{
- return;
-}
-
-void
-caller(void (*func) (void))
-{
- func ();
-}
-
-/* { dg-final-use { scan-ipa-dump "hist->count 1 hist->all 1" "tree_profile_ipa" } } */
-/* { dg-final-use { cleanup-ipa-dump "tree_profile_ipa" } } */
===================================================================
@@ -1,20 +0,0 @@
-/* { dg-options "-O2 -fdump-tree-tailc -fdump-tree-optimized" } */
-__attribute__ ((noinline))
-int factorial(int x)
-{
- if (x == 1)
- return 1;
- else
- return x*factorial(--x);
-}
-int gbl;
-int
-main()
-{
- gbl = factorial(100);
- return 0;
-}
-/* { dg-final-use { scan-tree-dump-not "Invalid sum" "tailc"} } */
-/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */
-/* { dg-final-use { cleanup-tree-dump "tailc" } } */
-/* { dg-final-use { cleanup-tree-dump "optimized" } } */
===================================================================
@@ -1,22 +0,0 @@
-/* { dg-options "-DEMPTY" } */
-/* This file is only needed in combination with ic-misattribution-1.c
- but there's no easy way to make this file ignored. */
-extern void callee (void);
-extern void caller (void (*func) (void));
-
-typedef void (*func_t) (void);
-func_t func;
-
-int
-main ()
-{
-#ifdef EMPTY
-#else
- func = callee;
- caller (callee);
- func ();
-#endif
- return 0;
-}
-
-/* { dg-final-use { cleanup-ipa-dump "tree_profile_ipa" } } */
===================================================================
@@ -1,18 +0,0 @@
-/* { dg-options "-O2 -ftracer -fdump-tree-tracer" } */
-volatile int a, b, c;
-int main ()
-{
- int i;
- for (i = 0; i < 1000; i++)
- {
- if (i % 17)
- a++;
- else
- b++;
- c++;
- }
- return 0;
-}
-/* Superblock formation should produce two copies of the increment of c */
-/* { dg-final-generate { scan-tree-dump-times "c =" 2 "tracer" } } */
-/* { dg-final-use { cleanup-tree-dump "tracer" } } */
===================================================================
@@ -1,43 +0,0 @@
-/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-tree_profile_ipa" } */
-
-static int a1 (void)
-{
- return 10;
-}
-
-static int a2 (void)
-{
- return 0;
-}
-
-typedef int (*tp) (void);
-
-static tp aa [] = {a2, a1, a1, a1, a1};
-
-__attribute__((noinline)) void setp (int (**pp) (void), int i)
-{
- if (!i)
- *pp = aa [i];
- else
- *pp = aa [(i & 2) + 1];
-}
-
-int
-main (void)
-{
- int (*p) (void);
- int i;
-
- for (i = 0; i < 10; i ++)
- {
- setp (&p, i);
- p ();
- }
-
- return 0;
-}
-
-/* { dg-final-use { scan-ipa-dump "Indirect call -> direct call.* a1" "tree_profile_ipa"} } */
-/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */
-/* { dg-final-use { cleanup-tree-dump "optimized" } } */
-/* { dg-final-use { cleanup-ipa-dump "tree_profile_ipa" } } */
===================================================================
@@ -1,22 +0,0 @@
-/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-tree_profile_ipa" } */
-int a[1000];
-int b = 256;
-int c = 257;
-main ()
-{
- int i;
- int n;
- for (i = 0; i < 1000; i++)
- {
- if (i % 17)
- n = c;
- else n = b;
- a[i] /= n;
- }
- return 0;
-}
-/* { dg-final-use { scan-ipa-dump "Div.mod by constant n_\[0-9\]*=257 transformation on insn" "tree_profile_ipa"} } */
-/* { dg-final-use { scan-tree-dump "if \\(n_\[0-9\]* != 257\\)" "optimized"} } */
-/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */
-/* { dg-final-use { cleanup-tree-dump "optimized" } } */
-/* { dg-final-use { cleanup-ipa-dump "tree_profile_ipa" } } */
===================================================================
@@ -1,32 +0,0 @@
-/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-tree_profile_ipa" } */
-unsigned int a[1000];
-unsigned int b = 256;
-unsigned int c = 1024;
-unsigned int d = 17;
-main ()
-{
- int i;
- unsigned int n;
- for (i = 0; i < 1000; i++)
- {
- a[i]=100*i;
- }
- for (i = 0; i < 1000; i++)
- {
- if (i % 2)
- n = b;
- else if (i % 3)
- n = c;
- else
- n = d;
- a[i] %= n;
- }
- return 0;
-}
-/* { dg-final-use { scan-ipa-dump "Mod power of 2 transformation on insn" "tree_profile_ipa" } } */
-/* This is part of code checking that n is power of 2, so we are sure that the transformation
- didn't get optimized out. */
-/* { dg-final-use { scan-tree-dump "n_\[0-9\]* \\+ 0xffff" "optimized"} } */
-/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */
-/* { dg-final-use { cleanup-tree-dump "optimized" } } */
-/* { dg-final-use { cleanup-ipa-dump "tree_profile_ipa" } } */
===================================================================
@@ -1,32 +0,0 @@
-/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-tree_profile_ipa" } */
-unsigned int a[1000];
-unsigned int b = 257;
-unsigned int c = 1023;
-unsigned int d = 19;
-main ()
-{
- int i;
- unsigned int n;
- for (i = 0; i < 1000; i++)
- {
- a[i]=18;
- }
- for (i = 0; i < 1000; i++)
- {
- if (i % 2)
- n = b;
- else if (i % 3)
- n = c;
- else
- n = d;
- a[i] %= n;
- }
- return 0;
-}
-/* { dg-final-use { scan-ipa-dump "Mod subtract transformation on insn" "tree_profile_ipa" } } */
-/* This is part of code checking that n is greater than the divisor so we are sure that it
- didn't get optimized out. */
-/* { dg-final-use { scan-tree-dump "if \\(n_\[0-9\]* \\>" "optimized"} } */
-/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */
-/* { dg-final-use { cleanup-tree-dump "optimized" } } */
-/* { dg-final-use { cleanup-ipa-dump "tree_profile_ipa" } } */
===================================================================
@@ -1,32 +0,0 @@
-/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-tree_profile_ipa" } */
-unsigned int a[1000];
-unsigned int b = 999;
-unsigned int c = 1002;
-unsigned int d = 1003;
-main ()
-{
- int i;
- unsigned int n;
- for (i = 0; i < 1000; i++)
- {
- a[i]=1000+i;
- }
- for (i = 0; i < 1000; i++)
- {
- if (i % 2)
- n = b;
- else if (i % 3)
- n = c;
- else
- n = d;
- a[i] %= n;
- }
- return 0;
-}
-/* { dg-final-use { scan-ipa-dump "Mod subtract transformation on insn" "tree_profile_ipa" } } */
-/* This is part of code checking that n is greater than the divisor so we are sure that it
- didn't get optimized out. */
-/* { dg-final-use { scan-tree-dump "if \\(n_\[0-9\]* \\>" "optimized"} } */
-/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */
-/* { dg-final-use { cleanup-tree-dump "optimized" } } */
-/* { dg-final-use { cleanup-ipa-dump "tree_profile_ipa" } } */
===================================================================
@@ -1,17 +0,0 @@
-/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-tree_profile_ipa" } */
-int a[1000];
-int b=997;
-main()
-{
- int i;
- for (i = 0; i < 1000; i++)
- if (a[i])
- a[i]/=b;
- else
- a[i]/=b;
- return 0;
-}
-/* { dg-final-use { scan-ipa-dump "Div.mod by constant b.*=997 transformation on insn" "tree_profile_ipa" } } */
-/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */
-/* { dg-final-use { cleanup-tree-dump "optimized" } } */
-/* { dg-final-use { cleanup-ipa-dump "tree_profile_ipa" } } */
===================================================================
@@ -1,20 +0,0 @@
-/* { dg-options "-O2 -fdump-tree-optimized" } */
-char a[1000];
-char b[1000];
-int size=1000;
-__attribute__ ((noinline))
-t(int size)
-{
- __builtin_memcpy(a,b,size);
-}
-int
-main()
-{
- int i;
- for (i=0; i < size; i++)
- t(i);
- return 0;
-}
-/* { dg-final-use { scan-tree-dump "Average value sum:499500" "optimized"} } */
-/* { dg-final-use { scan-tree-dump "IOR value" "optimized"} } */
-/* { dg-final-use { cleanup-tree-dump "optimized" } } */
===================================================================
@@ -1,26 +0,0 @@
-/* { dg-options "-O2 -fdump-ipa-tree_profile_ipa -mtune=core2" } */
-/* { dg-skip-if "" { ! { i?86-*-* x86_64-*-* } } { "*" } { "" } } */
-
-#include <strings.h>
-
-int foo(int len)
-{
- char array[1000];
- bzero(array, len);
- return 0;
-}
-
-int main() {
- int i;
- for (i = 0; i < 1000; i++)
- {
- if (i > 990)
- foo(16);
- else
- foo(8);
- }
- return 0;
-}
-
-/* { dg-final-use { scan-ipa-dump "Single value 8 stringop transformation on bzero" "tree_profile_ipa" } } */
-/* { dg-final-use { cleanup-ipa-dump "tree_profile_ipa" } } */
===================================================================
@@ -1,23 +0,0 @@
-/* PR bootstrap/47187 */
-/* { dg-options "-O2" } */
-
-char buf[64];
-char buf2[64];
-
-void *
-foo (char *p, long size)
-{
- return __builtin_memcpy (buf, p, size);
-}
-
-int
-main (void)
-{
- long i;
- for (i = 0; i < 65536; i++)
- if (foo ("abcdefghijkl", 12) != buf)
- __builtin_abort ();
- if (foo (buf2, 64) != buf)
- __builtin_abort ();
- return 0;
-}
===================================================================
@@ -1,21 +0,0 @@
-
-/* { dg-options "-O2 -fdump-tree-optimized-blocks" } */
-int a[8];
-__attribute__ ((noinline))
-int t()
-{
- int i;
- for (i = 0; i < 3; i++)
- if (a[i])
- break;
- return i;
-}
-main ()
-{
- int i;
- for (i = 0; i < 1000; i++)
- t ();
- return 0;
-}
-/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */
-/* { dg-final-use { cleanup-tree-dump "optimized" } } */
===================================================================
@@ -1,39 +0,0 @@
-/* { dg-require-effective-target freorder } */
-/* { dg-options "-O2 -freorder-blocks-and-partition" } */
-
-#include <string.h>
-
-#define SIZE 1000
-int t0 = 0;
-const char *t2[SIZE];
-char buf[SIZE];
-
-void
-foo (void)
-{
- char *s = buf;
- t0 = 1;
-
- for (;;)
- {
- if (*s == '\0')
- break;
- else
- {
- t2[t0] = s;
- t0++;
- }
- *s++ = '\0';
- }
- t2[t0] = NULL;
-}
-
-
-int
-main ()
-{
- strcpy (buf, "hello");
- foo ();
- return 0;
-}
-
===================================================================
@@ -0,0 +1,29 @@
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+extern int foo (void);
+extern int goo (void);
+
+
+int bar (void)
+{
+ return 2;
+}
+
+int g;
+int main ()
+{
+ int s = 0, i;
+
+ for (i = 0; i < 1000; i ++)
+ {
+ s += foo(); /* Should be inlined */
+ s += goo(); /* Should be inlined */
+ }
+
+ g = s;
+ return 0;
+}
+
+/* { dg-final-use { scan-tree-dump-not "foo" "optimized"} } */
+/* { dg-final-use { scan-tree-dump-not "goo" "optimized"} } */
+/* { dg-final-use { cleanup-tree-dump "optimized" } } */
===================================================================
@@ -0,0 +1,22 @@
+extern int bar(void);
+extern int blah(void);
+int foo (void)
+{
+ int i, s = 0;
+
+ for (i = 0; i < 2; i++)
+ {
+ s += bar(); /* Inlined */
+ s += blah(); /* Inlined */
+ }
+ return s;
+}
+
+int goo (void)
+{
+ return 10;
+}
+
+/* { dg-final-use { scan-tree-dump-not "bar" "optimized"} } */
+/* { dg-final-use { scan-tree-dump-not "blah" "optimized"} } */
+/* { dg-final-use { cleanup-tree-dump "optimized" } } */
===================================================================
@@ -1,45 +0,0 @@
-/* Same test as built-in-setjmp.c. Includes the case where
- the source block of a crossing fallthru edge ends with a call. */
-/* { dg-require-effective-target freorder } */
-/* { dg-options "-O2 -freorder-blocks-and-partition" } */
-
-extern int strcmp(const char *, const char *);
-extern char *strcpy(char *, const char *);
-extern void abort(void);
-extern void exit(int);
-
-void *buf[20];
-
-void __attribute__((noinline))
-sub2 (void)
-{
- __builtin_longjmp (buf, 1);
-}
-
-int
-main ()
-{
- char *p = (char *) __builtin_alloca (20);
-
- strcpy (p, "test");
-
- if (__builtin_setjmp (buf))
- {
- if (strcmp (p, "test") != 0)
- abort ();
-
- exit (0);
- }
-
- {
- int *q = (int *) __builtin_alloca (p[2] * sizeof (int));
- int i;
-
- for (i = 0; i < p[2]; i++)
- q[i] = 0;
-
- while (1)
- sub2 ();
- }
-}
-
===================================================================
@@ -0,0 +1,6 @@
+int blah (void)
+{
+ return 2;
+}
+
+/* { dg-final-use { cleanup-tree-dump "optimized" } } */
===================================================================
@@ -45,7 +45,7 @@ load_lib profopt.exp
set profile_option "-fprofile-generate -fripa -D_PROFILE_GENERATE"
set feedback_option "-fprofile-use -fripa -D_PROFILE_USE"
-foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c]] {
+foreach src [lsort [glob -nocomplain $srcdir/$subdir/*_0.c]] {
# If we're only testing specific files and this isn't one of them, skip it.
if ![runtest_file_p $runtests $src] then {
continue
===================================================================
@@ -1,19 +1,19 @@
/* { dg-options "-O2 -fdump-ipa-tree_profile_ipa" } */
-/* { dg-additional-sources "ic-misattribution-1a.c" } */
-extern void other_caller (void);
+extern void callee (void);
+extern void caller (void (*func) (void));
-void
-callee (void)
-{
- return;
-}
+typedef void (*func_t) (void);
+func_t func;
-void
-caller(void (*func) (void))
+int
+main ()
{
+ func = callee;
+ caller (callee);
func ();
+ return 0;
}
-/* { dg-final-use { scan-ipa-dump "hist->count 1 hist->all 1" "tree_profile_ipa" } } */
+/* { dg-final-use { scan-ipa-dump-times "Indirect call -> direct call" 2 "tree_profile_ipa" } } */
/* { dg-final-use { cleanup-ipa-dump "tree_profile_ipa" } } */
===================================================================
@@ -1,22 +1,18 @@
-/* { dg-options "-DEMPTY" } */
-/* This file is only needed in combination with ic-misattribution-1.c
- but there's no easy way to make this file ignored. */
-extern void callee (void);
-extern void caller (void (*func) (void));
+/* { dg-options "-O2 -fdump-ipa-tree_profile_ipa" } */
-typedef void (*func_t) (void);
-func_t func;
+extern void other_caller (void);
-int
-main ()
+void
+callee (void)
+{
+ return;
+}
+
+void
+caller(void (*func) (void))
{
-#ifdef EMPTY
-#else
- func = callee;
- caller (callee);
func ();
-#endif
- return 0;
}
+/* { dg-final-use { scan-ipa-dump "Indiret call -> direct call" "tree_profile_ipa" } } */
/* { dg-final-use { cleanup-ipa-dump "tree_profile_ipa" } } */
===================================================================
@@ -1,20 +0,0 @@
-/* { dg-options "-O2 -Wno-coverage-mismatch" } */
-
-int __attribute__((noinline)) bar (void)
-{
-}
-
-int foo (int i)
-{
-#ifdef _PROFILE_USE
- if (i)
- bar ();
-#endif
- return 0;
-}
-
-int main(int argc, char **argv)
-{
- foo (argc);
- return 0;
-}
===================================================================
@@ -1,43 +0,0 @@
-/* { dg-require-effective-target freorder } */
-/* { dg-options "-O -freorder-blocks-and-partition -fschedule-insns -fselective-scheduling" { target powerpc*-*-* ia64-*-* x86_64-*-* } } */
-
-extern void abort (void);
-
-int ifelse_val2;
-
-int __attribute__((noinline))
-test_ifelse2 (int i)
-{
- int result = 0;
- if (!i) /* count(6) */
- result = 1; /* count(1) */
- if (i == 1) /* count(6) */
- result = 1024;
- if (i == 2) /* count(6) */
- result = 2; /* count(3) */
- if (i == 3) /* count(6) */
- return 8; /* count(2) */
- if (i == 4) /* count(4) */
- return 2048;
- return result; /* count(4) */
-}
-
-void __attribute__((noinline))
-call_ifelse ()
-{
- ifelse_val2 += test_ifelse2 (0);
- ifelse_val2 += test_ifelse2 (2);
- ifelse_val2 += test_ifelse2 (2);
- ifelse_val2 += test_ifelse2 (2);
- ifelse_val2 += test_ifelse2 (3);
- ifelse_val2 += test_ifelse2 (3);
-}
-
-int
-main()
-{
- call_ifelse ();
- if (ifelse_val2 != 23)
- abort ();
- return 0;
-}
===================================================================
@@ -0,0 +1,41 @@
+/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-tree_profile_ipa" } */
+#include <stdio.h>
+struct A {
+ A () {}
+ virtual int AA (void) { return 0; }
+};
+
+extern A* getB (void);
+extern A* getC (void);
+
+int g;
+
+int
+main (void)
+{
+ A* p;
+ int i;
+ int s = 0;
+
+ p = getB();
+ for (i = 0; i < 100; i++)
+ {
+ s += p->AA();
+ }
+
+ for (i = 0; i < 100; i++)
+ {
+ if (i%10 == 0)
+ p = getB();
+ else
+ p = getC();
+
+ s += p->AA();
+ }
+ printf ("result = %d\n",s);
+}
+
+/* { dg-final-use { scan-ipa-dump-times "Indirect call -> direct call" 2 "tree_profile_ipa" } } */
+/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized" } } */
+/* { dg-final-use { cleanup-tree-dump "optimized" } } */
+/* { dg-final-use { cleanup-ipa-dump "tree_profile_ipa" } } */
===================================================================
@@ -0,0 +1,23 @@
+/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-tree_profile_ipa" } */
+
+struct A {
+ A () {}
+
+ virtual int AA (void)
+ { return 0; }
+
+};
+
+struct B : public A {
+ B () {}
+
+ virtual int AA (void)
+ { return 1; }
+};
+
+B b;
+
+A* getB (void)
+{
+ return &b;
+}
===================================================================
@@ -0,0 +1,31 @@
+/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-tree_profile_ipa" } */
+
+struct A {
+ A () {}
+
+ virtual int AA (void)
+ { return 0; }
+
+};
+
+struct B : public A {
+ B () {}
+
+ virtual int AA (void)
+ { return 1; }
+};
+
+struct C : public B {
+ C () {}
+
+ virtual int AA (void)
+ { return 2; }
+
+};
+
+C c;
+
+A* getC(void)
+{
+ return &c;
+}
===================================================================
@@ -45,7 +45,7 @@ load_lib profopt.exp
set profile_option "-fprofile-generate -fripa"
set feedback_option "-fprofile-use -fripa"
-foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.C]] {
+foreach src [lsort [glob -nocomplain $srcdir/$subdir/*_0.C]] {
# If we're only testing specific files and this isn't one of them, skip it.
if ![runtest_file_p $runtests $src] then {
continue
===================================================================
@@ -1,36 +0,0 @@
-/* { dg-options "-O2 -fdump-tree-einline" } */
-class DocId {
- public:
- DocId() { }
- DocId(const DocId &other) { }
-};
-
-int g;
-class Base {
- public:
- virtual void Foo(DocId id) { g++; }
-};
-
-class Super: public Base {
- public:
- void Foo(DocId id) { }
- void Bar(Base *base, DocId id) __attribute__((noinline));
-};
-
-void Super::Bar(Base *base, DocId id) {
- Super::Foo(id); // direct call is inlined
- base->Foo(id); // indirect call is marked do not inline
-}
-
-int main(void)
-{
- Base bah;
- Super baz;
- DocId gid;
-
- baz.Bar(&baz, gid);
- return 0;
-}
-/* { dg-final-use { scan-tree-dump "Inlining .*Super::Foo" "einline" } } */
-/* { dg-final-use { scan-tree-dump-not "mismatched arguments" "einline" } } */
-/* { dg-final-use { cleanup-tree-dump "einline" } } */
===================================================================
@@ -1,35 +0,0 @@
-/* { dg-options "-O" } */
-
-int foo1(void) { return 0; }
-int bar1(void) { throw 1; }
-void foo2(void) { }
-void bar2(void) { throw 1; }
-void __attribute__((noinline,noclone)) test1(void (*f)(void)) { (*f)(); }
-void __attribute__((noinline,noclone)) test2(void (*f)(void)) { (*f)(); }
-int __attribute__((noinline,noclone)) test3(int (*f)(void)) { return (*f)(); }
-int __attribute__((noinline,noclone)) test4(int (*f)(void)) { return (*f)(); }
-int __attribute__((noinline,noclone)) test5(int (*f)(void), int x) { return x ? x : (*f)(); }
-int __attribute__((noinline,noclone)) test6(int (*f)(void), int x) { return x ? x : (*f)(); }
-void __attribute__((noinline,noclone)) test7(void (*f)(void)) { try { (*f)(); } catch (...) {} }
-void __attribute__((noinline,noclone)) test8(void (*f)(void)) { try { (*f)(); } catch (...) {}}
-int __attribute__((noinline,noclone)) test9(int (*f)(void)) { try { return (*f)(); } catch (...) {return 0;} }
-int __attribute__((noinline,noclone)) test10(int (*f)(void)) { try { return (*f)(); } catch (...) {return 0;} }
-int __attribute__((noinline,noclone)) test11(int (*f)(void), int x) { try { return x ? x : (*f)(); } catch (...) {return 0;} }
-int __attribute__((noinline,noclone)) test12(int (*f)(void), int x) { try { return x ? x : (*f)(); } catch (...) {return 0;} }
-
-int main()
-{
- for (int i = 0; i < 100; ++i) test1(foo2);
- for (int i = 0; i < 100; ++i) try { test2(bar2); } catch (...) {}
- for (int i = 0; i < 100; ++i) test3(foo1);
- for (int i = 0; i < 100; ++i) try { test4(bar1); } catch (...) {}
- for (int i = 0; i < 100; ++i) test5(foo1, 0);
- for (int i = 0; i < 100; ++i) try { test6(bar1, 0); } catch (...) {}
- for (int i = 0; i < 100; ++i) test7(foo2);
- for (int i = 0; i < 100; ++i) try { test8(bar2); } catch (...) {}
- for (int i = 0; i < 100; ++i) test9(foo1);
- for (int i = 0; i < 100; ++i) try { test10(bar1); } catch (...) {}
- for (int i = 0; i < 100; ++i) test11(foo1, 0);
- for (int i = 0; i < 100; ++i) try { test12(bar1, 0); } catch (...) {}
- return 0;
-}
===================================================================
@@ -1,39 +0,0 @@
-/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-tree_profile_ipa" } */
-
-struct A {
- A () {}
-
- virtual int AA (void)
- { return 0; }
-
-};
-
-struct B : public A {
- B () {}
-
- virtual int AA (void)
- { return 1; }
-};
-
-void * __attribute__((noinline,noclone)) wrap (void *p) { return p; }
-int
-main (void)
-{
- A a;
- B b;
-
- A* p;
-
- p = (A *)wrap ((void *)&a);
- p->AA ();
-
- p = (B *)wrap ((void *)&b);
- p->AA ();
-
- return 0;
-}
-
-/* { dg-final-use { scan-ipa-dump "Indirect call -> direct call.* AA " "tree_profile_ipa" } } */
-/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized" } } */
-/* { dg-final-use { cleanup-tree-dump "optimized" } } */
-/* { dg-final-use { cleanup-ipa-dump "tree_profile_ipa" } } */
===================================================================
@@ -1,54 +0,0 @@
-/* { dg-require-effective-target freorder } */
-/* { dg-options "-O2 -freorder-blocks-and-partition" } */
-/* { dg-skip-if "PR target/47683" { mips-sgi-irix* } } */
-
-struct A { A () __attribute__((noinline)); ~A () __attribute__((noinline)); };
-A::A () { asm volatile ("" : : : "memory"); }
-A::~A () { asm volatile ("" : : : "memory"); }
-
-int bar () __attribute__((noinline));
-void foo () __attribute__((noinline));
-
-volatile int k, l;
-
-int bar (int i)
-{
- void *p = __builtin_alloca (i);
- asm volatile ("" : : "r" (i), "r" (p) : "memory");
- if (k) throw 6;
- return ++l;
-}
-
-void foo ()
-{
- A a;
- try {
- A b;
- int i = bar (5);
- try { throw 6; } catch (int) {}
- if (__builtin_expect (i < 4500, 0)) {
- bar (7);
- try { bar (8); } catch (long) {}
- bar (10);
- if (__builtin_expect (i < 0, 0)) {
- try { bar (12); } catch (...) {}
- bar (16);
- bar (122);
- } else {
- try { bar (bar (7)); } catch (int) {}
- }
- } else {
- try { bar (bar (bar (9))); } catch (...) {}
- bar (5);
- }
- } catch (...) {
- }
-}
-
-int
-main ()
-{
- int i;
- for (i = 0; i < 10000; i++)
- foo ();
-}
===================================================================
@@ -1,16 +0,0 @@
-// PR middle-end/45458
-// { dg-require-effective-target freorder }
-// { dg-options "-fnon-call-exceptions -freorder-blocks-and-partition" }
-// { dg-skip-if "PR target/47683" { mips-sgi-irix* } }
-
-int
-main ()
-{
- try
- {
- throw 6;
- }
- catch (...)
- {
- }
-}
===================================================================
@@ -1,18 +0,0 @@
-// PR middle-end/45566
-// { dg-require-effective-target freorder }
-// { dg-options "-O -fnon-call-exceptions -freorder-blocks-and-partition" }
-
-int k;
-
-int
-main ()
-{
- try
- {
- if (k)
- throw 6;
- }
- catch (...)
- {
- }
-}
===================================================================
@@ -349,8 +349,17 @@ cmp_templ_arg (tree ta1, tree ta2)
if (TREE_CODE (td1) != TREE_CODE (td2))
return 0;
if (TREE_CODE (td1) == FUNCTION_DECL)
- return (cgraph_lipo_get_resolved_node (td1)
- == cgraph_lipo_get_resolved_node (td2));
+ {
+ tree id1, id2;
+
+ if (!TREE_PUBLIC (td1) || !TREE_PUBLIC (td2))
+ return td1 == td2;
+
+ id1 = DECL_ASSEMBLER_NAME (td1);
+ id2 = DECL_ASSEMBLER_NAME (td2);
+ return !strcmp (IDENTIFIER_POINTER (id1),
+ IDENTIFIER_POINTER (id2));
+ }
else
{
gcc_assert (TREE_CODE (td1) == VAR_DECL);
===================================================================
@@ -281,8 +281,18 @@ clear_module_scope_bindings (struct save
for (i = 0;
VEC_iterate (tree, module_scope->module_decls, i, decl);
++i)
- lang_hooks.l_ipo.clear_global_name_bindings (
+ {
+ lang_hooks.l_ipo.clear_global_name_bindings (
get_type_or_decl_name (decl));
+ /* Now force creating assembly name. */
+ if (VAR_OR_FUNCTION_DECL_P (decl))
+ {
+ tree assembler_name;
+
+ assembler_name = DECL_ASSEMBLER_NAME (decl);
+ lang_hooks.l_ipo.clear_global_name_bindings (assembler_name);
+ }
+ }
}
/* The referenced attribute of a decl is not associated with the
@@ -416,7 +426,10 @@ pop_module_scope (void)
/* cp_clear_conv_type_map (); */
}
else if (num_in_fnames > 1)
- restore_post_parsing_states ();
+ {
+ clear_module_scope_bindings (current_module_scope);
+ restore_post_parsing_states ();
+ }
else
gcc_assert (L_IPO_IS_PRIMARY_MODULE && num_in_fnames == 1);
}
@@ -691,6 +704,8 @@ lipo_cmp_type (tree t1, tree t2)
case VOID_TYPE:
case BOOLEAN_TYPE:
return 1;
+ case TEMPLATE_TYPE_PARM:
+ return 1;
default:
gcc_unreachable ();
}