[llvm] r270596 - [profile] Fix runtime hook linkage bug for COFF
Xinliang David Li via llvm-commits
llvm-commits at lists.llvm.org
Tue May 24 11:47:38 PDT 2016
Author: davidxl
Date: Tue May 24 13:47:38 2016
New Revision: 270596
URL: http://llvm.org/viewvc/llvm-project?rev=270596&view=rev
Log:
[profile] Fix runtime hook linkage bug for COFF
Patch by: Johan Engelen
the user hook has linkonceODR linkage and it needs to be
in comdatAny group.
Modified:
llvm/trunk/lib/Transforms/Instrumentation/InstrProfiling.cpp
llvm/trunk/test/Instrumentation/InstrProfiling/linkage.ll
Modified: llvm/trunk/lib/Transforms/Instrumentation/InstrProfiling.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/InstrProfiling.cpp?rev=270596&r1=270595&r2=270596&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/InstrProfiling.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/InstrProfiling.cpp Tue May 24 13:47:38 2016
@@ -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);
Modified: llvm/trunk/test/Instrumentation/InstrProfiling/linkage.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/InstrProfiling/linkage.ll?rev=270596&r1=270595&r2=270596&view=diff
==============================================================================
--- llvm/trunk/test/Instrumentation/InstrProfiling/linkage.ll (original)
+++ llvm/trunk/test/Instrumentation/InstrProfiling/linkage.ll Tue May 24 13:47:38 2016
@@ -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(i
; 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
More information about the llvm-commits
mailing list