Skip to content

Commit cca510e

Browse files
Simplify tests and relax restrictive checks.
1 parent 4936920 commit cca510e

File tree

3 files changed

+22
-35
lines changed

3 files changed

+22
-35
lines changed

compiler-rt/test/profile/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set(PROFILE_TESTSUITES)
66
set(PROFILE_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS} compiler-rt-headers)
77
list(APPEND PROFILE_TEST_DEPS profile)
88
if(NOT COMPILER_RT_STANDALONE_BUILD)
9-
list(APPEND PROFILE_TEST_DEPS llvm-cov llvm-dis llvm-lto llvm-profdata opt)
9+
list(APPEND PROFILE_TEST_DEPS llvm-cov llvm-lto llvm-profdata opt)
1010
if(NOT APPLE AND COMPILER_RT_HAS_LLD AND "lld" IN_LIST LLVM_ENABLE_PROJECTS)
1111
list(APPEND PROFILE_TEST_DEPS lld)
1212
endif()

compiler-rt/test/profile/instrprof-thinlto-indirect-call-promotion.cpp

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
// - Generate ThinLTO summary file with LLVM bitcodes, and run `function-import` pass.
1414
// - Run `pgo-icall-prom` pass for the IR module which needs to import callees.
1515

16+
// This test and IR test llvm/test/Transforms/PGOProfile/thinlto_indirect_call_promotion.ll
17+
// are complementary to each other; a compiler-rt test has better test coverage
18+
// on different platforms, and the IR test is less restrictive in terms of
19+
// running environment and could be executed more widely.
20+
1621
// Use lld as linker for more robust test. We need to REQUIRE LLVMgold.so for
1722
// LTO if default linker is GNU ld or gold anyway.
1823
// REQUIRES: lld-available
@@ -40,12 +45,9 @@
4045
// RUN: env LLVM_PROFILE_FILE=main.profraw %run ./main
4146
// RUN: llvm-profdata merge main.profraw -o main.profdata
4247

43-
// Use profile on lib and get bitcode, test that local function callee0 has
44-
// expected !PGOFuncName metadata and external function callee1 doesn't have
45-
// !PGOFuncName metadata. Explicitly skip ICP pass to test ICP happens as
48+
// Use profile on lib and get bitcode. Explicitly skip ICP pass to test ICP happens as
4649
// expected in the IR module that imports functions from lib.
4750
// RUN: %clang -mllvm -disable-icp -fprofile-use=main.profdata -flto=thin -O2 -c lib.cpp -o lib.bc
48-
// RUN: llvm-dis lib.bc -o - | FileCheck %s --check-prefix=PGOName
4951

5052
// Use profile on main and get bitcode.
5153
// RUN: %clang -fprofile-use=main.profdata -flto=thin -O2 -c main.cpp -o main.bc
@@ -58,35 +60,20 @@
5860
// block with a function-entry-count of one, so they are actually hot functions
5961
// per default profile summary hotness cutoff.
6062
// RUN: opt -passes=function-import -import-instr-limit=100 -import-cold-multiplier=1 -summary-file summary.thinlto.bc main.bc -o main.import.bc -print-imports 2>&1 | FileCheck %s --check-prefix=IMPORTS
61-
// Test that '_Z11global_funcv' has indirect calls annotated with value profiles.
62-
// RUN: llvm-dis main.import.bc -o - | FileCheck %s --check-prefix=IR
6363

6464
// Test that both candidates are ICP'ed and there is no `!VP` in the IR.
6565
// RUN: opt main.import.bc -icp-lto -passes=pgo-icall-prom -S -pass-remarks=pgo-icall-prom 2>&1 | FileCheck %s --check-prefixes=ICP-IR,ICP-REMARK --implicit-check-not="!VP"
6666

