@@ -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.
0 commit comments