diff --git a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp --- a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp +++ b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp @@ -1246,7 +1246,7 @@ new GlobalVariable(*M, Int32Ty, false, GlobalValue::ExternalLinkage, nullptr, getInstrProfRuntimeHookVarName()); - if (TT.isOSBinFormatELF()) { + if (TT.isOSBinFormatELF() && !TT.isPS()) { // Mark the user variable as used so that it isn't stripped out. CompilerUsedVars.push_back(Var); } else { diff --git a/llvm/test/Instrumentation/InstrProfiling/profiling.ll b/llvm/test/Instrumentation/InstrProfiling/profiling.ll --- a/llvm/test/Instrumentation/InstrProfiling/profiling.ll +++ b/llvm/test/Instrumentation/InstrProfiling/profiling.ll @@ -2,8 +2,10 @@ ; RUN: opt < %s -mtriple=x86_64-apple-macosx10.10.0 -passes=instrprof -S | FileCheck %s --check-prefixes=MACHO ; RUN: opt < %s -mtriple=x86_64 -passes=instrprof -S | FileCheck %s --check-prefix=ELF_GENERIC -; RUN: opt < %s -mtriple=x86_64-unknown-linux -passes=instrprof -S | FileCheck %s --check-prefixes=ELF -; RUN: opt < %s -mtriple=x86_64-unknown-fuchsia -passes=instrprof -S | FileCheck %s --check-prefixes=ELF +; RUN: opt < %s -mtriple=x86_64-unknown-linux -passes=instrprof -S | FileCheck %s --check-prefixes=ELF,ELFRT +; RUN: opt < %s -mtriple=x86_64-unknown-fuchsia -passes=instrprof -S | FileCheck %s --check-prefixes=ELF,ELFRT +; RUN: opt < %s -mtriple=x86_64-scei-ps4 -passes=instrprof -S | FileCheck %s --check-prefixes=ELF,PS +; RUN: opt < %s -mtriple=x86_64-sie-ps5 -passes=instrprof -S | FileCheck %s --check-prefixes=ELF,PS ; RUN: opt < %s -mtriple=x86_64-pc-win32-coff -passes=instrprof -S | FileCheck %s --check-prefixes=COFF ; RUN: opt < %s -mtriple=powerpc64-ibm-aix-xcoff -passes=instrprof -S | FileCheck %s --check-prefixes=XCOFF @@ -104,8 +106,10 @@ ; MACHO: ret i32 %[[REG]] ; MACHO: } ; COFF: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() {{.*}} comdat { -; ELF-NOT: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() {{.*}} { -; ELF-NOT: %[[REG:.*]] = load i32, i32* @__llvm_profile_runtime +; ELFRT-NOT: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() {{.*}} { +; ELFRT-NOT: %[[REG:.*]] = load i32, i32* @__llvm_profile_runtime +; PS: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() {{.*}} { +; PS: %[[REG:.*]] = load i32, i32* @__llvm_profile_runtime ; XCOFF: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() {{.*}} { ; XCOFF: %[[REG:.*]] = load i32, i32* @__llvm_profile_runtime ; XCOFF: ret i32 %[[REG]]