67-
// IMPORTS: main.cpp: Import _Z7callee1v
68-
// IMPORTS: main.cpp: Import _ZL7callee0v.llvm.[[#]]
69-
// IMPORTS: main.cpp: Import _Z11global_funcv
70-
71-
// PGOName: define {{(dso_local )?}}void @_Z7callee1v() #[[#]] !prof ![[#]] {
72-
// PGOName: define internal void @_ZL7callee0v() #[[#]] !prof ![[#]] !PGOFuncName ![[#MD:]] {
73-
// PGOName: ![[#MD]] = !{!"{{.*}}lib.cpp;_ZL7callee0v"}
74-
75-
// IR-LABEL: define available_externally {{.*}} void @_Z11global_funcv() {{.*}} !prof ![[#]] {
76-
// IR-NEXT: entry:
77-
// IR-NEXT: %0 = load ptr, ptr @calleeAddrs
78-
// IR-NEXT: tail call void %0(), !prof ![[#PROF1:]]
79-
// IR-NEXT: %1 = load ptr, ptr getelementptr inbounds ([2 x ptr], ptr @calleeAddrs,
80-
// IR-NEXT: tail call void %1(), !prof ![[#PROF2:]]
81-
82-
// The GUID of indirect callee is the MD5 hash of `/path/to/lib.cpp;_ZL7callee0v`
83-
// that depends on the directory. Use [[#]] for its MD5 hash.
84-
// Use {{.*}} for integer types so the test works on 32-bit and 64-bit systems.
85-
// IR: ![[#PROF1]] = !{!"VP", i32 0, {{.*}} 1, {{.*}} [[#]], {{.*}} 1}
86-
// IR: ![[#PROF2]] = !{!"VP", i32 0, {{.*}} 1, {{.*}} -3993653843325621743, {{.*}} 1}
87-
88-
// ICP-REMARK: Promote indirect call to _ZL7callee0v.llvm.[[#]] with count 1 out of 1
89-
// ICP-REMARK: Promote indirect call to _Z7callee1v with count 1 out of 1
67+
// IMPORTS-DAG: main.cpp: Import {{.*}}callee1{{.*}}
68+
// IMPORTS-DAG: main.cpp: Import {{.*}}callee0{{.*}}llvm.[[#]]
69+
// IMPORTS-DAG: main.cpp: Import {{.*}}global_func{{.*}}
70+
71+
// PGOName-DAG: define {{.*}}callee1{{.*}} !prof ![[#]] {
72+
// PGOName-DAG: define internal {{.*}}callee0{{.*}} !prof ![[#]] !PGOFuncName ![[#MD:]] {
73+
// PGOName-DAG: ![[#MD]] = !{!"{{.*}}lib.cpp;{{.*}}callee0{{.*}}"}
74+
75+
// ICP-REMARK: Promote indirect call to {{.*}}callee0{{.*}}llvm.[[#]] with count 1 out of 1
76+
// ICP-REMARK: Promote indirect call to {{.*}}callee1{{.*}} with count 1 out of 1
9077

9178
// ICP-IR: br i1 %[[#]], label %if.true.direct_targ, label %if.false.orig_indirect, !prof ![[#BRANCH_WEIGHT1:]]
9279
// ICP-IR: br i1 %[[#]], label %if.true.direct_targ1, label %if.false.orig_indirect2, !prof ![[#BRANCH_WEIGHT1]]

llvm/test/Transforms/PGOProfile/thinlto_indirect_call_promotion.ll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@
2323

2424
; Test that callee with local linkage has `PGOFuncName` metadata while callee with external doesn't have it.
2525
; RUN: llvm-dis lib.bc -o - | FileCheck %s --check-prefix=PGOName
26-
; PGOName: define void @_Z7callee1v() {{.*}} !prof ![[#]] {
27-
; PGOName: define internal void @_ZL7callee0v() {{.*}} !prof ![[#]] !PGOFuncName ![[#MD:]] {
26+
; PGOName-DAG: define void @_Z7callee1v() {{.*}} !prof ![[#]] {
27+
; PGOName-DAG: define internal void @_ZL7callee0v() {{.*}} !prof ![[#]] !PGOFuncName ![[#MD:]] {
2828
; The source filename of `lib.ll` is specified as "lib.cc" (i.e., the name does
2929
; not change with the directory), so match the full name here.
3030
; PGOName: ![[#MD]] = !{!"lib.cc;_ZL7callee0v"}
3131

3232
; Tests that both external and internal callees are correctly imported.
3333
; RUN: opt -passes=function-import -summary-file summary.thinlto.bc main.bc -o main.import.bc -print-imports 2>&1 | FileCheck %s --check-prefix=IMPORTS
34-
; IMPORTS: Import _Z7callee1v
35-
; IMPORTS: Import _ZL7callee0v.llvm.[[#]]
36-
; IMPORTS: Import _Z11global_funcv
34+
; IMPORTS-DAG: Import _Z7callee1v
35+
; IMPORTS-DAG: Import _ZL7callee0v.llvm.[[#]]
36+
; IMPORTS-DAG: Import _Z11global_funcv
3737

3838
; Tests that ICP transformations happen.
3939
; Both candidates are ICP'ed, check there is no `!VP` in the IR.

0 commit comments

Comments
 (0)