summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXinliang David Li <davidxl@google.com>2016-01-20 00:11:36 +0000
committerXinliang David Li <davidxl@google.com>2016-01-20 00:11:36 +0000
commit69005960400a84f3c8b03f173afdad79ccd1d4a0 (patch)
treef6bf8219254e09a16a524884756a80287f0c8c7d
parent16901a3e200af39e1ea8ef44db7359ef9417917e (diff)
downloadbcm5719-llvm-69005960400a84f3c8b03f173afdad79ccd1d4a0.tar.gz
bcm5719-llvm-69005960400a84f3c8b03f173afdad79ccd1d4a0.zip
[coverage] Add a test case to cover coverage testing with comdat
llvm-svn: 258255
-rw-r--r--compiler-rt/test/profile/Inputs/instrprof-comdat-1.cpp17
-rw-r--r--compiler-rt/test/profile/Inputs/instrprof-comdat-2.cpp12
-rw-r--r--compiler-rt/test/profile/Inputs/instrprof-comdat.h19
-rw-r--r--compiler-rt/test/profile/instrprof-comdat.test6
4 files changed, 54 insertions, 0 deletions
diff --git a/compiler-rt/test/profile/Inputs/instrprof-comdat-1.cpp b/compiler-rt/test/profile/Inputs/instrprof-comdat-1.cpp
new file mode 100644
index 00000000000..bd574ec3fb8
--- /dev/null
+++ b/compiler-rt/test/profile/Inputs/instrprof-comdat-1.cpp
@@ -0,0 +1,17 @@
+#include "instrprof-comdat.h"
+int g;
+extern int bar(int);
+
+int main() {
+
+ FOO<int> Foo;
+
+ int Res = Foo.DoIt(10);
+
+ if (Res > 10)
+ g = bar(10);
+ else
+ g = bar(1) + bar(2);
+ return 0;
+}
+
diff --git a/compiler-rt/test/profile/Inputs/instrprof-comdat-2.cpp b/compiler-rt/test/profile/Inputs/instrprof-comdat-2.cpp
new file mode 100644
index 00000000000..ce68d54e8c5
--- /dev/null
+++ b/compiler-rt/test/profile/Inputs/instrprof-comdat-2.cpp
@@ -0,0 +1,12 @@
+#include "instrprof-comdat.h"
+
+int bar(int I) {
+
+ FOO<long> Foo;
+ FOO<int> Foo2;
+
+ if (I > 5)
+ return (int)Foo.DoIt(10);
+ else
+ return (int)Foo2.DoIt(I);
+}
diff --git a/compiler-rt/test/profile/Inputs/instrprof-comdat.h b/compiler-rt/test/profile/Inputs/instrprof-comdat.h
new file mode 100644
index 00000000000..e1227167cd4
--- /dev/null
+++ b/compiler-rt/test/profile/Inputs/instrprof-comdat.h
@@ -0,0 +1,19 @@
+template <class T> class FOO {
+public:
+ FOO() : t(0) {}
+
+ T DoIt(T ti);
+
+private:
+ T t;
+};
+
+template <class T> T FOO<T>::DoIt(T ti) { // HEADER: 2| [[@LINE]]|template
+ for (T I = 0; I < ti; I++) { // HEADER: 22| [[@LINE]]| for (T
+ t += I; // HEADER: 20| [[@LINE]]| t += I;
+ if (I > ti / 2) // HEADER: 20| [[@LINE]]| if (I > ti
+ t -= 1; // HEADER: 8| [[@LINE]]| t -= 1;
+ } // HEADER: 10| [[@LINE]]| }
+ // HEADER: 1| [[@LINE]]|
+ return t; // HEADER: 1| [[@LINE]]| return t;
+}
diff --git a/compiler-rt/test/profile/instrprof-comdat.test b/compiler-rt/test/profile/instrprof-comdat.test
new file mode 100644
index 00000000000..ea20da55725
--- /dev/null
+++ b/compiler-rt/test/profile/instrprof-comdat.test
@@ -0,0 +1,6 @@
+RUN: mkdir -p %t.d
+RUN: %clang_profgen -xc++ -o %t.d/comdat -fcoverage-mapping %S/Inputs/instrprof-comdat-1.cpp %S/Inputs/instrprof-comdat-2.cpp
+RUN: LLVM_PROFILE_FILE=%t-comdat.profraw %t.d/comdat
+RUN: llvm-profdata merge -o %t.d/comdat.prof %t-comdat.profraw
+RUN: llvm-cov show --filename-equivalence --instr-profile=%t.d/comdat.prof %t.d/comdat | FileCheck --check-prefix=HEADER %S/Inputs/instrprof-comdat.h
+
OpenPOWER on IntegriCloud