[llvm] 427ba2b - [llvm-cov] Assume repeat architectures for universal binaries

Keith Smiley via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 8 13:23:29 PDT 2022


Author: Keith Smiley
Date: 2022-06-08T13:22:57-07:00
New Revision: 427ba2bcce1ccdc8a267bb55e92772985b316e76

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

LOG: [llvm-cov] Assume repeat architectures for universal binaries

In the case you pass multiple universal binaries to llvm-cov, assume
that if only 1 architecture is passed, it should be used for all the
passed binaries.

This makes it easier to use multiple multi-arch binaries, since it's
likely very rare that your architectures mismatch significantly if you
also have multiple binaries in a single llvm-cov invocation. If the
architecture is invalid for any of the passed binaries, it will still
fail later.

Differential Revision: https://reviews.llvm.org/D121667

Added: 
    

Modified: 
    llvm/test/tools/llvm-cov/universal-binary.c
    llvm/tools/llvm-cov/CodeCoverage.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/test/tools/llvm-cov/universal-binary.c b/llvm/test/tools/llvm-cov/universal-binary.c
index f8d5346bc579..5c970ac54480 100644
--- a/llvm/test/tools/llvm-cov/universal-binary.c
+++ b/llvm/test/tools/llvm-cov/universal-binary.c
@@ -7,6 +7,8 @@ int main(int argc, const char *argv[]) {}
 // RUN: llvm-cov show %S/Inputs/universal-binary -instr-profile %t.profdata -path-equivalence=/tmp,%S %s -arch x86_64 | FileCheck %s
 
 // RUN: llvm-cov report %S/Inputs/universal-binary -arch x86_64 -object %S/Inputs/templateInstantiations.covmapping -arch i386 -instr-profile %t.profdata 2>&1 | FileCheck %s --check-prefix=COMBINED
+// RUN: llvm-cov report %S/Inputs/universal-binary -arch x86_64 -object %S/Inputs/templateInstantiations.covmapping -instr-profile %t.profdata 2>&1 | FileCheck %s --check-prefix=COMBINED
+// RUN: not llvm-cov report %S/Inputs/universal-binary -arch i386 -object %S/Inputs/templateInstantiations.covmapping -instr-profile %t.profdata 2>&1 | FileCheck %s --check-prefix=WRONG-ARCH
 // COMBINED: showTemplateInstantiations.cpp
 // COMBINED-NEXT: universal-binary.c
 

diff  --git a/llvm/tools/llvm-cov/CodeCoverage.cpp b/llvm/tools/llvm-cov/CodeCoverage.cpp
index 33874e3c0d86..b333f7f0f2e6 100644
--- a/llvm/tools/llvm-cov/CodeCoverage.cpp
+++ b/llvm/tools/llvm-cov/CodeCoverage.cpp
@@ -883,6 +883,9 @@ int CodeCoverageTool::run(Command Cmd, int argc, const char **argv) {
         }
         CoverageArches.emplace_back(Arch);
       }
+      if (CoverageArches.size() == 1)
+        CoverageArches.insert(CoverageArches.end(), ObjectFilenames.size() - 1,
+                              CoverageArches[0]);
       if (CoverageArches.size() != ObjectFilenames.size()) {
         error("Number of architectures doesn't match the number of objects");
         return 1;


        


More information about the llvm-commits mailing list