[PATCH] D82928: [Coroutines] Fix code coverage for coroutine

2020-07-01 Thread Nico Weber via Phabricator via cfe-commits
thakis added inline comments.



Comment at: clang/test/CoverageMapping/coroutine.cpp:1
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 
-emit-llvm -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping 
%s | FileCheck %s
+

Since this line is missing an -o /dev/null, it writes a .ll file into the test 
directory, which lit tries to run as test next time, causing check-clang to 
fail: http://45.33.8.238/linux/21841/step_7.txt

Please add `-o /dev/null`, and please also add a `RUN: rm -f %S/coroutine.ll` 
to clean up bots (with a fixme to remove that rm line once it's been in the 
tree for a week or so)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82928/new/

https://reviews.llvm.org/D82928



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82928: [Coroutines] Fix code coverage for coroutine

2020-07-01 Thread Xun Li via Phabricator via cfe-commits
lxfind added a comment.

In D82928#2126018 , @fhahn wrote:

> Looks like this causes a bunch of build bot failures, e.g 
> http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/31465  b
>
> It would be great if you could take a look.


Fix patch in https://reviews.llvm.org/D82986


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82928/new/

https://reviews.llvm.org/D82928



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82928: [Coroutines] Fix code coverage for coroutine

2020-07-01 Thread Xun Li via Phabricator via cfe-commits
lxfind added a comment.

In D82928#2126018 , @fhahn wrote:

> Looks like this causes a bunch of build bot failures, e.g 
> http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/31465  b
>
> It would be great if you could take a look.


Let me revert it for now while fixing it. If you could accept: 
https://reviews.llvm.org/D82984


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82928/new/

https://reviews.llvm.org/D82928



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82928: [Coroutines] Fix code coverage for coroutine

2020-07-01 Thread Xun Li via Phabricator via cfe-commits
lxfind added a comment.

In D82928#2126018 , @fhahn wrote:

> Looks like this causes a bunch of build bot failures, e.g 
> http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/31465  b
>
> It would be great if you could take a look.


Looks like it's creating a tmp file within the test dir. Let me take a look.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82928/new/

https://reviews.llvm.org/D82928



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82928: [Coroutines] Fix code coverage for coroutine

2020-07-01 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

Looks like this causes a bunch of build bot failures, e.g 
http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/31465  b

It would be great if you could take a look.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82928/new/

https://reviews.llvm.org/D82928



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82928: [Coroutines] Fix code coverage for coroutine

2020-07-01 Thread Xun Li via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG565e37c7702d: [Coroutines] Fix code coverage for coroutine 
(authored by lxfind).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82928/new/

https://reviews.llvm.org/D82928

Files:
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/test/CoverageMapping/coroutine.cpp


