[llvm] 9f506fc - [InstrProfiling][test] Fix stale tests

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Fri May 28 21:14:09 PDT 2021


Author: Fangrui Song
Date: 2021-05-28T21:14:03-07:00
New Revision: 9f506fc761cc93ebc3854906e8886e1791c29d28

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

LOG: [InstrProfiling][test] Fix stale tests

* Change linkage/visibility of __profn_ variables to match the reality
* alwaysinline.ll: Add "EnableValueProfiling", otherwise it doesn't test available_externally alwaysinline.
* Delete PR23499.ll - covered by other comdat tests.

Added: 
    

Modified: 
    llvm/test/Instrumentation/InstrProfiling/always_inline.ll
    llvm/test/Instrumentation/InstrProfiling/atomic-updates.ll
    llvm/test/Instrumentation/InstrProfiling/early-exit.ll
    llvm/test/Instrumentation/InstrProfiling/linkage.ll
    llvm/test/Instrumentation/InstrProfiling/noruntime.ll
    llvm/test/Instrumentation/InstrProfiling/platform.ll
    llvm/test/Instrumentation/InstrProfiling/profiling.ll
    llvm/test/Instrumentation/InstrProfiling/runtime-counter-relocation.ll

Removed: 
    llvm/test/Instrumentation/InstrProfiling/PR23499.ll


################################################################################
diff  --git a/llvm/test/Instrumentation/InstrProfiling/PR23499.ll b/llvm/test/Instrumentation/InstrProfiling/PR23499.ll
deleted file mode 100644
index 88e8426ef6cb..000000000000
--- a/llvm/test/Instrumentation/InstrProfiling/PR23499.ll
+++ /dev/null
@@ -1,33 +0,0 @@
-;; Check that PGO instrumented variables associated with linkonce odr
-;; functions are placed in the same comdat section.
-
-
-; RUN: opt < %s -mtriple=x86_64-apple-macosx10.10.0 -instrprof -S | FileCheck %s
-; RUN: opt < %s -mtriple=x86_64-apple-macosx10.10.0 -passes=instrprof -S | FileCheck %s
-; RUN: opt < %s -mtriple=x86_64-unknown-linux -instrprof -S | FileCheck %s
-; RUN: opt < %s -mtriple=x86_64-unknown-linux -passes=instrprof -S | FileCheck %s
-; 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
-
-$_Z3barIvEvv = comdat any
-
- at __profn__Z3barIvEvv = linkonce_odr hidden constant [11 x i8] c"_Z3barIvEvv", align 1
-
-; CHECK-NOT: __profn__Z3barIvEvv
-; CHECK: @__profc__Z3barIvEvv = linkonce_odr hidden global [1 x i64] zeroinitializer, section "{{.*}}__llvm_prf_cnts", comdat($__profd__Z3barIvEvv), align 8
-; CHECK: @__profd__Z3barIvEvv = linkonce_odr hidden global { i64, i64, i64*, i8*, i8*, i32, [2 x i16] } { i64 4947693190065689389, i64 0, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc__Z3barIvEvv, i32 0, i32 0), i8*{{.*}}, i8* null, i32 1, [2 x i16] zeroinitializer }, section "{{.*}}__llvm_prf_data{{.*}}", comdat, align 8
-; CHECK: @__llvm_prf_nm = private constant [{{.*}} x i8] c"{{.*}}", section "{{.*}}__llvm_prf_names"
-
-
-; COFF-NOT: __profn__Z3barIvEvv
-; COFF: @__profc__Z3barIvEvv = linkonce_odr hidden global [1 x i64] zeroinitializer, section "{{.*}}prfc$M", comdat, align 8
-; COFF: @__profd__Z3barIvEvv = linkonce_odr hidden global { i64, i64, i64*, i8*, i8*, i32, [2 x i16] } { i64 4947693190065689389, i64 0, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc__Z3barIvEvv, i32 0, i32 0), i8*{{.*}}, i8* null, i32 1, [2 x i16] zeroinitializer }, section "{{.*}}prfd{{.*}}", comdat, align 8
-
-
-declare void @llvm.instrprof.increment(i8*, i64, i32, i32) #1
-
-define linkonce_odr void @_Z3barIvEvv() comdat {
-entry:
-  call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn__Z3barIvEvv, i32 0, i32 0), i64 0, i32 1, i32 0)
-  ret void
-}

