[compiler-rt] r260142 - [PGO] Simpflify test and increase coverage

Xinliang David Li via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 8 12:46:27 PST 2016


Author: davidxl
Date: Mon Feb  8 14:46:26 2016
New Revision: 260142

URL: http://llvm.org/viewvc/llvm-project?rev=260142&view=rev
Log:
[PGO] Simpflify test and increase coverage

Modified:
    compiler-rt/trunk/test/profile/Linux/coverage_ctors.cpp
    compiler-rt/trunk/test/profile/Linux/coverage_dtor.cpp

Modified: compiler-rt/trunk/test/profile/Linux/coverage_ctors.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/profile/Linux/coverage_ctors.cpp?rev=260142&r1=260141&r2=260142&view=diff
==============================================================================
--- compiler-rt/trunk/test/profile/Linux/coverage_ctors.cpp (original)
+++ compiler-rt/trunk/test/profile/Linux/coverage_ctors.cpp Mon Feb  8 14:46:26 2016
@@ -5,28 +5,28 @@
 
 struct Base {
   int B;
-  Base() : B(2) {}
-  Base(const struct Base &b2) {
-    if (b2.B == 0) {
-      B = b2.B + 1;
-    } else
-      B = b2.B;
+  Base() : B(0) {}
+  Base(const Base &b2) {
+    B = b2.B + 5;
+  }
+  Base(Base &&b2) {
+    B = b2.B + 10;
   }
 };
 
 struct Derived : public Base {
   Derived(const Derived &) = default; // CHECK:  2| [[@LINE]]|  Derived(const Derived &) = default;
+  Derived(Derived &&) = default;      // CHECK:  1| [[@LINE]]|  Derived(Derived &&) = default;
   Derived() = default;                // CHECK:  1| [[@LINE]]|  Derived() = default
-  int I;
-  int getI() { return I; }
 };
 
 Derived dd;
-int g;
 int main() {
   Derived dd2(dd);
-  Derived dd3(dd);
+  Derived dd3(dd2);
+  Derived dd4(static_cast<Derived &&>(dd3));
 
-  g = dd2.getI() + dd3.getI();
+  if (dd.B != 0 || dd2.B != 5 || dd3.B != 10 || dd4.B != 20)
+    return 1;                         // CHECK: 0| [[@LINE]]|     return 1;
   return 0;
 }

Modified: compiler-rt/trunk/test/profile/Linux/coverage_dtor.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/profile/Linux/coverage_dtor.cpp?rev=260142&r1=260141&r2=260142&view=diff
==============================================================================
--- compiler-rt/trunk/test/profile/Linux/coverage_dtor.cpp (original)
+++ compiler-rt/trunk/test/profile/Linux/coverage_dtor.cpp Mon Feb  8 14:46:26 2016
@@ -3,23 +3,24 @@
 // RUN: llvm-profdata merge -o %t.profdata %t.profraw
 // RUN: llvm-cov show %t -instr-profile %t.profdata -filename-equivalence 2>&1 | FileCheck %s
 
+int g = 100;
 struct Base {
   int B;
   Base(int B_) : B(B_) {}
-  ~Base() {}
+  ~Base() { g -= B; }
 };
 
 struct Derived : public Base {
-  Derived(int K) : Base(K), I(K) {}
+  Derived(int K) : Base(K) {}
   ~Derived() = default; // CHECK:  2| [[@LINE]]|  ~Derived() = default;
-  int I;
-  int getI() { return I; }
 };
 
-int g;
 int main() {
-  Derived dd(10);
-  Derived dd2(120);
-  g = dd2.getI() + dd.getI();
+  {
+    Derived dd(10);
+    Derived dd2(90);
+  }
+  if (g != 0)
+    return 1;          // CHECK:  0| [[@LINE]]|    return 1;
   return 0;
 }




More information about the llvm-commits mailing list