Index: clang/test/CoverageMapping/coroutine.cpp
===
--- /dev/null
+++ clang/test/CoverageMapping/coroutine.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 
-emit-llvm -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping 
%s | FileCheck %s
+
+namespace std::experimental {
+template 
+struct coroutine_traits;
+
+template 
+struct coroutine_handle {
+  coroutine_handle() = default;
+  static coroutine_handle from_address(void *) noexcept { return {}; }
+};
+template <>
+struct coroutine_handle {
+  static coroutine_handle from_address(void *) { return {}; }
+  coroutine_handle() = default;
+  template 
+  coroutine_handle(coroutine_handle) noexcept {}
+};
+} // namespace std::experimental
+
+struct suspend_always {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+template <>
+struct std::experimental::coroutine_traits {
+  struct promise_type {
+int get_return_object();
+suspend_always initial_suspend();
+suspend_always final_suspend() noexcept;
+void return_value(int);
+  };
+};
+
+// CHECK-LABEL: _Z2f1i:
+int f1(int x) {   // CHECK-NEXT: File 0, [[@LINE]]:15 -> [[@LINE+7]]:2 = #0
+  if (x > 42) {   // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:13 = #0
+++x;  // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:14 -> 
[[@LINE-1]]:15 = #1
+  } else {// CHECK-NEXT: File 0, [[@LINE-2]]:15 -> [[@LINE]]:4 = #1
+co_return x + 42; // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:4 -> 
[[@LINE-1]]:10 = (#0 - #1)
+  }   // CHECK-NEXT: File 0, [[@LINE-2]]:10 -> [[@LINE]]:4 = 
(#0 - #1)
+  co_return x;// CHECK-NEXT: Gap,File 0, [[@LINE-1]]:4 -> [[@LINE]]:3 
= #1
+} // CHECK-NEXT: File 0, [[@LINE-1]]:3 -> [[@LINE]]:2 = #1
Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===
--- clang/lib/CodeGen/CoverageMappingGen.cpp
+++ clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -908,6 +908,18 @@
 terminateRegion(S);
   }
 
+  void VisitCoroutineBodyStmt(const CoroutineBodyStmt *S) {
+extendRegion(S);
+Visit(S->getBody());
+  }
+
+  void VisitCoreturnStmt(const CoreturnStmt *S) {
+extendRegion(S);
+if (S->getOperand())
+  Visit(S->getOperand());
+terminateRegion(S);
+  }
+
   void VisitCXXThrowExpr(const CXXThrowExpr *E) {
 extendRegion(E);
 if (E->getSubExpr())


Index: clang/test/CoverageMapping/coroutine.cpp
===
--- /dev/null
+++ clang/test/CoverageMapping/coroutine.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 -emit-llvm -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping %s | FileCheck %s
+
+namespace std::experimental {
+template 
+struct coroutine_traits;
+
+template 
+struct coroutine_handle {
+  coroutine_handle() = default;
+  static coroutine_handle from_address(void *) noexcept { return {}; }
+};
+template <>
+struct coroutine_handle {
+  static coroutine_handle from_address(void *) { return {}; }
+  coroutine_handle() = default;
+  template 
+  coroutine_handle(coroutine_handle) noexcept {}
+};
+} // namespace std::experimental
+
+struct suspend_always {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+template <>
+struct std::experimental::coroutine_traits {
+  struct promise_type {
+int get_return_object();
+suspend_always initial_suspend();
+suspend_always final_suspend() noexcept;
+void return_value(int);
+  };
+};
+
+// CHECK-LABEL: _Z2f1i:
+int f1(int x) {   // CHECK-NEXT: File 0, [[@LINE]]:15 -> [[@LINE+7]]:2 = #0
+  if (x > 42) {   // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:13 = #0
+++x;  // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:14 -> [[@LINE-1]]:15 = #1
+  } else {// CHECK-NEXT: File 0, [[@LINE-2]]:15 -> [[@LINE]]:4 = #1
+co_return x + 42; // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:4 -> [[@LINE-1]]:10 = (#0 - #1)
+  }   // CHECK-NEXT: File 0, [[@LINE-2]]:10 -> [[@LINE]]:4 = (#0 - #1)
+  co_return x;// CHECK-NEXT: Gap,File 0, [[@LINE-1]]:4 -> [[@LINE]]:3 = #1
+} // CHECK-NEXT: File 0, [[@LINE-1]]:3 -> [[@LINE]]:2 = #1
Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===

[PATCH] D82928: [Coroutines] Fix code coverage for coroutine

2020-07-01 Thread Xun Li via Phabricator via cfe-commits
lxfind updated this revision to Diff 274836.
lxfind added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82928/new/

https://reviews.llvm.org/D82928

Files:
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/test/CoverageMapping/coroutine.cpp


Index: clang/test/CoverageMapping/coroutine.cpp
===
--- /dev/null
+++ clang/test/CoverageMapping/coroutine.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 
-emit-llvm -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping 
%s | FileCheck %s
+
+namespace std::experimental {
+template 
+struct coroutine_traits;
+
+template 
+struct coroutine_handle {
+  coroutine_handle() = default;
+  static coroutine_handle from_address(void *) noexcept { return {}; }
+};
+template <>
+struct coroutine_handle {
+  static coroutine_handle from_address(void *) { return {}; }
+  coroutine_handle() = default;
+  template 
+  coroutine_handle(coroutine_handle) noexcept {}
+};
+} // namespace std::experimental
+
+struct suspend_always {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+template <>
+struct std::experimental::coroutine_traits {
+  struct promise_type {
+int get_return_object();
+suspend_always initial_suspend();
+suspend_always final_suspend() noexcept;
+void return_value(int);
+  };
+};
+
+// CHECK-LABEL: _Z2f1i:
+int f1(int x) {   // CHECK-NEXT: File 0, [[@LINE]]:15 -> [[@LINE+7]]:2 = #0
+  if (x > 42) {   // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:13 = #0
+++x;  // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:14 -> 
[[@LINE-1]]:15 = #1
+  } else {// CHECK-NEXT: File 0, [[@LINE-2]]:15 -> [[@LINE]]:4 = #1
+co_return x + 42; // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:4 -> 
[[@LINE-1]]:10 = (#0 - #1)
+  }   // CHECK-NEXT: File 0, [[@LINE-2]]:10 -> [[@LINE]]:4 = 
(#0 - #1)
+  co_return x;// CHECK-NEXT: Gap,File 0, [[@LINE-1]]:4 -> [[@LINE]]:3 
= #1
+} // CHECK-NEXT: File 0, [[@LINE-1]]:3 -> [[@LINE]]:2 = #1
Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===
--- clang/lib/CodeGen/CoverageMappingGen.cpp
+++ clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -908,6 +908,18 @@
 terminateRegion(S);
   }
 
+  void VisitCoroutineBodyStmt(const CoroutineBodyStmt *S) {
+extendRegion(S);
+Visit(S->getBody());
+  }
+
+  void VisitCoreturnStmt(const CoreturnStmt *S) {
+extendRegion(S);
+if (S->getOperand())
+  Visit(S->getOperand());
+terminateRegion(S);
+  }
+
   void VisitCXXThrowExpr(const CXXThrowExpr *E) {
 extendRegion(E);
 if (E->getSubExpr())


Index: clang/test/CoverageMapping/coroutine.cpp
===
--- /dev/null
+++ clang/test/CoverageMapping/coroutine.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 -emit-llvm -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping %s | FileCheck %s
+
+namespace std::experimental {
+template 
+struct coroutine_traits;
+
+template 
+struct coroutine_handle {
+  coroutine_handle() = default;
+  static coroutine_handle from_address(void *) noexcept { return {}; }
+};
+template <>
+struct coroutine_handle {
+  static coroutine_handle from_address(void *) { return {}; }
+  coroutine_handle() = default;
+  template 
+  coroutine_handle(coroutine_handle) noexcept {}
+};
+} // namespace std::experimental
+
+struct suspend_always {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+template <>
+struct std::experimental::coroutine_traits {
+  struct promise_type {
+int get_return_object();
+suspend_always initial_suspend();
+suspend_always final_suspend() noexcept;
+void return_value(int);
+  };
+};
+
+// CHECK-LABEL: _Z2f1i:
+int f1(int x) {   // CHECK-NEXT: File 0, [[@LINE]]:15 -> [[@LINE+7]]:2 = #0
+  if (x > 42) {   // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:13 = #0
+++x;  // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:14 -> [[@LINE-1]]:15 = #1
+  } else {// CHECK-NEXT: File 0, [[@LINE-2]]:15 -> [[@LINE]]:4 = #1
+co_return x + 42; // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:4 -> [[@LINE-1]]:10 = (#0 - #1)
+  }   // CHECK-NEXT: File 0, [[@LINE-2]]:10 -> [[@LINE]]:4 = (#0 - #1)
+  co_return x;// CHECK-NEXT: Gap,File 0, [[@LINE-1]]:4 -> [[@LINE]]:3 = #1
+} // CHECK-NEXT: File 0, [[@LINE-1]]:3 -> [[@LINE]]:2 = #1
Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===
--- clang/lib/CodeGen/CoverageMappingGen.cpp
+++ clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -908

[PATCH] D82928: [Coroutines] Fix code coverage for coroutine

2020-07-01 Thread Brian Gesiak via Phabricator via cfe-commits
modocache accepted this revision.
modocache added a comment.
This revision is now accepted and ready to land.

Excellent, thanks for this!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82928/new/

https://reviews.llvm.org/D82928



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82928: [Coroutines] Fix code coverage for coroutine

2020-06-30 Thread Xun Li via Phabricator via cfe-commits
lxfind created this revision.
lxfind added reviewers: lewissbaker, modocache, junparser.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Previously, source-based coverage analysis does not work properly for coroutine.
This patch adds processing of coroutine body and co_return in the coverage 
analysis, so that we can handle them properly.
For coroutine body, we should only look at the actual function body and ignore 
the compiler-generated things; for co_return, we need to terminate the region 
similar to return statement.
Added a test, and confirms that it now works properly. (without this patch, the 
statement after the if statement will be treated wrongly)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82928

Files:
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/test/CoverageMapping/coroutine.cpp


Index: clang/test/CoverageMapping/coroutine.cpp
===
--- /dev/null
+++ clang/test/CoverageMapping/coroutine.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 
-emit-llvm -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping 
%s | FileCheck %s
+
+namespace std::experimental {
+template 
+struct coroutine_traits;
+
+template 
+struct coroutine_handle {
+  coroutine_handle() = default;
+  static coroutine_handle from_address(void *) noexcept { return {}; }
+};
+template <>
+struct coroutine_handle {
+  static coroutine_handle from_address(void *) { return {}; }
+  coroutine_handle() = default;
+  template 
+  coroutine_handle(coroutine_handle) noexcept {}
+};
+} // namespace std::experimental
+
+struct suspend_always {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+template <>
+struct std::experimental::coroutine_traits {
+  struct promise_type {
+int get_return_object();
+suspend_always initial_suspend();
+suspend_always final_suspend() noexcept;
+void return_value(int);
+  };
+};
+
+// CHECK-LABEL: _Z2f1i:
+int f1(int x) {   // CHECK-NEXT: File 0, [[@LINE]]:15 -> [[@LINE+7]]:2 = #0
+  if (x > 42) {   // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:13 = #0
+++x;  // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:14 -> 
[[@LINE-1]]:15 = #1
+  } else {// CHECK-NEXT: File 0, [[@LINE-2]]:15 -> [[@LINE]]:4 = #1
+co_return x + 42; // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:4 -> 
[[@LINE-1]]:10 = (#0 - #1)
+  }   // CHECK-NEXT: File 0, [[@LINE-2]]:10 -> [[@LINE]]:4 = 
(#0 - #1)
+  co_return x;// CHECK-NEXT: Gap,File 0, [[@LINE-1]]:4 -> [[@LINE]]:3 
= #1
+} // CHECK-NEXT: File 0, [[@LINE-1]]:3 -> [[@LINE]]:2 = #1
Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===
--- clang/lib/CodeGen/CoverageMappingGen.cpp
+++ clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -908,6 +908,18 @@
 terminateRegion(S);
   }
 
+  void VisitCoroutineBodyStmt(const CoroutineBodyStmt *S) {
+extendRegion(S);
+Visit(S->getBody());
+  }
+
+  void VisitCoreturnStmt(const CoreturnStmt *S) {
+extendRegion(S);
+if (S->getOperand())
+  Visit(S->getOperand());
+terminateRegion(S);
+  }
+
   void VisitCXXThrowExpr(const CXXThrowExpr *E) {
 extendRegion(E);
 if (E->getSubExpr())


Index: clang/test/CoverageMapping/coroutine.cpp
===
--- /dev/null
+++ clang/test/CoverageMapping/coroutine.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 -emit-llvm -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping %s | FileCheck %s
+
+namespace std::experimental {
+template 
+struct coroutine_traits;
+
+template 
+struct coroutine_handle {
+  coroutine_handle() = default;
+  static coroutine_handle from_address(void *) noexcept { return {}; }
+};
+template <>
+struct coroutine_handle {
+  static coroutine_handle from_address(void *) { return {}; }
+  coroutine_handle() = default;
+  template 
+  coroutine_handle(coroutine_handle) noexcept {}
+};
+} // namespace std::experimental
+
+struct suspend_always {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+template <>
+struct std::experimental::coroutine_traits {
+  struct promise_type {
+int get_return_object();
+suspend_always initial_suspend();
+suspend_always final_suspend() noexcept;
+void return_value(int);
+  };
+};
+
+// CHECK-LABEL: _Z2f1i:
+int f1(int x) {   // CHECK-NEXT: File 0, [[@LINE]]:15 -> [[@LINE+7]]:2 = #0
+  if (x > 42) {   // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:13 = #0
+++x;  // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:14 -> [[@LINE-1]]:15 = #1
+  } else {// CHECK-NEXT: File 0, [[@LINE-2]]:15 -> [[@LINE