[llvm] r338172 - [InstrProf] Don't register __llvm_profile_runtime_user

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 27 15:21:35 PDT 2018


Author: rnk
Date: Fri Jul 27 15:21:35 2018
New Revision: 338172

URL: http://llvm.org/viewvc/llvm-project?rev=338172&view=rev
Log:
[InstrProf] Don't register __llvm_profile_runtime_user

Refactor some FileCheck prefixes while I'm at it.

Fixes PR38340

Modified:
    llvm/trunk/lib/Transforms/Instrumentation/InstrProfiling.cpp
    llvm/trunk/test/Instrumentation/InstrProfiling/linkage.ll
    llvm/trunk/test/Instrumentation/InstrProfiling/platform.ll

Modified: llvm/trunk/lib/Transforms/Instrumentation/InstrProfiling.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/InstrProfiling.cpp?rev=338172&r1=338171&r2=338172&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/InstrProfiling.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/InstrProfiling.cpp Fri Jul 27 15:21:35 2018
@@ -898,7 +898,7 @@ void InstrProfiling::emitRegistration()
 
   IRBuilder<> IRB(BasicBlock::Create(M->getContext(), "", RegisterF));
   for (Value *Data : UsedVars)
-    if (Data != NamesVar)
+    if (Data != NamesVar && !isa<Function>(Data))
       IRB.CreateCall(RuntimeRegisterF, IRB.CreateBitCast(Data, VoidPtrTy));
 
   if (NamesVar) {

Modified: llvm/trunk/test/Instrumentation/InstrProfiling/linkage.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/InstrProfiling/linkage.ll?rev=338172&r1=338171&r2=338172&view=diff
==============================================================================
--- llvm/trunk/test/Instrumentation/InstrProfiling/linkage.ll (original)
+++ llvm/trunk/test/Instrumentation/InstrProfiling/linkage.ll Fri Jul 27 15:21:35 2018
@@ -1,13 +1,13 @@
 ;; Check that runtime symbols get appropriate linkage.
 
-; RUN: opt < %s -mtriple=x86_64-apple-macosx10.10.0 -instrprof -S | FileCheck %s --check-prefix=OTHER --check-prefix=COMMON
-; RUN: opt < %s -mtriple=x86_64-unknown-linux -instrprof -S | FileCheck %s --check-prefix=LINUX --check-prefix=COMMON
-; RUN: opt < %s -mtriple=x86_64-apple-macosx10.10.0 -passes=instrprof -S | FileCheck %s --check-prefix=OTHER --check-prefix=COMMON
-; RUN: opt < %s -mtriple=x86_64-unknown-linux -passes=instrprof -S | FileCheck %s --check-prefix=LINUX --check-prefix=COMMON
-; 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
+; RUN: opt < %s -mtriple=x86_64-apple-macosx10.10.0 -instrprof -S | FileCheck %s --check-prefixes=COMMON,MACHO
+; RUN: opt < %s -mtriple=x86_64-unknown-linux -instrprof -S | FileCheck %s --check-prefixes=COMMON,LINUX
+; RUN: opt < %s  -mtriple=x86_64-pc-win32-coff -instrprof -S | FileCheck %s --check-prefixes=COMMON,COFF
+; RUN: opt < %s -mtriple=x86_64-apple-macosx10.10.0 -passes=instrprof -S | FileCheck %s --check-prefixes=COMMON,MACHO
+; RUN: opt < %s -mtriple=x86_64-unknown-linux -passes=instrprof -S | FileCheck %s --check-prefixes=COMMON,LINUX
+; RUN: opt < %s  -mtriple=x86_64-pc-win32-coff -passes=instrprof -S | FileCheck %s --check-prefixes=COMMON,COFF
 
-; OTHER: @__llvm_profile_runtime = external global i32
+; MACHO: @__llvm_profile_runtime = external global i32
 ; LINUX-NOT: @__llvm_profile_runtime = external global i32
 
 @__profn_foo = hidden constant [3 x i8] c"foo"
@@ -32,18 +32,15 @@ define weak void @foo_weak() {
 
 ; COMMON: @"__profc_linkage.ll:foo_internal" = internal global
 ; COMMON: @"__profd_linkage.ll:foo_internal" = internal global
-; COFF: @"__profc_linkage.ll:foo_internal" = internal global
-; COFF: @"__profd_linkage.ll:foo_internal" = internal global
 define internal void @foo_internal() {
   call void @llvm.instrprof.increment(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @"__profn_linkage.ll:foo_internal", i32 0, i32 0), i64 0, i32 1, i32 0)
   ret void
 }
 
 ; COMMON: @__profc_foo_inline = linkonce_odr hidden global
+; COFF-SAME: section ".lprfc", align 8
 ; COMMON: @__profd_foo_inline = linkonce_odr hidden global
-; FIXME: Should we put a comdat here?
-; COFF: @__profc_foo_inline = linkonce_odr hidden global {{.*}}section ".lprfc", align 8
-; COFF: @__profd_foo_inline = linkonce_odr hidden global {{.*}}section ".lprfd", align 8
+; COFF-SAME: section ".lprfd", align 8
 define linkonce_odr void @foo_inline() {
   call void @llvm.instrprof.increment(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @__profn_foo_inline, i32 0, i32 0), i64 0, i32 1, i32 0)
   ret void
@@ -51,8 +48,8 @@ define linkonce_odr void @foo_inline() {
 
 ; LINUX: @__profc_foo_extern = linkonce_odr hidden global {{.*}}section "__llvm_prf_cnts", comdat($__profv_foo_extern), align 8
 ; LINUX: @__profd_foo_extern = linkonce_odr hidden global {{.*}}section "__llvm_prf_data", comdat($__profv_foo_extern), align 8
-; OTHER: @__profc_foo_extern = linkonce_odr hidden global
-; OTHER: @__profd_foo_extern = linkonce_odr hidden global
+; MACHO: @__profc_foo_extern = linkonce_odr hidden global
+; MACHO: @__profd_foo_extern = linkonce_odr hidden global
 ; COFF: @__profc_foo_extern = linkonce_odr hidden global {{.*}}section ".lprfc", comdat, align 8
 ; COFF: @__profd_foo_extern = linkonce_odr hidden global {{.*}}section ".lprfd", comdat($__profc_foo_extern), align 8
 define available_externally void @foo_extern() {
@@ -62,10 +59,10 @@ define available_externally void @foo_ex
 
 declare void @llvm.instrprof.increment(i8*, i64, i32, i32)
 
-; OTHER: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() {{.*}} {
-; OTHER:   %[[REG:.*]] = load i32, i32* @__llvm_profile_runtime
-; OTHER:   ret i32 %[[REG]]
-; OTHER: }
+; MACHO: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() {{.*}} {
+; MACHO:   %[[REG:.*]] = load i32, i32* @__llvm_profile_runtime
+; MACHO:   ret i32 %[[REG]]
+; MACHO: }
 ; COFF: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() {{.*}} comdat {
 ; LINUX-NOT: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() {{.*}} {
 ; LINUX-NOT:   %[[REG:.*]] = load i32, i32* @__llvm_profile_runtime

Modified: llvm/trunk/test/Instrumentation/InstrProfiling/platform.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/InstrProfiling/platform.ll?rev=338172&r1=338171&r2=338172&view=diff
==============================================================================
--- llvm/trunk/test/Instrumentation/InstrProfiling/platform.ll (original)
+++ llvm/trunk/test/Instrumentation/InstrProfiling/platform.ll Fri Jul 27 15:21:35 2018
@@ -2,27 +2,29 @@
 
 ; RUN: opt < %s -mtriple=x86_64-apple-macosx10.10.0 -instrprof -S | FileCheck %s -check-prefix=MACHO
 ; RUN: opt < %s -mtriple=x86_64-apple-macosx10.10.0 -passes=instrprof -S | FileCheck %s -check-prefix=MACHO
-; RUN: opt < %s -mtriple=x86_64-unknown-linux -instrprof -S | FileCheck %s -check-prefix=LINUX
-; RUN: opt < %s -mtriple=x86_64-unknown-linux -passes=instrprof -S | FileCheck %s -check-prefix=LINUX
-; RUN: opt < %s -mtriple=x86_64-unknown-freebsd -instrprof -S | FileCheck %s -check-prefix=FREEBSD
-; RUN: opt < %s -mtriple=x86_64-unknown-freebsd -passes=instrprof -S | FileCheck %s -check-prefix=FREEBSD
-; RUN: opt < %s -mtriple=x86_64-scei-ps4 -instrprof -S | FileCheck %s -check-prefix=PS4
-; RUN: opt < %s -mtriple=x86_64-scei-ps4 -passes=instrprof -S | FileCheck %s -check-prefix=PS4
-; RUN: opt < %s -mtriple=x86_64-pc-solaris -instrprof -S | FileCheck %s -check-prefix=SOLARIS
-; RUN: opt < %s -mtriple=x86_64-pc-solaris -passes=instrprof -S | FileCheck %s -check-prefix=SOLARIS
+; RUN: opt < %s -mtriple=x86_64-unknown-linux -instrprof -S | FileCheck %s -check-prefixes=LINUX,ELF
+; RUN: opt < %s -mtriple=x86_64-unknown-linux -passes=instrprof -S | FileCheck %s -check-prefixes=LINUX,ELF
+; RUN: opt < %s -mtriple=x86_64-unknown-freebsd -instrprof -S | FileCheck %s -check-prefixes=FREEBSD,ELF
+; RUN: opt < %s -mtriple=x86_64-unknown-freebsd -passes=instrprof -S | FileCheck %s -check-prefixes=FREEBSD,ELF
+; RUN: opt < %s -mtriple=x86_64-scei-ps4 -instrprof -S | FileCheck %s -check-prefixes=PS4,ELF
+; RUN: opt < %s -mtriple=x86_64-scei-ps4 -passes=instrprof -S | FileCheck %s -check-prefixes=PS4,ELF
+; RUN: opt < %s -mtriple=x86_64-pc-solaris -instrprof -S | FileCheck %s -check-prefixes=SOLARIS,ELF
+; RUN: opt < %s -mtriple=x86_64-pc-solaris -passes=instrprof -S | FileCheck %s -check-prefixes=SOLARIS,ELF
+; RUN: opt < %s -mtriple=x86_64-pc-windows -instrprof -S | FileCheck %s -check-prefix=WINDOWS
+; RUN: opt < %s -mtriple=x86_64-pc-windows -passes=instrprof -S | FileCheck %s -check-prefix=WINDOWS
 
 @__profn_foo = hidden constant [3 x i8] c"foo"
 ; MACHO-NOT: __profn_foo
 ; ELF-NOT: __profn_foo
+; WINDOWS-NOT: __profn_foo
 
 ; MACHO: @__profc_foo = hidden global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8
 ; ELF: @__profc_foo = hidden global [1 x i64] zeroinitializer, section "__llvm_prf_cnts", align 8
+; WINDOWS: @__profc_foo = hidden global [1 x i64] zeroinitializer, section ".lprfc", align 8
 
 ; MACHO: @__profd_foo = hidden {{.*}}, section "__DATA,__llvm_prf_data,regular,live_support", align 8
-; LINUX: @__profd_foo = hidden {{.*}}, section "__llvm_prf_data", align 8
-; FREEBSD: @__profd_foo = hidden {{.*}}, section "__llvm_prf_data", align 8
-; PS4: @__profd_foo = hidden {{.*}}, section "__llvm_prf_data", align 8
-; SOLARIS: @__profd_foo = hidden {{.*}}, section "__llvm_prf_data", align 8
+; ELF: @__profd_foo = hidden {{.*}}, section "__llvm_prf_data", align 8
+; WINDOWS: @__profd_foo = hidden {{.*}}, section ".lprfd", align 8
 
 ; ELF: @__llvm_prf_nm = private constant [{{.*}} x i8] c"{{.*}}", section "{{.*}}__llvm_prf_names"
 
@@ -40,10 +42,21 @@ declare void @llvm.instrprof.increment(i
 ; LINUX-NOT: define internal void @__llvm_profile_register_functions
 ; FREEBSD-NOT: define internal void @__llvm_profile_register_functions
 ; PS4-NOT: define internal void @__llvm_profile_register_functions
+
+;; PR38340: When dynamic registration is used, we had a bug where we'd register
+;; something that's not a __profd_* variable.
+
+; WINDOWS: define internal void @__llvm_profile_register_functions()
+; WINDOWS-NOT: __llvm_profile_runtime_user
+; WINDOWS: ret void
+
 ; SOLARIS: define internal void @__llvm_profile_register_functions
+; SOLARIS-NOT: __llvm_profile_runtime_user
+; SOLARIS: ret void
 
 ; MACHO-NOT: define internal void @__llvm_profile_init
 ; LINUX-NOT: define internal void @__llvm_profile_init
 ; FREEBSD-NOT: define internal void @__llvm_profile_init
 ; PS4-NOT: define internal void @__llvm_profile_init
 ; SOLARIS: define internal void @__llvm_profile_init
+; WINDOWS: define internal void @__llvm_profile_init




More information about the llvm-commits mailing list