Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1251,6 +1251,10 @@ void InstrProfiling::createDataVariable(InstrProfCntrInstBase *Inc,
GlobalVariable *NamePtr = Inc->getName();
auto &PD = ProfileDataMap[NamePtr];

// Return if data variable was already created.
if (PD.DataVar)
return;

LLVMContext &Ctx = M->getContext();

Function *Fn = Inc->getParent()->getParent();
Expand Down
26 changes: 26 additions & 0 deletions llvm/test/Instrumentation/InstrProfiling/inline-data-var.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
;; Check that only one data variable is created when an instrprof.increment is
;; inlined into more than one function.
; RUN: opt %s -passes='cgscc(inline),instrprof' -S | FileCheck %s

target triple = "x86_64-unknown-linux-gnu"

; CHECK: @__profd_foobar = private global
; CHECK-NOT @__profd_foobar

declare void @llvm.instrprof.increment(ptr %0, i64 %1, i32 %2, i32 %3)
@__profn_foobar = private constant [6 x i8] c"foobar"

define internal void @foobar() {
call void @llvm.instrprof.increment(ptr @__profn_foobar, i64 123456, i32 32, i32 0)
ret void
}

define void @foo() {
call void @foobar()
ret void
}

define void @bar() {
call void @foobar()
ret void
}