From 48596b6f7a422650987c7f2c2566917c7dfff61c Mon Sep 17 00:00:00 2001 From: Rong Xu Date: Tue, 4 Apr 2017 16:42:20 +0000 Subject: [PGO] Memory intrinsic calls optimization based on profiled size This patch optimizes two memory intrinsic operations: memset and memcpy based on the profiled size of the operation. The high level transformation is like: mem_op(..., size) ==> switch (size) { case s1: mem_op(..., s1); goto merge_bb; case s2: mem_op(..., s2); goto merge_bb; ... default: mem_op(..., size); goto merge_bb; } merge_bb: Differential Revision: http://reviews.llvm.org/D28966 llvm-svn: 299446 --- llvm/lib/ProfileData/InstrProf.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'llvm/lib/ProfileData') diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp index bbefde709cf..0ec3fce4b23 100644 --- a/llvm/lib/ProfileData/InstrProf.cpp +++ b/llvm/lib/ProfileData/InstrProf.cpp @@ -936,4 +936,25 @@ bool canRenameComdatFunc(const Function &F, bool CheckAddressTaken) { return true; } +// Parse the value profile options. +void getMemOPSizeRangeFromOption(std::string MemOPSizeRange, + int64_t &RangeStart, int64_t &RangeLast) { + static const int64_t DefaultMemOPSizeRangeStart = 0; + static const int64_t DefaultMemOPSizeRangeLast = 8; + RangeStart = DefaultMemOPSizeRangeStart; + RangeLast = DefaultMemOPSizeRangeLast; + + if (!MemOPSizeRange.empty()) { + auto Pos = MemOPSizeRange.find(":"); + if (Pos != std::string::npos) { + if (Pos > 0) + RangeStart = atoi(MemOPSizeRange.substr(0, Pos).c_str()); + if (Pos < MemOPSizeRange.size() - 1) + RangeLast = atoi(MemOPSizeRange.substr(Pos + 1).c_str()); + } else + RangeLast = atoi(MemOPSizeRange.c_str()); + } + assert(RangeLast >= RangeStart); +} + } // end namespace llvm -- cgit v1.2.3