diff  --git a/llvm/test/Instrumentation/InstrProfiling/always_inline.ll b/llvm/test/Instrumentation/InstrProfiling/always_inline.ll
index bddd3a402b62..9effb6f95796 100644
--- a/llvm/test/Instrumentation/InstrProfiling/always_inline.ll
+++ b/llvm/test/Instrumentation/InstrProfiling/always_inline.ll
@@ -1,11 +1,15 @@
 ; Check that '__attribute__((always_inline)) inline' functions are inlined.
 
-; RUN: opt < %s -mtriple=x86_64-apple-macosx10.10.0 -instrprof -inline -S -enable-new-pm=0 | FileCheck %s --check-prefixes=CHECK,LPM
 ; RUN: opt < %s -mtriple=x86_64-apple-macosx10.10.0 -passes='instrprof,inline' -S | FileCheck %s
 
 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-apple-macosx10.13.0"
 
+;; Don't record the address of an available_externally alwaysinline function.
+; CHECK:      @__profd_foo = linkonce_odr hidden global
+; CHECK-NOT:  @foo
+; CHECK-SAME: , align 8
+
 @__profn_foo = linkonce_odr hidden constant [3 x i8] c"foo"
 
 ; CHECK-LABEL: @main
@@ -18,7 +22,6 @@ entry:
 
 declare void @llvm.instrprof.increment(i8*, i64, i32, i32) #0
 
-; LPM-NOT: define available_externally i32 @foo
 define available_externally i32 @foo() #1 {
 entry:
   call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_foo, i32 0, i32 0), i64 0, i32 1, i32 0)
@@ -27,3 +30,6 @@ entry:
 
 attributes #0 = { nounwind }
 attributes #1 = { alwaysinline }
+
+!llvm.module.flags = !{!0}
+!0 = !{i32 2, !"EnableValueProfiling", i32 1}

diff  --git a/llvm/test/Instrumentation/InstrProfiling/atomic-updates.ll b/llvm/test/Instrumentation/InstrProfiling/atomic-updates.ll
index 7230a205dff0..691a11699026 100644
--- a/llvm/test/Instrumentation/InstrProfiling/atomic-updates.ll
+++ b/llvm/test/Instrumentation/InstrProfiling/atomic-updates.ll
@@ -2,7 +2,7 @@
 
 target triple = "x86_64-apple-macosx10.10.0"
 
- at __profn_foo = hidden constant [3 x i8] c"foo"
+ at __profn_foo = private constant [3 x i8] c"foo"
 
 ; CHECK-LABEL: define void @foo
 ; CHECK-NEXT: atomicrmw add i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc_foo, i64 0, i64 0), i64 1 monotonic

diff  --git a/llvm/test/Instrumentation/InstrProfiling/early-exit.ll b/llvm/test/Instrumentation/InstrProfiling/early-exit.ll
index bc19fbd8155e..e4e92b945bec 100644
--- a/llvm/test/Instrumentation/InstrProfiling/early-exit.ll
+++ b/llvm/test/Instrumentation/InstrProfiling/early-exit.ll
@@ -6,10 +6,10 @@ declare void @llvm.instrprof.increment(i8*, i64, i32, i32)
 
 declare void @llvm.instrprof.increment.step(i8*, i64, i32, i32, i64)
 
