@@ -95,7 +95,7 @@ static cl::opt<bool> ClInsertVersionCheck(
9595// This flag may need to be replaced with -f[no-]memprof-reads.
9696static 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
100100static 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
183186extern cl::opt<bool > MemProfReportHintedSizes;
184187extern 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 ();
0 commit comments