Skip to content

Commit 85ed751

Browse files
author
Snehasish Kumar
committed
Undo unrelated change.
1 parent 918d650 commit 85ed751

File tree

3 files changed

+18
-19
lines changed

3 files changed

+18
-19
lines changed

llvm/lib/Transforms/Instrumentation/MemProfiler.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ static cl::opt<bool> ClInsertVersionCheck(
9595
// This flag may need to be replaced with -f[no-]memprof-reads.
9696
static cl::opt<bool> ClInstrumentReads("memprof-instrument-reads",
9797
cl::desc("instrument read instructions"),
98-
cl::Hidden, cl::init(false));
98+
cl::Hidden, cl::init(true));
9999

100100
static cl::opt<bool>
101101
ClInstrumentWrites("memprof-instrument-writes",
@@ -177,8 +177,11 @@ static cl::opt<bool>
177177
cl::desc("Salvage stale MemProf profile"),
178178
cl::init(false), cl::Hidden);
179179

180-
static cl::opt<bool> ClMemProfAttachCalleeGuids("memprof-attach-calleeguids",
181-
cl::init(false));
180+
static cl::opt<bool> ClMemProfAttachCalleeGuids(
181+
"memprof-attach-calleeguids",
182+
cl::desc(
183+
"Attach calleeguids as value profile metadata for indirect calls."),
184+
cl::init(true), cl::Hidden);
182185

183186
extern cl::opt<bool> MemProfReportHintedSizes;
184187
extern cl::opt<unsigned> MinClonedColdBytePercent;
@@ -974,8 +977,6 @@ static void addVPMetadata(Module &M, Instruction &I,
974977
return;
975978

976979
if (I.getMetadata(LLVMContext::MD_prof)) {
977-
// Use the existing helper function to check for indirect call
978-
// target value profiling metadata
979980
uint64_t Unused;
980981
auto ExistingVD =
981982
getValueProfDataFromInst(I, IPVK_IndirectCallTarget, ~0U, Unused);
@@ -988,20 +989,17 @@ static void addVPMetadata(Module &M, Instruction &I,
988989
SmallVector<InstrProfValueData, 4> VDs;
989990
uint64_t TotalCount = 0;
990991

991-
for (GlobalValue::GUID CalleeGUID : CalleeGuids) {
992-
// For MemProf, we don't have actual call counts, so we assign
993-
// a weight of 1 to each potential target. This provides the
994-
// information needed for indirect call promotion without
995-
// specific count data.
992+
for (const GlobalValue::GUID CalleeGUID : CalleeGuids) {
996993
InstrProfValueData VD;
997994
VD.Value = CalleeGUID;
998-
VD.Count = 1; // Weight for ICP decision making
995+
// For MemProf, we don't have actual call counts, so we assign
996+
// a weight of 1 to each potential target.
997+
VD.Count = 1;
999998
VDs.push_back(VD);
1000999
TotalCount += VD.Count;
10011000
}
10021001

10031002
if (!VDs.empty()) {
1004-
// Attach value profile metadata for indirect call targets
10051003
annotateValueSite(M, I, VDs, TotalCount, IPVK_IndirectCallTarget,
10061004
VDs.size());
10071005
}
@@ -1075,12 +1073,16 @@ readMemprof(Module &M, Function &F, IndexedInstrProfReader *MemProfReader,
10751073
// (allocation info and the callsites).
10761074
std::map<uint64_t, std::set<const AllocationInfo *>> LocHashToAllocInfo;
10771075

1076+
// Helper struct for maintaining refs to callsite data. As an alternative we
1077+
// could store a pointer to the CallSiteInfo struct but we also need the frame
1078+
// index. Using ArrayRefs instead makes it a little easier to read.
10781079
struct CallSiteEntry {
10791080
// Subset of frames for the corresponding CallSiteInfo.
10801081
ArrayRef<Frame> Frames;
10811082
// Potential targets for indirect calls.
10821083
ArrayRef<GlobalValue::GUID> CalleeGuids;
10831084

1085+
// Only compare Frame contents.
10841086
bool operator==(const CallSiteEntry &Other) const {
10851087
return Frames.data() == Other.Frames.data() &&
10861088
Frames.size() == Other.Frames.size();

llvm/test/Transforms/PGOProfile/memprof_annotate_indirect_call_fdo_conflict.test

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,17 @@ entry:
2525
%fp = alloca ptr, align 8
2626
%0 = load ptr, ptr %fp, align 8
2727
; This call already has FDO value profile metadata - should NOT be modified
28+
; CHECK: call void %0(), {{.*}} !prof !6
29+
; CHECK-NOT: call void %0(), {{.*}} !prof ![[NEWPROF:[0-9]+]]
2830
call void %0(), !dbg !5, !prof !6
29-
; CHECK: call void %0(), {{.*}} !prof !6
30-
; CHECK-NOT: call void %0(), {{.*}} !prof ![[NEWPROF:[0-9]+]]
3131

32-
; This call does NOT have existing metadata - should get MemProf annotation
3332
%1 = load ptr, ptr %fp, align 8
33+
; This call does NOT have existing metadata - should get MemProf annotation
34+
; CHECK: call void %1(), {{.*}} !prof ![[NEWPROF:[0-9]+]]
3435
call void %1(), !dbg !7
35-
; CHECK: call void %1(), {{.*}} !prof ![[NEWPROF:[0-9]+]]
3636
ret void
3737
}
3838

39-
; Existing FDO value profile metadata (should be preserved)
4039
!6 = !{!"VP", i32 0, i64 100, i64 9191153033785521275, i64 80, i64 -1069303473483922844, i64 20}
4140

4241
; CHECK: !6 = !{!"VP", i32 0, i64 100, i64 9191153033785521275, i64 80, i64 -1069303473483922844, i64 20}

llvm/test/Transforms/PGOProfile/memprof_annotate_indirect_call_yaml.test

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
; RUN: split-file %s %t
55
; RUN: llvm-profdata merge --memprof-version=4 %t/memprof_annotate_indirect_call_yaml.yaml -o %t/memprof_annotate_indirect_call_yaml.memprofdata
6-
; RUN: opt < %t/memprof_annotate_indirect_call_yaml.ll -passes='memprof-use<profile-filename=%t/memprof_annotate_indirect_call_yaml.memprofdata>' -S 2>&1 | FileCheck %s
76
; RUN: opt < %t/memprof_annotate_indirect_call_yaml.ll -passes='memprof-use<profile-filename=%t/memprof_annotate_indirect_call_yaml.memprofdata>' -memprof-attach-calleeguids=false -S 2>&1 | FileCheck %s --check-prefix=CHECK-DISABLE
87
; RUN: opt < %t/memprof_annotate_indirect_call_yaml.ll -passes='memprof-use<profile-filename=%t/memprof_annotate_indirect_call_yaml.memprofdata>' -memprof-attach-calleeguids=true -S 2>&1 | FileCheck %s --check-prefix=CHECK-ENABLE
98

@@ -23,7 +22,6 @@ entry:
2322
%fp = alloca ptr, align 8
2423
%0 = load ptr, ptr %fp, align 8
2524
call void %0(), !dbg !5
26-
; CHECK-NOT: !prof
2725
; CHECK-ENABLE: call void %0(), {{.*}} !prof ![[PROF:[0-9]+]]
2826
; CHECK-DISABLE-NOT: !prof
2927
ret void

0 commit comments

Comments
 (0)