InstrProf: Remove CoverageMapping::HasCodeBefore, it isn't used
authorJustin Bogner <mail@justinbogner.com>
Tue, 3 Feb 2015 21:35:36 +0000 (21:35 +0000)
committerJustin Bogner <mail@justinbogner.com>
Tue, 3 Feb 2015 21:35:36 +0000 (21:35 +0000)
It's not entirely clear to me what this field was meant for, but it's
always false. Remove it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228034 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ProfileData/CoverageMapping.h
lib/ProfileData/CoverageMappingReader.cpp
lib/ProfileData/CoverageMappingWriter.cpp
test/tools/llvm-cov/Inputs/highlightedRanges.covmapping
test/tools/llvm-cov/Inputs/regionMarkers.covmapping
test/tools/llvm-cov/Inputs/showExpansions.covmapping
test/tools/llvm-cov/showHighlightedRanges.cpp

index 7c88977cb29e02f311fea21b88fd9490855f4543..61aad3b3bc3dbf0fa072577319368201580d57e1 100644 (file)
@@ -158,24 +158,17 @@ struct CounterMappingRegion {
     SkippedRegion
   };
 
-  static const unsigned EncodingHasCodeBeforeBits = 1;
-
   Counter Count;
   unsigned FileID, ExpandedFileID;
   unsigned LineStart, ColumnStart, LineEnd, ColumnEnd;
   RegionKind Kind;
-  /// \brief A flag that is set to true when there is already code before
-  /// this region on the same line.
-  /// This is useful to accurately compute the execution counts for a line.
-  bool HasCodeBefore;
 
   CounterMappingRegion(Counter Count, unsigned FileID, unsigned LineStart,
                        unsigned ColumnStart, unsigned LineEnd,
-                       unsigned ColumnEnd, bool HasCodeBefore = false,
-                       RegionKind Kind = CodeRegion)
+                       unsigned ColumnEnd, RegionKind Kind = CodeRegion)
       : Count(Count), FileID(FileID), ExpandedFileID(0), LineStart(LineStart),
         ColumnStart(ColumnStart), LineEnd(LineEnd), ColumnEnd(ColumnEnd),
-        Kind(Kind), HasCodeBefore(HasCodeBefore) {}
+        Kind(Kind) {}
 
   inline std::pair<unsigned, unsigned> startLoc() const {
     return std::pair<unsigned, unsigned>(LineStart, ColumnStart);
index 71ce22aec9e579e29a1aef2b2a933fa9c84f452f..423947d132fe1b791d262c4d627afd38f93488c6 100644 (file)
@@ -173,15 +173,12 @@ std::error_code RawCoverageMappingReader::readMappingRegionsSubArray(
     }
 
     // Read the source range.
-    uint64_t LineStartDelta, CodeBeforeColumnStart, NumLines, ColumnEnd;
+    uint64_t LineStartDelta, ColumnStart, NumLines, ColumnEnd;
     if (auto Err =
             readIntMax(LineStartDelta, std::numeric_limits<unsigned>::max()))
       return Err;
-    if (auto Err = readULEB128(CodeBeforeColumnStart))
+    if (auto Err = readULEB128(ColumnStart))
       return Err;
-    bool HasCodeBefore = CodeBeforeColumnStart & 1;
-    uint64_t ColumnStart = CodeBeforeColumnStart >>
-                           CounterMappingRegion::EncodingHasCodeBeforeBits;
     if (ColumnStart > std::numeric_limits<unsigned>::max())
       return error(instrprof_error::malformed);
     if (auto Err = readIntMax(NumLines, std::numeric_limits<unsigned>::max()))
@@ -213,9 +210,9 @@ std::error_code RawCoverageMappingReader::readMappingRegionsSubArray(
       dbgs() << "\n";
     });
 
-    MappingRegions.push_back(CounterMappingRegion(
-        C, InferredFileID, LineStart, ColumnStart, LineStart + NumLines,
-        ColumnEnd, HasCodeBefore, Kind));
+    MappingRegions.push_back(
+        CounterMappingRegion(C, InferredFileID, LineStart, ColumnStart,
+                             LineStart + NumLines, ColumnEnd, Kind));
     MappingRegions.back().ExpandedFileID = ExpandedFileID;
   }
   return success();
index 6969c2a1242bdc5ec29b10434261745f59fe0167..aef5511fc0e4ba7064deef0908d6201fb4b16397 100644 (file)
@@ -172,11 +172,7 @@ void CoverageMappingWriter::write(raw_ostream &OS) {
     }
     assert(I->LineStart >= PrevLineStart);
     encodeULEB128(I->LineStart - PrevLineStart, OS);
-    uint64_t CodeBeforeColumnStart =
-        uint64_t(I->HasCodeBefore) |
-        (uint64_t(I->ColumnStart)
-         << CounterMappingRegion::EncodingHasCodeBeforeBits);
-    encodeULEB128(CodeBeforeColumnStart, OS);
+    encodeULEB128(I->ColumnStart, OS);
     assert(I->LineEnd >= I->LineStart);
     encodeULEB128(I->LineEnd - I->LineStart, OS);
     encodeULEB128(I->ColumnEnd, OS);
index 20eb0d7e8df5b91054e61fd3508b1cbff05e640b..e97320b7855d167054b5fccccd4b703f75b31482 100644 (file)
Binary files a/test/tools/llvm-cov/Inputs/highlightedRanges.covmapping and b/test/tools/llvm-cov/Inputs/highlightedRanges.covmapping differ
index 3ebcb0777af316534f4ba725d7400f00e741f55e..501cba2b734ad5e90a1055b5247b784cf6ea993a 100644 (file)
Binary files a/test/tools/llvm-cov/Inputs/regionMarkers.covmapping and b/test/tools/llvm-cov/Inputs/regionMarkers.covmapping differ
index b8c7d9711afe58085452d69d030c0e3d1b2ba1a6..e02a7281b000183b4b9359c4ffa896a7995ded69 100644 (file)
Binary files a/test/tools/llvm-cov/Inputs/showExpansions.covmapping and b/test/tools/llvm-cov/Inputs/showExpansions.covmapping differ
index cec730829e0c5b225825faa6918352c9b301d826..1ff7929ee75550044d4b4b8abf1df8c82ff0bab5 100644 (file)
@@ -2,17 +2,17 @@
 
 void func() {
   return;
-  int i = 0;                     // CHECK: Highlighted line [[@LINE]], 3 -> 12
-}
+  int i = 0;                     // CHECK: Highlighted line [[@LINE]], 3 -> ?
+}                                // CHECK: Highlighted line [[@LINE]], 1 -> 2
 
 void func2(int x) {
   if(x > 5) {
     while(x >= 9) {
       return;
-      --x;                       // CHECK: Highlighted line [[@LINE]], 7 -> 10
-    }
-    int i = 0;                   // CHECK: Highlighted line [[@LINE]], 5 -> 14
-  }
+      --x;                       // CHECK: Highlighted line [[@LINE]], 7 -> ?
+    }                            // CHECK: Highlighted line [[@LINE]], 1 -> 6
+    int i = 0;                   // CHECK: Highlighted line [[@LINE]], 5 -> ?
+  }                              // CHECK: Highlighted line [[@LINE]], 1 -> 4
 }
 
 void test() {