- at __profn_foo = hidden constant [3 x i8] c"foo"
+; CHECK: @__profc_foo = private global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8
+ at __profn_foo = private constant [3 x i8] c"foo"
 
 define void @foo() {
-; CHECK: @__profc_foo = hidden global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8
   call void @llvm.instrprof.increment.step(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_foo, i32 0, i32 0), i64 0, i32 1, i32 0, i64 0)
   ret void
 }

diff  --git a/llvm/test/Instrumentation/InstrProfiling/linkage.ll b/llvm/test/Instrumentation/InstrProfiling/linkage.ll
index 8de6a2ec6f0b..e982176047dd 100644
--- a/llvm/test/Instrumentation/InstrProfiling/linkage.ll
+++ b/llvm/test/Instrumentation/InstrProfiling/linkage.ll
@@ -18,16 +18,16 @@
 ; ELF: $__profd_foo_inline = comdat noduplicates
 ; ELF: $__profd_foo_extern = comdat any
 
- at __profn_foo = hidden constant [3 x i8] c"foo"
+ at __profn_foo = private 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"
 @__profn_foo_inline = linkonce_odr hidden constant [10 x i8] c"foo_inline"
 @__profn_foo_extern = linkonce_odr hidden constant [10 x i8] c"foo_extern"
 
-; ELF: @__profc_foo = hidden global{{.*}}section "__llvm_prf_cnts", comdat($__profd_foo)
-; ELF: @__profd_foo = hidden global{{.*}}section "__llvm_prf_data", comdat
-; MACHO: @__profc_foo = hidden global
-; MACHO: @__profd_foo = hidden global
+; ELF: @__profc_foo = private global {{.*}} section "__llvm_prf_cnts", comdat($__profd_foo)
+; ELF: @__profd_foo = private global {{.*}} section "__llvm_prf_data", comdat
+; MACHO: @__profc_foo = private global
+; MACHO: @__profd_foo = private global
 ; COFF: @__profc_foo = internal global
 ; COFF-NOT: comdat
 ; COFF: @__profd_foo = internal global

diff  --git a/llvm/test/Instrumentation/InstrProfiling/noruntime.ll b/llvm/test/Instrumentation/InstrProfiling/noruntime.ll
index 03b6a24a6b34..970884ff8516 100644
--- a/llvm/test/Instrumentation/InstrProfiling/noruntime.ll
+++ b/llvm/test/Instrumentation/InstrProfiling/noruntime.ll
@@ -7,7 +7,7 @@
 
 @__llvm_profile_runtime = global i32 0, align 4
 
- at __profn_foo = hidden constant [3 x i8] c"foo"
+ at __profn_foo = private constant [3 x i8] c"foo"
 
 define void @foo() {
   call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_foo, i32 0, i32 0), i64 0, i32 1, i32 0)

diff  --git a/llvm/test/Instrumentation/InstrProfiling/platform.ll b/llvm/test/Instrumentation/InstrProfiling/platform.ll
index a440c3e54d23..dad013d1b88b 100644
--- a/llvm/test/Instrumentation/InstrProfiling/platform.ll
+++ b/llvm/test/Instrumentation/InstrProfiling/platform.ll
@@ -29,7 +29,7 @@
 ; ELF: @__llvm_prf_nm = private constant [{{.*}} x i8] c"{{.*}}", section "{{.*}}__llvm_prf_names", align 1
 ; WINDOWS: @__llvm_prf_nm = private constant [{{.*}} x i8] c"{{.*}}", section "{{.*}}lprfn$M", align 1
 
-define void @foo() {
+define linkonce_odr void @foo() {
   call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_foo, i32 0, i32 0), i64 0, i32 1, i32 0)
   ret void
 }

diff  --git a/llvm/test/Instrumentation/InstrProfiling/profiling.ll b/llvm/test/Instrumentation/InstrProfiling/profiling.ll
index 44262ddf39ee..ca4a9b117020 100644
--- a/llvm/test/Instrumentation/InstrProfiling/profiling.ll
+++ b/llvm/test/Instrumentation/InstrProfiling/profiling.ll
@@ -10,17 +10,17 @@
 ; MACHO: @__llvm_profile_runtime = external global i32
 ; WIN: @__llvm_profile_runtime = external global i32
 
