diff options
author | Diego Novillo <dnovillo@redhat.com> | 2004-03-17 19:44:35 +0000 |
---|---|---|
committer | Diego Novillo <dnovillo@redhat.com> | 2004-03-17 19:44:35 +0000 |
commit | c7c02cd1d8a86bd42644dca2979e12ae5aa0943e (patch) | |
tree | 8e134cbc7256dd3f04eeba1be16ab2520d56f2b4 /gcc/testsuite/g++.dg | |
parent | 4334092cc2bcb3cc93c9f11f949311b19067b79e (diff) |
PR optimization/14511
* tree-ssa-alias.c (compute_flow_insensitive_aliasing): Do not
ignore read-only variables.
(may_alias_p): Fix pointer-to-var calculation when 'var' is an
array.
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/tree-ssa-20020619-branch@79599 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/g++.dg')
-rw-r--r-- | gcc/testsuite/g++.dg/README | 1 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/tree-ssa/20040317-1.C | 38 |
2 files changed, 39 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/README b/gcc/testsuite/g++.dg/README index 27f6a5a80cf..d96e8990ee3 100644 --- a/gcc/testsuite/g++.dg/README +++ b/gcc/testsuite/g++.dg/README @@ -21,6 +21,7 @@ rtti Tests for run-time type identification (typeid, dynamic_cast, etc.) special Tests requiring individual processing. template Tests for templates. tls Tests for support of thread-local data. +tree-ssa Tests for Tree SSA optimizations. warn Tests for compiler warnings. other Tests that don't fit into one of the other categories. diff --git a/gcc/testsuite/g++.dg/tree-ssa/20040317-1.C b/gcc/testsuite/g++.dg/tree-ssa/20040317-1.C new file mode 100644 index 00000000000..e2f3dcdceb8 --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-ssa/20040317-1.C @@ -0,0 +1,38 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +/* Test provided by Brian Ryner in PR 14511. The alias analyzer was + not handling structures containing arrays properly. In this case, + the static cast was introducing two assignments of the form + + this_6->_vptr.IFoo = &_ZTV4IFoo[2]; + this_4->_vptr.IFoo = &_ZTV3Bar[2]; + + which were not considered to alias each other because the alias + analyzer was not computing a proper pointer to array elements. + Another related bug was the type based alias analyzer not computing + alias relations to _ZTV4IFoo and _ZTV3Bar. Since those variables + are read-only, it was disregarding alias information for them. + So, the memory tags for the two 'this' variables were not being + marked as aliased with these variables. Resulting in the two + assignments not aliasing each other. + + This was causing the optimizers to generate a call to the virtual + method Foo() instead of the overloaded version. */ + +struct IFoo +{ + virtual void Foo() = 0; +}; + +struct Bar : IFoo +{ + void Foo() { } +}; + +int main(int argc, char **argv) +{ + Bar* b = new Bar(); + static_cast<IFoo*>(b)->Foo(); + return 0; +} |