diff options
| author | Vedant Kumar <vsk@apple.com> | 2018-02-28 19:00:08 +0000 |
|---|---|---|
| committer | Vedant Kumar <vsk@apple.com> | 2018-02-28 19:00:08 +0000 |
| commit | 9a041a75221cadaafbf902e8ec6b73f6d2612d89 (patch) | |
| tree | eeb45bbee1766691a7a3221df5d44144d229829e /llvm/test | |
| parent | 18a7c51520ae6bafb8a95d45308becf60159488e (diff) | |
| download | bcm5719-llvm-9a041a75221cadaafbf902e8ec6b73f6d2612d89.tar.gz bcm5719-llvm-9a041a75221cadaafbf902e8ec6b73f6d2612d89.zip | |
[InstrProfiling] Emit the runtime hook when no counters are lowered
The API verification tool tapi has difficulty processing frameworks
which enable code coverage, but which have no code. The profile lowering
pass does not emit the runtime hook in this case because no counters are
lowered.
While the hook is not needed for program correctness (the profile
runtime doesn't have to be linked in), it's needed to allow tapi to
validate the exported symbol set of instrumented binaries.
It was not possible to add a workaround in tapi for empty binaries due
to an architectural issue: tapi generates its expected symbol set before
it inspects a binary. Changing that model has a higher cost than simply
forcing llvm to always emit the runtime hook.
rdar://36076904
Differential Revision: https://reviews.llvm.org/D43794
llvm-svn: 326350
Diffstat (limited to 'llvm/test')
| -rw-r--r-- | llvm/test/Instrumentation/InstrProfiling/linkage.ll | 6 | ||||
| -rw-r--r-- | llvm/test/Instrumentation/InstrProfiling/no-counters.ll | 14 | ||||
| -rw-r--r-- | llvm/test/Instrumentation/InstrProfiling/profiling.ll | 3 |
3 files changed, 13 insertions, 10 deletions
diff --git a/llvm/test/Instrumentation/InstrProfiling/linkage.ll b/llvm/test/Instrumentation/InstrProfiling/linkage.ll index 72320ef523b..c3682834d5c 100644 --- a/llvm/test/Instrumentation/InstrProfiling/linkage.ll +++ b/llvm/test/Instrumentation/InstrProfiling/linkage.ll @@ -7,6 +7,9 @@ ; RUN: opt < %s -mtriple=x86_64-pc-win32-coff -instrprof -S | FileCheck %s --check-prefix=COFF ; RUN: opt < %s -mtriple=x86_64-pc-win32-coff -passes=instrprof -S | FileCheck %s --check-prefix=COFF +; OTHER: @__llvm_profile_runtime = external global i32 +; LINUX-NOT: @__llvm_profile_runtime = external global i32 + @__profn_foo = hidden constant [3 x i8] c"foo" @__profn_foo_weak = weak hidden constant [8 x i8] c"foo_weak" @"__profn_linkage.ll:foo_internal" = internal constant [23 x i8] c"linkage.ll:foo_internal" @@ -52,9 +55,6 @@ define available_externally void @foo_extern() { declare void @llvm.instrprof.increment(i8*, i64, i32, i32) -; OTHER: @__llvm_profile_runtime = external global i32 -; LINUX-NOT: @__llvm_profile_runtime = external global i32 - ; OTHER: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() {{.*}} { ; OTHER: %[[REG:.*]] = load i32, i32* @__llvm_profile_runtime ; OTHER: ret i32 %[[REG]] diff --git a/llvm/test/Instrumentation/InstrProfiling/no-counters.ll b/llvm/test/Instrumentation/InstrProfiling/no-counters.ll index 4bc57ec6ef0..4c1905b2eaa 100644 --- a/llvm/test/Instrumentation/InstrProfiling/no-counters.ll +++ b/llvm/test/Instrumentation/InstrProfiling/no-counters.ll @@ -1,10 +1,12 @@ -;; No instrumentation should be emitted if there are no counter increments. +;; Emit the runtime hook even if there are no counter increments. -; RUN: opt < %s -instrprof -S | FileCheck %s -; RUN: opt < %s -passes=instrprof -S | FileCheck %s -; CHECK-NOT: @__profc -; CHECK-NOT: @__profd -; CHECK-NOT: @__llvm_profile_runtime +; RUN: opt < %s -mtriple=x86_64-apple-macosx10.10.0 -instrprof -S | FileCheck %s -check-prefixes=ALL,DARWIN +; RUN: opt < %s -mtriple=x86_64-apple-macosx10.10.0 -passes=instrprof -S | FileCheck %s -check-prefixes=ALL,DARWIN +; RUN: opt < %s -mtriple=x86_64-linux-unknown -passes=instrprof -S | FileCheck %s -check-prefixes=ALL,LINUX +; ALL-NOT: @__profc +; ALL-NOT: @__profd +; DARWIN: @__llvm_profile_runtime +; LINUX-NOT: @__llvm_profile_runtime define void @foo() { ret void diff --git a/llvm/test/Instrumentation/InstrProfiling/profiling.ll b/llvm/test/Instrumentation/InstrProfiling/profiling.ll index c4cc1d9ce43..67a5d627c8b 100644 --- a/llvm/test/Instrumentation/InstrProfiling/profiling.ll +++ b/llvm/test/Instrumentation/InstrProfiling/profiling.ll @@ -3,6 +3,8 @@ target triple = "x86_64-apple-macosx10.10.0" +; CHECK: @__llvm_profile_runtime = external global i32 + @__profn_foo = hidden constant [3 x i8] c"foo" ; CHECK-NOT: __profn_foo @__profn_bar = hidden constant [4 x i8] c"bar\00" @@ -35,5 +37,4 @@ define void @baz() { declare void @llvm.instrprof.increment(i8*, i64, i32, i32) -; CHECK: @__llvm_profile_runtime = external global i32 ; CHECK: @llvm.used = appending global {{.*}} @__profd_foo {{.*}} @__profd_bar {{.*}} @__profd_baz {{.*}} section "llvm.metadata" |