- at __profn_foo = hidden constant [3 x i8] c"foo"
+ at __profn_foo = private constant [3 x i8] c"foo"
 ; CHECK-NOT: __profn_foo
 @__profn_bar = hidden constant [4 x i8] c"bar\00"
 ; CHECK-NOT: __profn_bar
 @__profn_baz = hidden constant [3 x i8] c"baz"
 ; CHECK-NOT: __profn_baz
 
-; ELF:   @__profc_foo = hidden global [1 x i64] zeroinitializer, section "__llvm_prf_cnts", comdat($__profd_foo), align 8
-; ELF:   @__profd_foo = hidden {{.*}}, section "__llvm_prf_data", comdat, align 8
-; MACHO: @__profc_foo = hidden global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8
-; MACHO: @__profd_foo = hidden {{.*}}, section "__DATA,__llvm_prf_data,regular,live_support", align 8
+; ELF:   @__profc_foo = private global [1 x i64] zeroinitializer, section "__llvm_prf_cnts", comdat($__profd_foo), align 8
+; ELF:   @__profd_foo = private {{.*}}, section "__llvm_prf_data", comdat, align 8
+; MACHO: @__profc_foo = private global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8
+; MACHO: @__profd_foo = private {{.*}}, section "__DATA,__llvm_prf_data,regular,live_support", align 8
 ; WIN:   @__profc_foo = internal global [1 x i64] zeroinitializer, section ".lprfc$M", align 8
 ; WIN:   @__profd_foo = internal {{.*}}, section ".lprfd$M", align 8
 define void @foo() {
@@ -34,7 +34,7 @@ define void @foo() {
 ; MACHO: @__profd_bar = hidden {{.*}}, section "__DATA,__llvm_prf_data,regular,live_support", align 8
 ; WIN:   @__profc_bar = internal global [1 x i64] zeroinitializer, section ".lprfc$M", align 8
 ; WIN:   @__profd_bar = internal {{.*}}, section ".lprfd$M", align 8
-define void @bar() {
+define linkonce_odr void @bar() {
   call void @llvm.instrprof.increment(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @__profn_bar, i32 0, i32 0), i64 0, i32 1, i32 0)
   ret void
 }
@@ -45,7 +45,7 @@ define void @bar() {
 ; MACHO: @__profd_baz = hidden {{.*}}, section "__DATA,__llvm_prf_data,regular,live_support", align 8
 ; WIN:   @__profc_baz = internal global [3 x i64] zeroinitializer, section ".lprfc$M", align 8
 ; WIN:   @__profd_baz = internal {{.*}}, section ".lprfd$M", align 8
-define void @baz() {
+define linkonce_odr void @baz() {
   call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_baz, i32 0, i32 0), i64 0, i32 3, i32 0)
   call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_baz, i32 0, i32 0), i64 0, i32 3, i32 1)
   call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_baz, i32 0, i32 0), i64 0, i32 3, i32 2)

diff  --git a/llvm/test/Instrumentation/InstrProfiling/runtime-counter-relocation.ll b/llvm/test/Instrumentation/InstrProfiling/runtime-counter-relocation.ll
index 52065921bd76..672492474c5f 100644
--- a/llvm/test/Instrumentation/InstrProfiling/runtime-counter-relocation.ll
+++ b/llvm/test/Instrumentation/InstrProfiling/runtime-counter-relocation.ll
@@ -3,7 +3,7 @@
 
 target triple = "x86_64-unknown-linux-gnu"
 
- at __profn_foo = hidden constant [3 x i8] c"foo"
+ at __profn_foo = private constant [3 x i8] c"foo"
 ; RELOC: @__llvm_profile_counter_bias = linkonce_odr hidden global i64 0
 
 ; CHECK-LABEL: define void @foo


        


More information about the llvm-commits mailing list