[compiler-rt] 7b6b15e - [profile][test] Improve coverage-linkage.cpp with ld.lld --gc-sections
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 6 11:08:53 PDT 2021
Author: Fangrui Song
Date: 2021-07-06T11:08:47-07:00
New Revision: 7b6b15e010664ec444f3c20a9b15ff4324c8971c
URL: https://github.com/llvm/llvm-project/commit/7b6b15e010664ec444f3c20a9b15ff4324c8971c
DIFF: https://github.com/llvm/llvm-project/commit/7b6b15e010664ec444f3c20a9b15ff4324c8971c.diff
LOG: [profile][test] Improve coverage-linkage.cpp with ld.lld --gc-sections
The __llvm_prf_names section uses SHF_GNU_RETAIN. However, GNU ld before 2015-10
(https://sourceware.org/bugzilla/show_bug.cgi?id=19161) neither supports it nor
retains __llvm_prf_names according to __start___llvm_prf_names. So --gc-sections
does not work on such old GNU ld.
This is not a problem for gold and sufficiently new lld.
Added:
Modified:
compiler-rt/test/profile/Linux/coverage-linkage.cpp
Removed:
################################################################################
diff --git a/compiler-rt/test/profile/Linux/coverage-linkage.cpp b/compiler-rt/test/profile/Linux/coverage-linkage.cpp
index 32a63fb000955..8a52bfc97d949 100644
--- a/compiler-rt/test/profile/Linux/coverage-linkage.cpp
+++ b/compiler-rt/test/profile/Linux/coverage-linkage.cpp
@@ -1,9 +1,33 @@
/// Test instrumentation can handle various linkages.
+// REQUIRES: lld-available
// RUN: %clang_profgen -fcoverage-mapping %s -o %t
// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
+// RUN: llvm-profdata show %t.profraw --all-functions | FileCheck %s
-// RUN: %clang_profgen -fcoverage-mapping -ffunction-sections -Wl,--gc-sections %s -o %t
+// RUN: %clang_profgen -fcoverage-mapping -ffunction-sections -fuse-ld=lld -Wl,--gc-sections %s -o %t
// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
+// RUN: llvm-profdata show %t.profraw --all-functions | FileCheck %s
+
+// CHECK: {{.*}}external{{.*}}:
+// CHECK-NEXT: Hash:
+// CHECK-NEXT: Counters: 1
+// CHECK-NEXT: Function count: 1
+// CHECK: {{.*}}weak{{.*}}:
+// CHECK-NEXT: Hash:
+// CHECK-NEXT: Counters: 1
+// CHECK-NEXT: Function count: 1
+// CHECK: main:
+// CHECK-NEXT: Hash:
+// CHECK-NEXT: Counters: 1
+// CHECK-NEXT: Function count: 1
+// CHECK: {{.*}}internal{{.*}}:
+// CHECK-NEXT: Hash:
+// CHECK-NEXT: Counters: 1
+// CHECK-NEXT: Function count: 1
+// CHECK: {{.*}}linkonce_odr{{.*}}:
+// CHECK-NEXT: Hash:
+// CHECK-NEXT: Counters: 1
+// CHECK-NEXT: Function count: 1
#include <stdio.h>
More information about the llvm-commits
mailing list