Patchwork [google] Multiple source LIPO test cases and bug fixes (issue4441084)

login
register
mail settings
Submitter Xinliang David Li
Date May 2, 2011, 5:18 a.m.
Message ID <20110502051843.4D2CA20401@syzygy.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/93589/
State New
Headers show

Comments

Xinliang David Li - May 2, 2011, 5:18 a.m.
Hi, the following patch will be committed to google/main. The patch added multiple
source file support for FDO and a couple of multi-source test cases for LIPO. It
also include a couple of bug fixes related to missing assembler name binding cleanup.

regression test and SPEC with LIPO.

David

2011-05-01  David Li  <davidxl@google.com>

	* testsuite/lib/profopt.exp (proc): Multiple source file support.
	* testsuite/gcc.dg/tree-prof/lipo/lipo.exp (load_lib):
	Multiple source file support.
	* testsuite/g++.dg/tree-prof/lipo/lipo.exp: Ditto.
	* testsuite/gcc.dg/tree-prof/lipo/indir-call-prof_0.c: New test.
	* testsuite/gcc.dg/tree-prof/lipo/indir-call-prof_1.c: New test.
	* testsuite/gcc.dg/tree-prof/lipo/lipo_inline1_0.c: New test.
	* testsuite/gcc.dg/tree-prof/lipo/lipo_inline1_1.c: New test.
	* testsuite/gcc.dg/tree-prof/lipo/lipo_inline1_2.c: New test.
	* testsuite/g++.dg/tree-prof/lipo/vcall1_0.c: New test.
	* testsuite/g++.dg/tree-prof/lipo/vcall1_1.c: New test.
	* testsuite/g++.dg/tree-prof/lipo/vcall1_2.c: New test.
	* testsuite/gcc.dg/tree-prof/lipo/inliner-1.c: Rename.
	* testsuite/gcc.dg/tree-prof/lipo/stringop-1.c: Ditto.
	* testsuite/gcc.dg/tree-prof/lipo/update-loopch.c: Ditto.
	* testsuite/gcc.dg/tree-prof/lipo/stringop-2.: Ditto.
	* testsuite/gcc.dg/tree-prof/lipo/ic-misattribution-1.c: Ditto.
	* testsuite/gcc.dg/tree-prof/lipo/update-tailcall.c: Ditto.
	* testsuite/gcc.dg/tree-prof/lipo/ic-misattribution-1a.c: Ditto.
	* testsuite/gcc.dg/tree-prof/lipo/tracer-1.c: Ditto.
	* testsuite/gcc.dg/tree-prof/lipo/indir-call-prof.c: Ditto.
	* testsuite/gcc.dg/tree-prof/lipo/val-prof-1.c: Ditto.
	* testsuite/gcc.dg/tree-prof/lipo/val-prof-2.c: Ditto.
	* testsuite/gcc.dg/tree-prof/lipo/val-prof-3.c: Ditto.
	* testsuite/gcc.dg/tree-prof/lipo/val-prof-4.c: Ditto.
	* testsuite/gcc.dg/tree-prof/lipo/val-prof-5.c: Ditto.
	* testsuite/gcc.dg/tree-prof/lipo/val-prof-6.c: Ditto.
	* testsuite/gcc.dg/tree-prof/lipo/val-prof-7.c: Ditto.
	* testsuite/gcc.dg/tree-prof/lipo/pr47187.c: Ditto.
	* testsuite/gcc.dg/tree-prof/lipo/update-cunroll-2.c: Ditto.
	* testsuite/gcc.dg/tree-prof/lipo/bb-reorg.c: Ditto.
	* testsuite/gcc.dg/tree-prof/lipo/pr34999.c: Ditto.
	* testsuite/gcc.dg/tree-prof/lipo/ic-misattribution-1_0.c: Ditto.
	* testsuite/gcc.dg/tree-prof/lipo/ic-misattribution-1_1.c: Ditto.
	* testsuite/gcc.dg/tree-prof/lipo/wcoverage-mismatch.c: Ditto.
	* testsuite/gcc.dg/tree-prof/lipo/pr45354.c: Ditto.
	* testsuite/g++.dg/tree-prof/lipo/inline_mismatch_args.C: Ditto.
	* testsuite/g++.dg/tree-prof/lipo/indir-call-prof-2.C: Ditto.
	* testsuite/g++.dg/tree-prof/lipo/indir-call-prof.C: Ditto.
	* testsuite/g++.dg/tree-prof/lipo/partition1.C: Ditto.
	* testsuite/g++.dg/tree-prof/lipo/partition2.C: Ditto.
	* testsuite/g++.dg/tree-prof/lipo/partition3.C: Ditto.
	* cp/cp-objcp-common.c (cmp_templ_arg): Use assembler name for
	decl comparison.
	* l-ipo.c (clear_module_scope_bindings): Clear name binding for
	assembler name.
	(pop_module_scope): Clear name bindings for the last module.
	(lipo_cmp_type): Handle template arg type.


