diff options
| -rw-r--r-- | llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp | 2 | ||||
| -rw-r--r-- | llvm/test/Instrumentation/InstrProfiling/linkage.ll | 3 |
2 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp index 97e8bd1ae11..120ed18b06e 100644 --- a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp +++ b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp @@ -550,6 +550,8 @@ void InstrProfiling::emitRuntimeHook() { User->addFnAttr(Attribute::NoInline); if (Options.NoRedZone) User->addFnAttr(Attribute::NoRedZone); User->setVisibility(GlobalValue::HiddenVisibility); + if (Triple(M->getTargetTriple()).isOSBinFormatCOFF()) + User->setComdat(M->getOrInsertComdat(User->getName())); IRBuilder<> IRB(BasicBlock::Create(M->getContext(), "", User)); auto *Load = IRB.CreateLoad(Var); diff --git a/llvm/test/Instrumentation/InstrProfiling/linkage.ll b/llvm/test/Instrumentation/InstrProfiling/linkage.ll index c4344b6617c..72320ef523b 100644 --- a/llvm/test/Instrumentation/InstrProfiling/linkage.ll +++ b/llvm/test/Instrumentation/InstrProfiling/linkage.ll @@ -4,6 +4,8 @@ ; 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 @__profn_foo = hidden constant [3 x i8] c"foo" @__profn_foo_weak = weak hidden constant [8 x i8] c"foo_weak" @@ -57,5 +59,6 @@ declare void @llvm.instrprof.increment(i8*, i64, i32, i32) ; OTHER: %[[REG:.*]] = load i32, i32* @__llvm_profile_runtime ; OTHER: ret i32 %[[REG]] ; OTHER: } +; 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 |

