From 8015f885255c85810b7082e0585d40a1460fe35e Mon Sep 17 00:00:00 2001 From: Teresa Johnson Date: Tue, 13 Jun 2017 20:44:08 +0000 Subject: [PGO] Update VP metadata after memory intrinsic optimization Summary: Leave an updated VP metadata on the fallback memcpy intrinsic after specialization. This can be used for later possible expansion based on the average of the remaining values. Reviewers: davidxl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D34164 llvm-svn: 305321 --- llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'llvm/lib') diff --git a/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp b/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp index 96027bc3d0a..39a3ef2a49a 100644 --- a/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp +++ b/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp @@ -884,6 +884,7 @@ bool MemOPSizeOpt::perform(MemIntrinsic *MI) { // Keeping track of the count of the default case: uint64_t RemainCount = TotalCount; + uint64_t SavedRemainCount = SavedTotalCount; SmallVector SizeIds; SmallVector CaseCounts; uint64_t MaxCount = 0; @@ -912,6 +913,8 @@ bool MemOPSizeOpt::perform(MemIntrinsic *MI) { assert(RemainCount >= C); RemainCount -= C; + assert(SavedRemainCount >= VD.Count); + SavedRemainCount -= VD.Count; if (++Version > MemOPMaxVersion && MemOPMaxVersion != 0) break; @@ -968,6 +971,11 @@ bool MemOPSizeOpt::perform(MemIntrinsic *MI) { // Clear the value profile data. MI->setMetadata(LLVMContext::MD_prof, nullptr); + // If all promoted, we don't need the MD.prof metadata. + if (SavedRemainCount > 0 || Version != NumVals) + // Otherwise we need update with the un-promoted records back. + annotateValueSite(*Func.getParent(), *MI, VDs.slice(Version), + SavedRemainCount, IPVK_MemOPSize, NumVals); DEBUG(dbgs() << "\n\n== Basic Block After==\n"); -- cgit v1.2.3