--
This patch is available for review at http://codereview.appspot.com/4441084
Rainer Orth - May 2, 2011, 9:03 a.m.
David,

> 2011-05-01  David Li  <davidxl@google.com>
>
> 	* testsuite/lib/profopt.exp (proc): Multiple source file support.
                                     ^

This is wrong, the proc is called profopt-execute.

> 	* testsuite/gcc.dg/tree-prof/lipo/lipo.exp (load_lib):
                                                    ^
> 	Multiple source file support.

Wrong again: not inside any proc.  Just omit.

	Rainer
Xinliang David Li - May 2, 2011, 3:51 p.m.
thanks. Will correct.

David

On Mon, May 2, 2011 at 2:03 AM, Rainer Orth <ro@cebitec.uni-bielefeld.de> wrote:
> David,
>
>> 2011-05-01  David Li  <davidxl@google.com>
>>
>>       * testsuite/lib/profopt.exp (proc): Multiple source file support.
>                                     ^
>
> This is wrong, the proc is called profopt-execute.
>
>>       * testsuite/gcc.dg/tree-prof/lipo/lipo.exp (load_lib):
>                                                    ^
>>       Multiple source file support.
>
> Wrong again: not inside any proc.  Just omit.
>
>        Rainer
>
> --
> -----------------------------------------------------------------------------
> Rainer Orth, Center for Biotechnology, Bielefeld University
>

Patch

