Skip to content

Commit a6283e7

Browse files
author
Snehasish Kumar
committed
Address comments.
1 parent ca1cc24 commit a6283e7

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

llvm/lib/Transforms/Instrumentation/MemProfiler.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -978,8 +978,9 @@ static void addVPMetadata(Module &M, Instruction &I,
978978

979979
if (I.getMetadata(LLVMContext::MD_prof)) {
980980
uint64_t Unused;
981-
auto ExistingVD =
982-
getValueProfDataFromInst(I, IPVK_IndirectCallTarget, ~0U, Unused);
981+
// ~0U means get all available value profile data without any count limit
982+
auto ExistingVD = getValueProfDataFromInst(I, IPVK_IndirectCallTarget,
983+
/*MaxNumValueData=*/~0U, Unused);
983984
// We don't know how to merge value profile data yet.
984985
if (!ExistingVD.empty()) {
985986
return;
@@ -994,6 +995,8 @@ static void addVPMetadata(Module &M, Instruction &I,
994995
VD.Value = CalleeGUID;
995996
// For MemProf, we don't have actual call counts, so we assign
996997
// a weight of 1 to each potential target.
998+
// TODO: Consider making this weight configurable or increasing it to
999+
// improve effectiveness for ICP.
9971000
VD.Count = 1;
9981001
VDs.push_back(VD);
9991002
TotalCount += VD.Count;
@@ -1083,6 +1086,9 @@ readMemprof(Module &M, Function &F, IndexedInstrProfReader *MemProfReader,
10831086
ArrayRef<GlobalValue::GUID> CalleeGuids;
10841087

10851088
// Only compare Frame contents.
1089+
// Use pointer-based equality instead of ArrayRef's operator== which does
1090+
// element-wise comparison. We want to check if it's the same slice of the
1091+
// underlying array, not just equivalent content.
10861092
bool operator==(const CallSiteEntry &Other) const {
10871093
return Frames.data() == Other.Frames.data() &&
10881094
Frames.size() == Other.Frames.size();
@@ -1271,9 +1277,8 @@ readMemprof(Module &M, Function &F, IndexedInstrProfReader *MemProfReader,
12711277
addCallsiteMetadata(I, InlinedCallStack, Ctx);
12721278

12731279
// Try to attach indirect call metadata if possible.
1274-
if (!CalledFunction) {
1280+
if (!CalledFunction)
12751281
addVPMetadata(M, I, CallSiteEntry.CalleeGuids);
1276-
}
12771282

12781283
// Only need to find one with a matching call stack and add a single
12791284
// callsite metadata.

llvm/test/Transforms/PGOProfile/memprof_annotate_indirect_call.test

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
; RUN: split-file %s %t
22

3-
; COM: Basic functionality with flag toggle
3+
;; Basic functionality with flag toggle
44
; RUN: llvm-profdata merge --memprof-version=4 %t/basic.yaml -o %t/basic.memprofdata
55
; RUN: opt < %t/basic.ll -passes='memprof-use<profile-filename=%t/basic.memprofdata>' -memprof-attach-calleeguids=false -S 2>&1 | FileCheck %s --check-prefix=CHECK-DISABLE
66
; RUN: opt < %t/basic.ll -passes='memprof-use<profile-filename=%t/basic.memprofdata>' -memprof-attach-calleeguids=true -S 2>&1 | FileCheck %s --check-prefix=CHECK-ENABLE
77

8-
; COM: FDO conflict handling
8+
;; FDO conflict handling
99
; RUN: llvm-profdata merge --memprof-version=4 %t/fdo_conflict.yaml -o %t/fdo_conflict.memprofdata
1010
; RUN: opt < %t/fdo_conflict.ll -passes='memprof-use<profile-filename=%t/fdo_conflict.memprofdata>' -memprof-attach-calleeguids=true -S 2>&1 | FileCheck %s --check-prefix=CHECK-FDO
1111

@@ -63,7 +63,6 @@ entry:
6363
%0 = load ptr, ptr %fp, align 8
6464
; This call already has FDO value profile metadata - should NOT be modified
6565
; CHECK-FDO: call void %0(), {{.*}} !prof !6
66-
; CHECK-FDO-NOT: call void %0(), {{.*}} !prof !9
6766
call void %0(), !dbg !15, !prof !16
6867

6968
%1 = load ptr, ptr %fp, align 8

0 commit comments

Comments
 (0)