[PATCH] D18610: [PGO] Restore the correct counter value after processing a nested region in case of combined regions.

David Li via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 30 22:32:16 PDT 2016


davidxl added a comment.

I think a better fix is to change the active region stack into a stack of entry segments. The resulting code will be more readable.


================
Comment at: llvm/trunk/lib/ProfileData/CoverageMapping.cpp:279
@@ -278,3 +278,3 @@
   /// Start a segment with no count specified.
   void startSegment(unsigned Line, unsigned Col) {
     DEBUG(dbgs() << "Top level segment at " << Line << ":" << Col << "\n");
----------------
This seems like a dead function now.

================
Comment at: llvm/trunk/test/tools/llvm-cov/showTemplateInstantiations.cpp:10
@@ -9,3 +9,3 @@
     return 0;        // ALL-NEXT:    1| [[@LINE]]|    return 0;
-  else               // ALL-NEXT:    1| [[@LINE]]|  else
+  else               // ALL-NEXT:    2| [[@LINE]]|  else
     return 1;        // ALL-NEXT:    1| [[@LINE]]|    return 1;
----------------
vsk wrote:
> Could you explain why the line containing the `else` is marked as having executed twice? It seems like it should only be executed once.
The 'else' line is not included by any region. It gets its count from the End segment of the previous region. The count of the end segment of a region is defined here to be the count of its parent region which makes sense for case like

if (...) {
  // region 1
}
// non exec line

The non exec line's count is region 1's parent region's count, not region 1.


http://reviews.llvm.org/D18610





More information about the llvm-commits mailing list