PR tree-optimization/45605

H.J. Lu hjl.tools@gmail.com
Mon Sep 20 19:18:00 GMT 2010


On Thu, Sep 16, 2010 at 4:48 PM, Jan Hubicka <hubicka@ucw.cz> wrote:
> Hi,
> this patch fixes missed devirtualization seen in the attached testcase.
> (shamelessly stolen from the testsuite).
>
> The problem is that we never actually try to fold the statement at gimple level
> and thus we never try gimple_fold_obj_type_ref_known_binfo.  Adding it to
> gimple_fold_obj_type_ref_known_binfo does not solve the problem since
> gimple_fold_obj_type_ref_known_binfo.  returns NULL.
>
> This is because of code I added into it to prevent referring static function
> from other ltrans units.  We call the function too early and cgraph is not built
> yet and consequently it thinks function is not there.
>
> This patch adds static_object_in_other_unit_p that has fixed logic of detecting
> this case and combine it with the other problem I encounter with my folding patch,
> where we pick up values from external vtables that reffer to external static variables.
> C++ represent these with EXTERN and STATIC flags together.
>
> The patch saves whopping 300 bytes on Mozilla binnary ;)
>
> Bootstrapped/regtested x86_64-linux, OK?
>
>
> /* { dg-do compile } */
> /* { dg-options "-O1 -fdump-tree-ssa" } */
>
> extern "C" { void abort(); }
>
> struct A
> {
>  int d;
>
>  A ()                     { d = 123; }
>  A (const A & o)          { d = o.d;  }
>  A (volatile const A & o) { d = o.d + 2; }
> };
>
> A bar()
> {
>  volatile A l;
>  return l;
> }
>
> main()
> {
>  A a = bar ();
>
>  if (a.d != 125)
>    abort();
>
>  return 0;
> }
> /* We should devirtualize call to D::Run */
> /* { dg-final { scan-tree-dump-times "D::Run (" 1 "ssa"} } */
> /* { dg-final { cleanup-tree-dump "ssa" } } */
>

I got

ERROR: g++.dg/tree-ssa/pr45605.C: error executing dg-final: couldn't
compile regular expression pattern: parentheses () not balanced

I checked in the enclosed patch.


H.J.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 6dac3e5..8316803 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2010-09-20  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* g++.dg/tree-ssa/pr45605.C: Add "\\".
+
 2010-09-20  Richard Guenther  <rguenther@suse.de>

 	PR middle-end/45704
diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr45605.C
b/gcc/testsuite/g++.dg/tree-ssa/pr45605.C
index b47f91a..20c4ba8 100644
--- a/gcc/testsuite/g++.dg/tree-ssa/pr45605.C
+++ b/gcc/testsuite/g++.dg/tree-ssa/pr45605.C
@@ -33,5 +33,5 @@ int main() {


 /* We should devirtualize call to D::Run */
-/* { dg-final { scan-tree-dump-times "D::Run (" 1 "ssa"} } */
+/* { dg-final { scan-tree-dump-times "D::Run \\(" 1 "ssa"} } */
 /* { dg-final { cleanup-tree-dump "ssa" } } */



More information about the Gcc-patches mailing list