Index: testsuite/lib/profopt.exp
===================================================================
--- testsuite/lib/profopt.exp	(revision 173148)
+++ testsuite/lib/profopt.exp	(working copy)
@@ -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"
Index: testsuite/gcc.dg/tree-prof/lipo/inliner-1.c
===================================================================
--- testsuite/gcc.dg/tree-prof/lipo/inliner-1.c	(revision 173148)
+++ testsuite/gcc.dg/tree-prof/lipo/inliner-1.c	(working copy)
@@ -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" } } */
Index: testsuite/gcc.dg/tree-prof/lipo/gdb_cmd
===================================================================
--- testsuite/gcc.dg/tree-prof/lipo/gdb_cmd	(revision 173148)
+++ testsuite/gcc.dg/tree-prof/lipo/gdb_cmd	(working copy)
@@ -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
Index: testsuite/gcc.dg/tree-prof/lipo/indir-call-prof_0.c
===================================================================
--- testsuite/gcc.dg/tree-prof/lipo/indir-call-prof_0.c	(revision 0)
+++ testsuite/gcc.dg/tree-prof/lipo/indir-call-prof_0.c	(revision 0)
@@ -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" } } */
Index: testsuite/gcc.dg/tree-prof/lipo/indir-call-prof_1.c
===================================================================
--- testsuite/gcc.dg/tree-prof/lipo/indir-call-prof_1.c	(revision 0)
+++ testsuite/gcc.dg/tree-prof/lipo/indir-call-prof_1.c	(revision 0)
@@ -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];
+}
Index: testsuite/gcc.dg/tree-prof/lipo/stringop-1.c
===================================================================
--- testsuite/gcc.dg/tree-prof/lipo/stringop-1.c	(revision 173148)
+++ testsuite/gcc.dg/tree-prof/lipo/stringop-1.c	(working copy)
@@ -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" } } */
Index: testsuite/gcc.dg/tree-prof/lipo/update-loopch.c
===================================================================
--- testsuite/gcc.dg/tree-prof/lipo/update-loopch.c	(revision 173148)
+++ testsuite/gcc.dg/tree-prof/lipo/update-loopch.c	(working copy)
@@ -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" } } */
Index: testsuite/gcc.dg/tree-prof/lipo/stringop-2.c
===================================================================
--- testsuite/gcc.dg/tree-prof/lipo/stringop-2.c	(revision 173148)
+++ testsuite/gcc.dg/tree-prof/lipo/stringop-2.c	(working copy)
@@ -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" } } */
Index: testsuite/gcc.dg/tree-prof/lipo/ic-misattribution-1.c
===================================================================
--- testsuite/gcc.dg/tree-prof/lipo/ic-misattribution-1.c	(revision 173148)
+++ testsuite/gcc.dg/tree-prof/lipo/ic-misattribution-1.c	(working copy)
@@ -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" } } */
Index: testsuite/gcc.dg/tree-prof/lipo/update-tailcall.c
===================================================================
--- testsuite/gcc.dg/tree-prof/lipo/update-tailcall.c	(revision 173148)
+++ testsuite/gcc.dg/tree-prof/lipo/update-tailcall.c	(working copy)
@@ -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" } } */
Index: testsuite/gcc.dg/tree-prof/lipo/ic-misattribution-1a.c
===================================================================
--- testsuite/gcc.dg/tree-prof/lipo/ic-misattribution-1a.c	(revision 173148)
+++ testsuite/gcc.dg/tree-prof/lipo/ic-misattribution-1a.c	(working copy)
@@ -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" } } */
Index: testsuite/gcc.dg/tree-prof/lipo/tracer-1.c
===================================================================
--- testsuite/gcc.dg/tree-prof/lipo/tracer-1.c	(revision 173148)
+++ testsuite/gcc.dg/tree-prof/lipo/tracer-1.c	(working copy)
@@ -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" } } */
Index: testsuite/gcc.dg/tree-prof/lipo/indir-call-prof.c
===================================================================
--- testsuite/gcc.dg/tree-prof/lipo/indir-call-prof.c	(revision 173148)
+++ testsuite/gcc.dg/tree-prof/lipo/indir-call-prof.c	(working copy)
@@ -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" } } */
Index: testsuite/gcc.dg/tree-prof/lipo/val-prof-1.c
===================================================================
--- testsuite/gcc.dg/tree-prof/lipo/val-prof-1.c	(revision 173148)
+++ testsuite/gcc.dg/tree-prof/lipo/val-prof-1.c	(working copy)
@@ -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" } } */
Index: testsuite/gcc.dg/tree-prof/lipo/val-prof-2.c
===================================================================
--- testsuite/gcc.dg/tree-prof/lipo/val-prof-2.c	(revision 173148)
+++ testsuite/gcc.dg/tree-prof/lipo/val-prof-2.c	(working copy)
@@ -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" } } */
Index: testsuite/gcc.dg/tree-prof/lipo/val-prof-3.c
===================================================================
--- testsuite/gcc.dg/tree-prof/lipo/val-prof-3.c	(revision 173148)
+++ testsuite/gcc.dg/tree-prof/lipo/val-prof-3.c	(working copy)
@@ -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" } } */
Index: testsuite/gcc.dg/tree-prof/lipo/val-prof-4.c
===================================================================
--- testsuite/gcc.dg/tree-prof/lipo/val-prof-4.c	(revision 173148)
+++ testsuite/gcc.dg/tree-prof/lipo/val-prof-4.c	(working copy)
@@ -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" } } */
Index: testsuite/gcc.dg/tree-prof/lipo/val-prof-5.c
===================================================================
--- testsuite/gcc.dg/tree-prof/lipo/val-prof-5.c	(revision 173148)
+++ testsuite/gcc.dg/tree-prof/lipo/val-prof-5.c	(working copy)
@@ -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" } } */
Index: testsuite/gcc.dg/tree-prof/lipo/val-prof-6.c
===================================================================
--- testsuite/gcc.dg/tree-prof/lipo/val-prof-6.c	(revision 173148)
+++ testsuite/gcc.dg/tree-prof/lipo/val-prof-6.c	(working copy)
@@ -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" } } */
Index: testsuite/gcc.dg/tree-prof/lipo/val-prof-7.c
===================================================================
--- testsuite/gcc.dg/tree-prof/lipo/val-prof-7.c	(revision 173148)
+++ testsuite/gcc.dg/tree-prof/lipo/val-prof-7.c	(working copy)
@@ -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" } } */
Index: testsuite/gcc.dg/tree-prof/lipo/pr47187.c
===================================================================
--- testsuite/gcc.dg/tree-prof/lipo/pr47187.c	(revision 173148)
+++ testsuite/gcc.dg/tree-prof/lipo/pr47187.c	(working copy)
@@ -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;
-}
Index: testsuite/gcc.dg/tree-prof/lipo/update-cunroll-2.c
===================================================================
--- testsuite/gcc.dg/tree-prof/lipo/update-cunroll-2.c	(revision 173148)
+++ testsuite/gcc.dg/tree-prof/lipo/update-cunroll-2.c	(working copy)
@@ -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" } } */
Index: testsuite/gcc.dg/tree-prof/lipo/bb-reorg.c
===================================================================
--- testsuite/gcc.dg/tree-prof/lipo/bb-reorg.c	(revision 173148)
+++ testsuite/gcc.dg/tree-prof/lipo/bb-reorg.c	(working copy)
@@ -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; 
-}
-
Index: testsuite/gcc.dg/tree-prof/lipo/lipo_inline1_0.c
===================================================================
--- testsuite/gcc.dg/tree-prof/lipo/lipo_inline1_0.c	(revision 0)
+++ testsuite/gcc.dg/tree-prof/lipo/lipo_inline1_0.c	(revision 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" } } */
Index: testsuite/gcc.dg/tree-prof/lipo/lipo_inline1_1.c
===================================================================
--- testsuite/gcc.dg/tree-prof/lipo/lipo_inline1_1.c	(revision 0)
+++ testsuite/gcc.dg/tree-prof/lipo/lipo_inline1_1.c	(revision 0)
@@ -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" } } */
Index: testsuite/gcc.dg/tree-prof/lipo/pr34999.c
===================================================================
--- testsuite/gcc.dg/tree-prof/lipo/pr34999.c	(revision 173148)
+++ testsuite/gcc.dg/tree-prof/lipo/pr34999.c	(working copy)
@@ -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 ();
-  }
-}
-
Index: testsuite/gcc.dg/tree-prof/lipo/lipo_inline1_2.c
===================================================================
--- testsuite/gcc.dg/tree-prof/lipo/lipo_inline1_2.c	(revision 0)
+++ testsuite/gcc.dg/tree-prof/lipo/lipo_inline1_2.c	(revision 0)
@@ -0,0 +1,6 @@ 
+int blah (void)
+{
+  return 2;
+}
+
+/* { dg-final-use { cleanup-tree-dump "optimized" } } */
Index: testsuite/gcc.dg/tree-prof/lipo/lipo.exp
===================================================================
--- testsuite/gcc.dg/tree-prof/lipo/lipo.exp	(revision 173148)
+++ testsuite/gcc.dg/tree-prof/lipo/lipo.exp	(working copy)
@@ -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
Index: testsuite/gcc.dg/tree-prof/lipo/ic-misattribution-1_0.c
===================================================================
--- testsuite/gcc.dg/tree-prof/lipo/ic-misattribution-1_0.c	(revision 173148)
+++ testsuite/gcc.dg/tree-prof/lipo/ic-misattribution-1_0.c	(working copy)
@@ -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" } } */
Index: testsuite/gcc.dg/tree-prof/lipo/ic-misattribution-1_1.c
===================================================================
--- testsuite/gcc.dg/tree-prof/lipo/ic-misattribution-1_1.c	(revision 173148)
+++ testsuite/gcc.dg/tree-prof/lipo/ic-misattribution-1_1.c	(working copy)
@@ -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" } } */
Index: testsuite/gcc.dg/tree-prof/lipo/wcoverage-mismatch.c
===================================================================
--- testsuite/gcc.dg/tree-prof/lipo/wcoverage-mismatch.c	(revision 173148)
+++ testsuite/gcc.dg/tree-prof/lipo/wcoverage-mismatch.c	(working copy)
@@ -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;
-}
Index: testsuite/gcc.dg/tree-prof/lipo/pr45354.c
===================================================================
--- testsuite/gcc.dg/tree-prof/lipo/pr45354.c	(revision 173148)
+++ testsuite/gcc.dg/tree-prof/lipo/pr45354.c	(working copy)
@@ -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;
-}
Index: testsuite/g++.dg/tree-prof/lipo/vcall1_0.C
===================================================================
--- testsuite/g++.dg/tree-prof/lipo/vcall1_0.C	(revision 0)
+++ testsuite/g++.dg/tree-prof/lipo/vcall1_0.C	(revision 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" } } */
Index: testsuite/g++.dg/tree-prof/lipo/vcall1_1.C
===================================================================
--- testsuite/g++.dg/tree-prof/lipo/vcall1_1.C	(revision 0)
+++ testsuite/g++.dg/tree-prof/lipo/vcall1_1.C	(revision 0)
@@ -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;
+}
Index: testsuite/g++.dg/tree-prof/lipo/vcall1_2.C
===================================================================
--- testsuite/g++.dg/tree-prof/lipo/vcall1_2.C	(revision 0)
+++ testsuite/g++.dg/tree-prof/lipo/vcall1_2.C	(revision 0)
@@ -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;
+}
Index: testsuite/g++.dg/tree-prof/lipo/lipo.exp
===================================================================
--- testsuite/g++.dg/tree-prof/lipo/lipo.exp	(revision 173148)
+++ testsuite/g++.dg/tree-prof/lipo/lipo.exp	(working copy)
@@ -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
Index: testsuite/g++.dg/tree-prof/lipo/inline_mismatch_args.C
===================================================================
--- testsuite/g++.dg/tree-prof/lipo/inline_mismatch_args.C	(revision 173148)
+++ testsuite/g++.dg/tree-prof/lipo/inline_mismatch_args.C	(working copy)
@@ -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" } } */
Index: testsuite/g++.dg/tree-prof/lipo/indir-call-prof-2.C
===================================================================
--- testsuite/g++.dg/tree-prof/lipo/indir-call-prof-2.C	(revision 173148)
+++ testsuite/g++.dg/tree-prof/lipo/indir-call-prof-2.C	(working copy)
@@ -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;
-}
Index: testsuite/g++.dg/tree-prof/lipo/indir-call-prof.C
===================================================================
--- testsuite/g++.dg/tree-prof/lipo/indir-call-prof.C	(revision 173148)
+++ testsuite/g++.dg/tree-prof/lipo/indir-call-prof.C	(working copy)
@@ -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" } } */
Index: testsuite/g++.dg/tree-prof/lipo/partition1.C
===================================================================
--- testsuite/g++.dg/tree-prof/lipo/partition1.C	(revision 173148)
+++ testsuite/g++.dg/tree-prof/lipo/partition1.C	(working copy)
@@ -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 ();
-}
Index: testsuite/g++.dg/tree-prof/lipo/partition2.C
===================================================================
--- testsuite/g++.dg/tree-prof/lipo/partition2.C	(revision 173148)
+++ testsuite/g++.dg/tree-prof/lipo/partition2.C	(working copy)
@@ -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 (...)
-  {
-  }
-}
Index: testsuite/g++.dg/tree-prof/lipo/partition3.C
===================================================================
--- testsuite/g++.dg/tree-prof/lipo/partition3.C	(revision 173148)
+++ testsuite/g++.dg/tree-prof/lipo/partition3.C	(working copy)
@@ -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 (...)
-  {
-  }
-}
Index: cp/cp-objcp-common.c
===================================================================
--- cp/cp-objcp-common.c	(revision 173148)
+++ cp/cp-objcp-common.c	(working copy)
@@ -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);
Index: l-ipo.c
===================================================================
--- l-ipo.c	(revision 173148)
+++ l-ipo.c	(working copy)
@@ -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 ();
     }