[llvm] c94b653 - [llvm-cov gcov] Drop support for clang<11's fake GCC 4.2 format

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 15 11:16:53 PDT 2023


Author: Fangrui Song
Date: 2023-08-15T10:44:48-07:00
New Revision: c94b6530bca80a8bd105921d6653a8c78f55d3d1

URL: https://github.com/llvm/llvm-project/commit/c94b6530bca80a8bd105921d6653a8c78f55d3d1
DIFF: https://github.com/llvm/llvm-project/commit/c94b6530bca80a8bd105921d6653a8c78f55d3d1.diff

LOG: [llvm-cov gcov] Drop support for clang<11's fake GCC 4.2 format

clang<11 intended to use a GCC 4.2 compatible format but that turned out
to make some mistakes. After instrumentation side format changes,
c8b082a3abe44138fff4ef824300270dd6e8bc77 kept supporting the legacy
format, originally intended for 1 or 2 major releases.

Remove an obsoleted comment as GCC 12 uses length==12 for
GCOV_TAG_FUNCTION in .gcda files.

Added: 
    

Modified: 
    llvm/lib/ProfileData/GCOV.cpp

Removed: 
    llvm/test/tools/llvm-cov/gcov/Inputs/gcov-fake-4.2.gcda
    llvm/test/tools/llvm-cov/gcov/Inputs/gcov-fake-4.2.gcno
    llvm/test/tools/llvm-cov/gcov/gcov-fake-4.2.c


################################################################################
diff  --git a/llvm/lib/ProfileData/GCOV.cpp b/llvm/lib/ProfileData/GCOV.cpp
index 1e70431a1fae12..0a3330fde1d100 100644
--- a/llvm/lib/ProfileData/GCOV.cpp
+++ b/llvm/lib/ProfileData/GCOV.cpp
@@ -237,23 +237,14 @@ bool GCOVFile::readGCDA(GCOVBuffer &buf) {
     if (tag == GCOV_TAG_OBJECT_SUMMARY) {
       buf.readInt(runCount);
       buf.readInt(dummy);
-      // clang<11 uses a fake 4.2 format which sets length to 9.
-      if (length == 9)
-        buf.readInt(runCount);
     } else if (tag == GCOV_TAG_PROGRAM_SUMMARY) {
-      // clang<11 uses a fake 4.2 format which sets length to 0.
-      if (length > 0) {
-        buf.readInt(dummy);
-        buf.readInt(dummy);
-        buf.readInt(runCount);
-      }
+      buf.readInt(dummy);
+      buf.readInt(dummy);
+      buf.readInt(runCount);
       ++programCount;
     } else if (tag == GCOV_TAG_FUNCTION) {
       if (length == 0) // Placeholder
         continue;
-      // As of GCC 10, GCOV_TAG_FUNCTION_LENGTH has never been larger than 3.
-      // However, clang<11 uses a fake 4.2 format which may set length larger
-      // than 3.
       if (length < 2 || !buf.readInt(ident))
         return false;
       auto It = identToFunction.find(ident);

diff  --git a/llvm/test/tools/llvm-cov/gcov/Inputs/gcov-fake-4.2.gcda b/llvm/test/tools/llvm-cov/gcov/Inputs/gcov-fake-4.2.gcda
deleted file mode 100644
index 613e3a85c02678..00000000000000
Binary files a/llvm/test/tools/llvm-cov/gcov/Inputs/gcov-fake-4.2.gcda and /dev/null 
diff er

diff  --git a/llvm/test/tools/llvm-cov/gcov/Inputs/gcov-fake-4.2.gcno b/llvm/test/tools/llvm-cov/gcov/Inputs/gcov-fake-4.2.gcno
deleted file mode 100644
index 24f1c82476b2cc..00000000000000
Binary files a/llvm/test/tools/llvm-cov/gcov/Inputs/gcov-fake-4.2.gcno and /dev/null 
diff er

diff  --git a/llvm/test/tools/llvm-cov/gcov/gcov-fake-4.2.c b/llvm/test/tools/llvm-cov/gcov/gcov-fake-4.2.c
deleted file mode 100644
index d2f99d74bfc0f0..00000000000000
--- a/llvm/test/tools/llvm-cov/gcov/gcov-fake-4.2.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/// Test that llvm-cov supports a fake gcov 4.2 format used before clang 11.
-
-// RUN: rm -rf %t && mkdir %t && cd %t
-// RUN: echo -e '\n\n\n\n\n\n\n\n\n' > test.cpp && echo > test.h
-// RUN: llvm-cov gcov test. --gcno=%S/Inputs/gcov-fake-4.2.gcno --gcda=%S/Inputs/gcov-fake-4.2.gcda | FileCheck %s
-// RUN: FileCheck %s --check-prefix=C < test.cpp.gcov
-// RUN: FileCheck %s --check-prefix=H < test.h.gcov
-
-// CHECK:       File 'test.cpp'
-// CHECK-NEXT:  Lines executed:84.21% of 38
-// CHECK-NEXT:  Creating 'test.cpp.gcov'
-// CHECK-EMPTY:
-// CHECK-NEXT:  File 'test.h'
-// CHECK-NEXT:  Lines executed:100.00% of 1
-// CHECK-NEXT:  Creating 'test.h.gcov'
-// CHECK-EMPTY:
-
-//      C:        -:    0:Source:test.cpp
-// C-NEXT:        -:    0:Graph:{{.*}}gcov-fake-4.2.gcno
-// C-NEXT:        -:    0:Data:{{.*}}gcov-fake-4.2.gcda
-/// `Runs` is stored in GCOV_TAG_OBJECT_SUMMARY with a length of 9.
-// C-NEXT:        -:    0:Runs:2
-// C-NEXT:        -:    0:Programs:1
-// C-NEXT:        -:    1:
-// C-NEXT:        -:    2:
-// C-NEXT:        -:    3:
-// C-NEXT:        -:    4:
-// C-NEXT:        -:    5:
-// C-NEXT:        -:    6:
-// C-NEXT:        -:    7:
-// C-NEXT:        -:    8:
-// C-NEXT:        -:    9:
-// C-NEXT:8589934592:   10:
-
-//      H:        -:    0:Source:test.h
-// H-NEXT:        -:    0:Graph:{{.*}}gcov-fake-4.2.gcno
-// H-NEXT:        -:    0:Data:{{.*}}gcov-fake-4.2.gcda
-// H-NEXT:        -:    0:Runs:2
-// H-NEXT:        -:    0:Programs:1
-// H-NEXT:        4:    1:


        


More information about the llvm-commits mailing list