Skip to content

Commit 3f60302

Browse files
committed
Reland "[PS4/PS5][profiling] Go back to the old way of doing a runtime hook"
Profiling stopped working for us after D98061, which was largely a Fuschia-specific patch but in one place used `isOSBinFormatELF` to make a decision. I'm adding a PS4/PS5 exception to that, so we can get profiling to work again. Differential Revision: https://reviews.llvm.org/D127506
1 parent dae2faf commit 3f60302

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1246,7 +1246,7 @@ bool InstrProfiling::emitRuntimeHook() {
12461246
new GlobalVariable(*M, Int32Ty, false, GlobalValue::ExternalLinkage,
12471247
nullptr, getInstrProfRuntimeHookVarName());
12481248

1249-
if (TT.isOSBinFormatELF()) {
1249+
if (TT.isOSBinFormatELF() && !TT.isPS()) {
12501250
// Mark the user variable as used so that it isn't stripped out.
12511251
CompilerUsedVars.push_back(Var);
12521252
} else {

llvm/test/Instrumentation/InstrProfiling/profiling.ll

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
; RUN: opt < %s -mtriple=x86_64-apple-macosx10.10.0 -passes=instrprof -S | FileCheck %s --check-prefixes=MACHO
44
; RUN: opt < %s -mtriple=x86_64 -passes=instrprof -S | FileCheck %s --check-prefix=ELF_GENERIC
5-
; RUN: opt < %s -mtriple=x86_64-unknown-linux -passes=instrprof -S | FileCheck %s --check-prefixes=ELF
6-
; RUN: opt < %s -mtriple=x86_64-unknown-fuchsia -passes=instrprof -S | FileCheck %s --check-prefixes=ELF
5+
; RUN: opt < %s -mtriple=x86_64-unknown-linux -passes=instrprof -S | FileCheck %s --check-prefixes=ELF,ELFRT
6+
; RUN: opt < %s -mtriple=x86_64-unknown-fuchsia -passes=instrprof -S | FileCheck %s --check-prefixes=ELF,ELFRT
7+
; RUN: opt < %s -mtriple=x86_64-scei-ps4 -passes=instrprof -S | FileCheck %s --check-prefixes=ELF,PS
8+
; RUN: opt < %s -mtriple=x86_64-sie-ps5 -passes=instrprof -S | FileCheck %s --check-prefixes=ELF,PS
79
; RUN: opt < %s -mtriple=x86_64-pc-win32-coff -passes=instrprof -S | FileCheck %s --check-prefixes=COFF
810
; RUN: opt < %s -mtriple=powerpc64-ibm-aix-xcoff -passes=instrprof -S | FileCheck %s --check-prefixes=XCOFF
911

@@ -104,8 +106,10 @@ declare void @llvm.instrprof.increment(i8*, i64, i32, i32)
104106
; MACHO: ret i32 %[[REG]]
105107
; MACHO: }
106108
; COFF: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() {{.*}} comdat {
107-
; ELF-NOT: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() {{.*}} {
108-
; ELF-NOT: %[[REG:.*]] = load i32, i32* @__llvm_profile_runtime
109+
; ELFRT-NOT: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() {{.*}} {
110+
; ELFRT-NOT: %[[REG:.*]] = load i32, i32* @__llvm_profile_runtime
111+
; PS: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() {{.*}} {
112+
; PS: %[[REG:.*]] = load i32, i32* @__llvm_profile_runtime
109113
; XCOFF: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() {{.*}} {
110114
; XCOFF: %[[REG:.*]] = load i32, i32* @__llvm_profile_runtime
111115
; XCOFF: ret i32 %[[REG]]

0 commit comments

Comments
 (0)