[compiler-rt] r262161 - [PGO] add a test for available_externally functions

Xinliang David Li via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 27 16:45:14 PST 2016


Author: davidxl
Date: Sat Feb 27 18:45:13 2016
New Revision: 262161

URL: http://llvm.org/viewvc/llvm-project?rev=262161&view=rev
Log:
[PGO] add a test for available_externally functions

Added:
    compiler-rt/trunk/test/profile/Inputs/extern_template.cpp
    compiler-rt/trunk/test/profile/Inputs/extern_template.h
    compiler-rt/trunk/test/profile/Inputs/extern_template1.cpp
    compiler-rt/trunk/test/profile/Inputs/extern_template2.cpp
    compiler-rt/trunk/test/profile/Linux/extern_template.test

Added: compiler-rt/trunk/test/profile/Inputs/extern_template.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/profile/Inputs/extern_template.cpp?rev=262161&view=auto
==============================================================================
--- compiler-rt/trunk/test/profile/Inputs/extern_template.cpp (added)
+++ compiler-rt/trunk/test/profile/Inputs/extern_template.cpp Sat Feb 27 18:45:13 2016
@@ -0,0 +1,14 @@
+#define DEF
+#include "extern_template.h"
+#undef DEF
+extern int bar();
+extern int foo();
+extern Test<int> TO;
+int main() {
+  foo();
+  int R = bar();
+
+  if (R != 10)
+    return 1;
+  return 0;
+}

Added: compiler-rt/trunk/test/profile/Inputs/extern_template.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/profile/Inputs/extern_template.h?rev=262161&view=auto
==============================================================================
--- compiler-rt/trunk/test/profile/Inputs/extern_template.h (added)
+++ compiler-rt/trunk/test/profile/Inputs/extern_template.h Sat Feb 27 18:45:13 2016
@@ -0,0 +1,17 @@
+template <typename T> struct Test {
+  Test() : M(10) {}
+  void doIt(int N) { // CHECK: 2| [[@LINE]]|  void doIt
+    if (N > 10) {    // CHECK: 2| [[@LINE]]|    if (N > 10) {
+      M += 2;        // CHECK: 1| [[@LINE]]|      M += 2;
+    } else           // CHECK: 1| [[@LINE]]|    } else
+      M -= 2;        // CHECK: 1| [[@LINE]]|      M -= 2;
+  }
+  T M;
+};
+
+#ifdef USE
+extern template struct Test<int>;
+#endif
+#ifdef DEF
+template struct Test<int>;
+#endif

Added: compiler-rt/trunk/test/profile/Inputs/extern_template1.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/profile/Inputs/extern_template1.cpp?rev=262161&view=auto
==============================================================================
--- compiler-rt/trunk/test/profile/Inputs/extern_template1.cpp (added)
+++ compiler-rt/trunk/test/profile/Inputs/extern_template1.cpp Sat Feb 27 18:45:13 2016
@@ -0,0 +1,9 @@
+#define USE
+#include "extern_template.h"
+#undef USE
+
+Test<int> TO;
+int foo() {
+  TO.doIt(20);
+  return TO.M;
+}

Added: compiler-rt/trunk/test/profile/Inputs/extern_template2.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/profile/Inputs/extern_template2.cpp?rev=262161&view=auto
==============================================================================
--- compiler-rt/trunk/test/profile/Inputs/extern_template2.cpp (added)
+++ compiler-rt/trunk/test/profile/Inputs/extern_template2.cpp Sat Feb 27 18:45:13 2016
@@ -0,0 +1,9 @@
+#define USE
+#include "extern_template.h"
+#undef USE
+
+extern Test<int> TO;
+int bar() {
+  TO.doIt(5);
+  return TO.M;
+}

Added: compiler-rt/trunk/test/profile/Linux/extern_template.test
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/profile/Linux/extern_template.test?rev=262161&view=auto
==============================================================================
--- compiler-rt/trunk/test/profile/Linux/extern_template.test (added)
+++ compiler-rt/trunk/test/profile/Linux/extern_template.test Sat Feb 27 18:45:13 2016
@@ -0,0 +1,29 @@
+// RUN: %clang -O2  -c -o %t.0.o %S/../Inputs/extern_template.cpp
+// RUN: %clang_profgen -O2  -c -o %t.o %S/../Inputs/extern_template.cpp
+// RUN: %clang_profgen -O2 -fcoverage-mapping %S/../Inputs/extern_template1.cpp %S/../Inputs/extern_template2.cpp %t.o -o %t
+// RUN: env LLVM_PROFILE_FILE=%t.profraw %t
+// RUN: llvm-profdata show --all-functions %t.profraw | FileCheck %s
+// RUN: llvm-profdata merge -o %t.profdata %t.profraw
+// RUN: llvm-cov show -instr-profile=%t.profdata %t | FileCheck %S/../Inputs/extern_template.h
+// RUN: %clang_profgen -O2 -fcoverage-mapping %S/../Inputs/extern_template1.cpp %S/../Inputs/extern_template2.cpp %t.0.o -o %t.0
+// RUN: env LLVM_PROFILE_FILE=%t.0.profraw %t.0
+// RUN: llvm-profdata show --all-functions %t.0.profraw | FileCheck %s
+// RUN: llvm-profdata merge -o %t.0.profdata %t.0.profraw
+// RUN: llvm-cov show -instr-profile=%t.0.profdata %t.0 | FileCheck %S/../Inputs/extern_template.h
+#define DEF
+#include "extern_template.h"
+#undef DEF
+extern int bar();
+extern int foo();
+extern Test<int> TO;
+int main() {
+  foo();
+  int R = bar();
+
+  if (R != 10)
+    return 1;
+  return 0;
+}
+// No duplicate entries
+// CHECK: _ZN4TestIiE4doItEi:
+// CHECK-NOT: _ZN4TestIiE4doItEi:




More information about the llvm-commits mailing list