diff options
Diffstat (limited to 'gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo')
15 files changed, 226 insertions, 1 deletions
diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/buildinfo.txt b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/buildinfo.txt new file mode 100644 index 0000000..c7a82f7 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/buildinfo.txt @@ -0,0 +1 @@ +Test -fprofile-generate-buildinfo option diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/comdat_fixup.h b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/comdat_fixup.h new file mode 100644 index 0000000..bf28164 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/comdat_fixup.h @@ -0,0 +1,5 @@ +class Foo +{ + public: + int foo(int x) { return x; } +}; diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/comdat_fixup_0.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/comdat_fixup_0.C new file mode 100644 index 0000000..7743a0b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/comdat_fixup_0.C @@ -0,0 +1,9 @@ +/* { dg-options "-O2 -fno-inline -fprofile-generate-buildinfo=$srcdir/g++.dg/tree-prof/lipo/buildinfo.txt" } */ +#include <stdio.h> + +extern int foo1(int x); +extern int foo2(int x); +int main() +{ + printf ("Result = %d\n", foo1(1) + foo2(1)); +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/comdat_fixup_1.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/comdat_fixup_1.C new file mode 100644 index 0000000..5f24dc1 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/comdat_fixup_1.C @@ -0,0 +1,7 @@ +/* { dg-options "-O2 -fno-inline" } */ +#include "comdat_fixup.h" +int foo1(int x) +{ + Foo f; + return f.foo(x); +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/comdat_fixup_2.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/comdat_fixup_2.C new file mode 100644 index 0000000..1416129 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/comdat_fixup_2.C @@ -0,0 +1,7 @@ +/* { dg-options "-O2 -fno-inline" } */ +#include "comdat_fixup.h" +int foo2(int x) +{ + Foo f; + return f.foo(x); +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/indir-call-prof_0.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/indir-call-prof_0.C index b34b937..78fd0c5 100644 --- a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/indir-call-prof_0.C +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/indir-call-prof_0.C @@ -1,4 +1,4 @@ -/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile" } */ +/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile --param=lipo-sampling-period=1" } */ struct A { A () {} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/static1_0.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/static1_0.C new file mode 100644 index 0000000..525480d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/static1_0.C @@ -0,0 +1,48 @@ +// { dg-options "-std=c++11 -O2" } + +// A test case for static var promotion on targets like powerpc, where +// the static initializer data is loaded via indirection through +// TOC. Ensure that the global label for static initializer data is +// unique via *.cmo* suffix. + +// Bug: after static var promotion in two different modules, we have +// the following which leads to multiple definition of ._41" error during +// link time. + +// Module 1 Module 2 +// .hidden ._41.cmo.1 .hidden ._41.cmo.3 +// .globl ._41 .globl ._41 +// ._41: ._41: +// ... ... + + +// Instead we should use the appropriate unique names for initializer +// data as in the following. + +// Module 1 Module 2 +// .hidden ._41.cmo.1 .hidden ._41.cmo.3 +// .globl ._41.cmo.1 .globl ._41.cmo.3 +// ._41.cmo.1: ._41.cmo.3: +// ... ... + +class A { + public: + int f(int x) const; +}; + +class B { + public: + int f(int x) const; +}; + +int main() +{ + A *a = new A(); + B *b = new B(); + int total = 0; + for (int i=0; i<3; ++i) { + total += a->f(1); + total += b->f(1); + } + return (total > 0) ? 0 : 1; +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/static1_1.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/static1_1.C new file mode 100644 index 0000000..0236e16 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/static1_1.C @@ -0,0 +1,14 @@ +/* { dg-options "-std=c++11 -O2" } */ + +#include <vector> + +class A { + public: + int f(int x) const; +}; + +static const std::vector<int> point1_{42}; + +int A::f(int x) const { + return x+1; +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/static1_2.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/static1_2.C new file mode 100644 index 0000000..d39095d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/static1_2.C @@ -0,0 +1,14 @@ +/* { dg-options "-std=c++11 -O2" } */ + +#include <vector> + +class B { + public: + int f(int x) const; +}; + +static const std::vector<int> point2_{43}; + +int B::f(int x) const { + return x+1; +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/tls.h b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/tls.h new file mode 100644 index 0000000..5eb102d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/tls.h @@ -0,0 +1,16 @@ +extern int NextId(); + +class TLSClass { + public: + TLSClass() { + id = NextId(); + bar = 1; + } + ~TLSClass() {} + int id; + int bar; +}; +extern TLSClass* NextTLSClass(); +extern void *SetTLSClass(TLSClass *a); +extern TLSClass *GetTLSClass(); +extern thread_local TLSClass* current_tls_; diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/tls2.h b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/tls2.h new file mode 100644 index 0000000..9ba0945 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/tls2.h @@ -0,0 +1,15 @@ +extern int NextId(); + +class TLSClass { + public: + TLSClass() { + id = NextId(); + bar = 1; + } + ~TLSClass() {} + int id; + int bar; +}; +extern TLSClass* NextTLSClass(); +extern void *SetTLSClass(TLSClass *a); +extern TLSClass *GetTLSClass(); diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/tls2_0.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/tls2_0.C new file mode 100644 index 0000000..9ccd5b9 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/tls2_0.C @@ -0,0 +1,10 @@ +// { dg-options "-std=c++11 -O2 --param=lipo-sampling-period=1" } +#include "tls2.h" + +static thread_local TLSClass* current_tls_ = NextTLSClass(); +void *SetTLSClass(TLSClass *a) { + current_tls_ = a; +} +TLSClass *GetTLSClass() { + return current_tls_; +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/tls2_1.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/tls2_1.C new file mode 100644 index 0000000..43c1085 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/tls2_1.C @@ -0,0 +1,31 @@ +// { dg-options "-std=c++11 -O2 --param=lipo-sampling-period=1" } +#include <stdio.h> +#include <stdlib.h> +#include <new> +#include "tls2.h" +TLSClass* NextTLSClass() { + return new TLSClass(); +} +int NextId() { + static int id = 0; + return id++; +} +static thread_local TLSClass* current_tls2_ = NextTLSClass(); +void *SetTLSClass2(TLSClass *a) { + current_tls2_ = a; +} +int main() { + int i = 0; + if (GetTLSClass()->id != i++) + abort(); + TLSClass *A = NextTLSClass(); + SetTLSClass(A); + if (GetTLSClass()->id != i++) + abort(); + if (current_tls2_->id != i++) + abort(); + A = NextTLSClass(); + SetTLSClass2(A); + if (current_tls2_->id != i++) + abort(); +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/tls_0.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/tls_0.C new file mode 100644 index 0000000..f3e5e37 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/tls_0.C @@ -0,0 +1,10 @@ +// { dg-options "-std=c++11 -O2 --param=lipo-sampling-period=1" } +#include "tls.h" + +thread_local TLSClass* current_tls_ = NextTLSClass(); +void *SetTLSClass(TLSClass *a) { + current_tls_ = a; +} +TLSClass *GetTLSClass() { + return current_tls_; +} diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/tls_1.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/tls_1.C new file mode 100644 index 0000000..fcf8c21 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/tls_1.C @@ -0,0 +1,38 @@ +// { dg-options "-std=c++11 -O2 --param=lipo-sampling-period=1" } +#include <stdio.h> +#include <stdlib.h> +#include <new> +#include "tls.h" +TLSClass* NextTLSClass() { + return new TLSClass(); +} +int NextId() { + static int id = 0; + return id++; +} +void *SetTLSClassHere(TLSClass *a) { + current_tls_ = a; +} +thread_local TLSClass* current_tls2_ = NextTLSClass(); +void *SetTLSClass2(TLSClass *a) { + current_tls2_ = a; +} +int main() { + int i = 0; + if (GetTLSClass()->id != i++) + abort(); + TLSClass *A = NextTLSClass(); + SetTLSClass(A); + if (GetTLSClass()->id != i++) + abort(); + A = NextTLSClass(); + SetTLSClassHere(A); + if (GetTLSClass()->id != i++) + abort(); + if (current_tls2_->id != i++) + abort(); + A = NextTLSClass(); + SetTLSClass2(A); + if (current_tls2_->id != i++) + abort(); +} |