diff --git a/compiler-rt/include/profile/InstrProfData.inc b/compiler-rt/include/profile/InstrProfData.inc --- a/compiler-rt/include/profile/InstrProfData.inc +++ b/compiler-rt/include/profile/InstrProfData.inc @@ -154,19 +154,7 @@ VALUE_PROF_FUNC_PARAM(uint64_t, TargetValue, Type::getInt64Ty(Ctx)) \ INSTR_PROF_COMMA VALUE_PROF_FUNC_PARAM(void *, Data, Type::getInt8PtrTy(Ctx)) INSTR_PROF_COMMA -#ifndef VALUE_RANGE_PROF VALUE_PROF_FUNC_PARAM(uint32_t, CounterIndex, Type::getInt32Ty(Ctx)) -#else /* VALUE_RANGE_PROF */ -/* FIXME: This is to be removed after switching to the new memop value - * profiling. */ -VALUE_PROF_FUNC_PARAM(uint32_t, CounterIndex, Type::getInt32Ty(Ctx)) \ - INSTR_PROF_COMMA -VALUE_PROF_FUNC_PARAM(uint64_t, PreciseRangeStart, Type::getInt64Ty(Ctx)) \ - INSTR_PROF_COMMA -VALUE_PROF_FUNC_PARAM(uint64_t, PreciseRangeLast, Type::getInt64Ty(Ctx)) \ - INSTR_PROF_COMMA -VALUE_PROF_FUNC_PARAM(uint64_t, LargeValue, Type::getInt64Ty(Ctx)) -#endif /*VALUE_RANGE_PROF */ #undef VALUE_PROF_FUNC_PARAM #undef INSTR_PROF_COMMA /* VALUE_PROF_FUNC_PARAM end */ @@ -673,6 +661,7 @@ #define GET_VERSION(V) ((V) & ~VARIANT_MASKS_ALL) #define VARIANT_MASK_IR_PROF (0x1ULL << 56) #define VARIANT_MASK_CSIR_PROF (0x1ULL << 57) +#define VARIANT_MASK_INSTR_ENTRY (0x1ULL << 58) #define INSTR_PROF_RAW_VERSION_VAR __llvm_profile_raw_version #define INSTR_PROF_PROFILE_RUNTIME_VAR __llvm_profile_runtime @@ -755,11 +744,6 @@ #define INSTR_PROF_VALUE_PROF_FUNC __llvm_profile_instrument_target #define INSTR_PROF_VALUE_PROF_FUNC_STR \ INSTR_PROF_QUOTE(INSTR_PROF_VALUE_PROF_FUNC) -/* FIXME: This is to be removed after switching to the new memop value - * profiling. */ -#define INSTR_PROF_VALUE_RANGE_PROF_FUNC __llvm_profile_instrument_range -#define INSTR_PROF_VALUE_RANGE_PROF_FUNC_STR \ - INSTR_PROF_QUOTE(INSTR_PROF_VALUE_RANGE_PROF_FUNC) #define INSTR_PROF_VALUE_PROF_MEMOP_FUNC __llvm_profile_instrument_memop #define INSTR_PROF_VALUE_PROF_MEMOP_FUNC_STR \ INSTR_PROF_QUOTE(INSTR_PROF_VALUE_PROF_MEMOP_FUNC) diff --git a/compiler-rt/lib/profile/InstrProfilingValue.c b/compiler-rt/lib/profile/InstrProfilingValue.c --- a/compiler-rt/lib/profile/InstrProfilingValue.c +++ b/compiler-rt/lib/profile/InstrProfilingValue.c @@ -238,37 +238,6 @@ instrumentTargetValueImpl(TargetValue, Data, CounterIndex, CountValue); } -/* - * The target values are partitioned into multiple regions/ranges. There is one - * contiguous region which is precise -- every value in the range is tracked - * individually. A value outside the precise region will be collapsed into one - * value depending on the region it falls in. - * - * There are three regions: - * 1. (-inf, PreciseRangeStart) and (PreciseRangeLast, LargeRangeValue) belong - * to one region -- all values here should be mapped to one value of - * "PreciseRangeLast + 1". - * 2. [PreciseRangeStart, PreciseRangeLast] - * 3. Large values: [LargeValue, +inf) maps to one value of LargeValue. - * - * The range for large values is optional. The default value of INT64_MIN - * indicates it is not specified. - */ -/* FIXME: This is to be removed after switching to the new memop value - * profiling. */ -COMPILER_RT_VISIBILITY void __llvm_profile_instrument_range( - uint64_t TargetValue, void *Data, uint32_t CounterIndex, - int64_t PreciseRangeStart, int64_t PreciseRangeLast, int64_t LargeValue) { - - if (LargeValue != INT64_MIN && (int64_t)TargetValue >= LargeValue) - TargetValue = LargeValue; - else if ((int64_t)TargetValue < PreciseRangeStart || - (int64_t)TargetValue > PreciseRangeLast) - TargetValue = PreciseRangeLast + 1; - - __llvm_profile_instrument_target(TargetValue, Data, CounterIndex); -} - /* * The target values are partitioned into multiple ranges. The range spec is * defined in InstrProfData.inc. diff --git a/llvm/include/llvm/ProfileData/InstrProf.h b/llvm/include/llvm/ProfileData/InstrProf.h --- a/llvm/include/llvm/ProfileData/InstrProf.h +++ b/llvm/include/llvm/ProfileData/InstrProf.h @@ -74,13 +74,6 @@ return INSTR_PROF_VALUE_PROF_FUNC_STR; } -/// Return the name profile runtime entry point to do value range profiling. -// FIXME: This is to be removed after switching to the new memop value -// profiling. -inline StringRef getInstrProfValueRangeProfFuncName() { - return INSTR_PROF_VALUE_RANGE_PROF_FUNC_STR; -} - /// Return the name profile runtime entry point to do memop size value /// profiling. inline StringRef getInstrProfValueProfMemOpFuncName() { diff --git a/llvm/include/llvm/ProfileData/InstrProfData.inc b/llvm/include/llvm/ProfileData/InstrProfData.inc --- a/llvm/include/llvm/ProfileData/InstrProfData.inc +++ b/llvm/include/llvm/ProfileData/InstrProfData.inc @@ -154,19 +154,7 @@ VALUE_PROF_FUNC_PARAM(uint64_t, TargetValue, Type::getInt64Ty(Ctx)) \ INSTR_PROF_COMMA VALUE_PROF_FUNC_PARAM(void *, Data, Type::getInt8PtrTy(Ctx)) INSTR_PROF_COMMA -#ifndef VALUE_RANGE_PROF VALUE_PROF_FUNC_PARAM(uint32_t, CounterIndex, Type::getInt32Ty(Ctx)) -#else /* VALUE_RANGE_PROF */ -/* FIXME: This is to be removed after switching to the new memop value - * profiling. */ -VALUE_PROF_FUNC_PARAM(uint32_t, CounterIndex, Type::getInt32Ty(Ctx)) \ - INSTR_PROF_COMMA -VALUE_PROF_FUNC_PARAM(uint64_t, PreciseRangeStart, Type::getInt64Ty(Ctx)) \ - INSTR_PROF_COMMA -VALUE_PROF_FUNC_PARAM(uint64_t, PreciseRangeLast, Type::getInt64Ty(Ctx)) \ - INSTR_PROF_COMMA -VALUE_PROF_FUNC_PARAM(uint64_t, LargeValue, Type::getInt64Ty(Ctx)) -#endif /*VALUE_RANGE_PROF */ #undef VALUE_PROF_FUNC_PARAM #undef INSTR_PROF_COMMA /* VALUE_PROF_FUNC_PARAM end */ @@ -756,11 +744,6 @@ #define INSTR_PROF_VALUE_PROF_FUNC __llvm_profile_instrument_target #define INSTR_PROF_VALUE_PROF_FUNC_STR \ INSTR_PROF_QUOTE(INSTR_PROF_VALUE_PROF_FUNC) -/* FIXME: This is to be removed after switching to the new memop value - * profiling. */ -#define INSTR_PROF_VALUE_RANGE_PROF_FUNC __llvm_profile_instrument_range -#define INSTR_PROF_VALUE_RANGE_PROF_FUNC_STR \ - INSTR_PROF_QUOTE(INSTR_PROF_VALUE_RANGE_PROF_FUNC) #define INSTR_PROF_VALUE_PROF_MEMOP_FUNC __llvm_profile_instrument_memop #define INSTR_PROF_VALUE_PROF_MEMOP_FUNC_STR \ INSTR_PROF_QUOTE(INSTR_PROF_VALUE_PROF_MEMOP_FUNC) diff --git a/llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h b/llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h --- a/llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h +++ b/llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h @@ -68,13 +68,6 @@ // vector of counter load/store pairs to be register promoted. std::vector PromotionCandidates; - // FIXME: These are to be removed after switching to the new memop value - // profiling. - // The start value of precise value profile range for memory intrinsic sizes. - int64_t MemOPSizeRangeStart; - // The end value of precise value profile range for memory intrinsic sizes. - int64_t MemOPSizeRangeLast; - int64_t TotalCountersPromoted = 0; /// Lower instrumentation intrinsics in the function. Returns true if there diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp --- a/llvm/lib/ProfileData/InstrProf.cpp +++ b/llvm/lib/ProfileData/InstrProf.cpp @@ -1112,29 +1112,6 @@ return true; } -// FIXME: This is to be removed after switching to the new memop value -// profiling. -// Parse the value profile options. -void getMemOPSizeRangeFromOption(StringRef 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) - MemOPSizeRange.substr(0, Pos).getAsInteger(10, RangeStart); - if (Pos < MemOPSizeRange.size() - 1) - MemOPSizeRange.substr(Pos + 1).getAsInteger(10, RangeLast); - } else - MemOPSizeRange.getAsInteger(10, RangeLast); - } - assert(RangeLast >= RangeStart); -} - // Create a COMDAT variable INSTR_PROF_RAW_VERSION_VAR to make the runtime // aware this is an ir_level profile so it can set the version flag. void createIRLevelProfileFlagVar(Module &M, bool IsCS, diff --git a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp --- a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp +++ b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp @@ -57,29 +57,6 @@ #define DEBUG_TYPE "instrprof" -// FIXME: These are to be removed after switching to the new memop value -// profiling. -// The start and end values of precise value profile range for memory -// intrinsic sizes -cl::opt MemOPSizeRange( - "memop-size-range", - cl::desc("Set the range of size in memory intrinsic calls to be profiled " - "precisely, in a format of :"), - cl::init("")); - -// The value that considered to be large value in memory intrinsic. -cl::opt MemOPSizeLarge( - "memop-size-large", - cl::desc("Set large value thresthold in memory intrinsic size profiling. " - "Value of 0 disables the large value profiling."), - cl::init(8192)); - -cl::opt UseOldMemOpValueProf( - "use-old-memop-value-prof", - cl::desc("Use the old memop value profiling buckets. This is " - "transitional and to be removed after switching. "), - cl::init(false)); - namespace { cl::opt DoHashBasedCounterSplit( @@ -424,11 +401,7 @@ // profiling. Default, - // The old memop size value profiling. FIXME: To be removed after switching to - // the new one. - OldMemOp, - - // MemOp: the (new) memop size value profiling with extended buckets. + // MemOp: the memop size value profiling. MemOp }; @@ -566,8 +539,6 @@ NamesSize = 0; ProfileDataMap.clear(); UsedVars.clear(); - getMemOPSizeRangeFromOption(MemOPSizeRange, MemOPSizeRangeStart, - MemOPSizeRangeLast); TT = Triple(M.getTargetTriple()); // Emit the runtime hook even if no counters are present. @@ -626,33 +597,19 @@ if (auto AK = TLI.getExtAttrForI32Param(false)) AL = AL.addParamAttribute(M.getContext(), 2, AK); - if (CallType == ValueProfilingCallType::Default || - CallType == ValueProfilingCallType::MemOp) { - Type *ParamTypes[] = { -#define VALUE_PROF_FUNC_PARAM(ParamType, ParamName, ParamLLVMType) ParamLLVMType -#include "llvm/ProfileData/InstrProfData.inc" - }; - auto *ValueProfilingCallTy = - FunctionType::get(ReturnTy, makeArrayRef(ParamTypes), false); - StringRef FuncName = CallType == ValueProfilingCallType::Default - ? getInstrProfValueProfFuncName() - : getInstrProfValueProfMemOpFuncName(); - return M.getOrInsertFunction(FuncName, ValueProfilingCallTy, AL); - } else { - // FIXME: This code is to be removed after switching to the new memop value - // profiling. - assert(CallType == ValueProfilingCallType::OldMemOp); - Type *RangeParamTypes[] = { -#define VALUE_RANGE_PROF 1 + assert((CallType == ValueProfilingCallType::Default || + CallType == ValueProfilingCallType::MemOp) && + "Must be Default or MemOp"); + Type *ParamTypes[] = { #define VALUE_PROF_FUNC_PARAM(ParamType, ParamName, ParamLLVMType) ParamLLVMType #include "llvm/ProfileData/InstrProfData.inc" -#undef VALUE_RANGE_PROF - }; - auto *ValueRangeProfilingCallTy = - FunctionType::get(ReturnTy, makeArrayRef(RangeParamTypes), false); - return M.getOrInsertFunction(getInstrProfValueRangeProfFuncName(), - ValueRangeProfilingCallTy, AL); - } + }; + auto *ValueProfilingCallTy = + FunctionType::get(ReturnTy, makeArrayRef(ParamTypes), false); + StringRef FuncName = CallType == ValueProfilingCallType::Default + ? getInstrProfValueProfFuncName() + : getInstrProfValueProfMemOpFuncName(); + return M.getOrInsertFunction(FuncName, ValueProfilingCallTy, AL); } void InstrProfiling::computeNumValueSiteCounts(InstrProfValueProfileInst *Ind) { @@ -698,24 +655,13 @@ Builder.getInt32(Index)}; Call = Builder.CreateCall(getOrInsertValueProfilingCall(*M, *TLI), Args, OpBundles); - } else if (!UseOldMemOpValueProf) { + } else { Value *Args[3] = {Ind->getTargetValue(), Builder.CreateBitCast(DataVar, Builder.getInt8PtrTy()), Builder.getInt32(Index)}; Call = Builder.CreateCall( getOrInsertValueProfilingCall(*M, *TLI, ValueProfilingCallType::MemOp), Args, OpBundles); - } else { - Value *Args[6] = { - Ind->getTargetValue(), - Builder.CreateBitCast(DataVar, Builder.getInt8PtrTy()), - Builder.getInt32(Index), - Builder.getInt64(MemOPSizeRangeStart), - Builder.getInt64(MemOPSizeRangeLast), - Builder.getInt64(MemOPSizeLarge == 0 ? INT64_MIN : MemOPSizeLarge)}; - Call = Builder.CreateCall(getOrInsertValueProfilingCall( - *M, *TLI, ValueProfilingCallType::OldMemOp), - Args, OpBundles); } if (auto AK = TLI->getExtAttrForI32Param(false)) Call->addParamAttr(2, AK); diff --git a/llvm/lib/Transforms/Instrumentation/PGOMemOPSizeOpt.cpp b/llvm/lib/Transforms/Instrumentation/PGOMemOPSizeOpt.cpp --- a/llvm/lib/Transforms/Instrumentation/PGOMemOPSizeOpt.cpp +++ b/llvm/lib/Transforms/Instrumentation/PGOMemOPSizeOpt.cpp @@ -91,16 +91,6 @@ cl::desc("Scale the memop size counts using the basic " " block count value")); -// FIXME: These are to be removed after switching to the new memop value -// profiling. -// This option sets the rangge of precise profile memop sizes. -extern cl::opt MemOPSizeRange; - -// This option sets the value that groups large memop sizes -extern cl::opt MemOPSizeLarge; - -extern cl::opt UseOldMemOpValueProf; - cl::opt MemOPOptMemcmpBcmp("pgo-memop-optimize-memcmp-bcmp", cl::init(true), cl::Hidden, @@ -234,9 +224,6 @@ : Func(Func), BFI(BFI), ORE(ORE), DT(DT), TLI(TLI), Changed(false) { ValueDataArray = std::make_unique(MemOPMaxVersion + 2); - // Get the MemOPSize range information from option MemOPSizeRange, - getMemOPSizeRangeFromOption(MemOPSizeRange, PreciseRangeStart, - PreciseRangeLast); } bool isChanged() const { return Changed; } void perform() { @@ -279,30 +266,9 @@ TargetLibraryInfo &TLI; bool Changed; std::vector WorkList; - // FIXME: These are to be removed after switching to the new memop value - // profiling. - // Start of the previse range. - int64_t PreciseRangeStart; - // Last value of the previse range. - int64_t PreciseRangeLast; // The space to read the profile annotation. std::unique_ptr ValueDataArray; bool perform(MemOp MO); - - // FIXME: This is to be removed after switching to the new memop value - // profiling. - // This kind shows which group the value falls in. For PreciseValue, we have - // the profile count for that value. LargeGroup groups the values that are in - // range [LargeValue, +inf). NonLargeGroup groups the rest of values. - enum MemOPSizeKind { PreciseValue, NonLargeGroup, LargeGroup }; - - MemOPSizeKind getMemOPSizeKind(int64_t Value) const { - if (Value == MemOPSizeLarge && MemOPSizeLarge != 0) - return LargeGroup; - if (Value == PreciseRangeLast + 1) - return NonLargeGroup; - return PreciseValue; - } }; static bool isProfitable(uint64_t Count, uint64_t TotalCount) { @@ -379,11 +345,7 @@ if (MemOPScaleCount) C = getScaledCount(C, ActualCount, SavedTotalCount); - if (UseOldMemOpValueProf) { - // Only care precise value here. - if (getMemOPSizeKind(V) != PreciseValue) - continue; - } else if (!InstrProfIsSingleValRange(V) || V > MemOpMaxOptSize) + if (!InstrProfIsSingleValRange(V) || V > MemOpMaxOptSize) continue; // ValueCounts are sorted on the count. Break at the first un-profitable diff --git a/llvm/test/Transforms/PGOProfile/memcpy.ll b/llvm/test/Transforms/PGOProfile/memcpy.ll --- a/llvm/test/Transforms/PGOProfile/memcpy.ll +++ b/llvm/test/Transforms/PGOProfile/memcpy.ll @@ -1,7 +1,5 @@ -; RUN: opt < %s -pgo-instr-gen -instrprof -use-old-memop-value-prof=true -S | FileCheck %s --check-prefix=OLDMEMOPVP -; RUN: opt < %s -pgo-instr-gen -instrprof -use-old-memop-value-prof=false -S | FileCheck %s --check-prefix=NEWMEMOPVP -; RUN: opt <%s -passes=pgo-instr-gen,instrprof -use-old-memop-value-prof=true -S | FileCheck %s --check-prefix=OLDMEMOPVP -; RUN: opt <%s -passes=pgo-instr-gen,instrprof -use-old-memop-value-prof=false -S | FileCheck %s --check-prefix=NEWMEMOPVP +; RUN: opt < %s -pgo-instr-gen -instrprof -S | FileCheck %s +; RUN: opt <%s -passes=pgo-instr-gen,instrprof -S | FileCheck %s target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" @@ -25,8 +23,7 @@ for.body3: %conv = sext i32 %add to i64 -; OLDMEMOPVP: call void @__llvm_profile_instrument_range(i64 %conv, i8* bitcast ({ i64, i64, i64*, i8*, i8*, i32, [2 x i16] }* @__profd_foo to i8*), i32 0, i64 0, i64 8, i64 8192) -; NEWMEMOPVP: call void @__llvm_profile_instrument_memop(i64 %conv, i8* bitcast ({ i64, i64, i64*, i8*, i8*, i32, [2 x i16] }* @__profd_foo to i8*), i32 0) +; CHECK: call void @__llvm_profile_instrument_memop(i64 %conv, i8* bitcast ({ i64, i64, i64*, i8*, i8*, i32, [2 x i16] }* @__profd_foo to i8*), i32 0) call void @llvm.memcpy.p0i8.p0i8.i64(i8* %dst, i8* %src, i64 %conv, i1 false) %inc = add nsw i32 %j.0, 1 br label %for.cond1 diff --git a/llvm/test/Transforms/PGOProfile/memop_profile_funclet.ll b/llvm/test/Transforms/PGOProfile/memop_profile_funclet.ll --- a/llvm/test/Transforms/PGOProfile/memop_profile_funclet.ll +++ b/llvm/test/Transforms/PGOProfile/memop_profile_funclet.ll @@ -1,10 +1,8 @@ ; RUN: opt < %s -pgo-instr-gen -S | FileCheck %s --check-prefix=GEN -; RUN: opt < %s -pgo-instr-gen -instrprof -use-old-memop-value-prof=true -S | FileCheck %s --check-prefixes=LOWER,LOWEROLDMEMOPVP -; RUN: opt < %s -pgo-instr-gen -instrprof -use-old-memop-value-prof=false -S | FileCheck %s --check-prefixes=LOWER,LOWERNEWMEMOPVP +; RUN: opt < %s -pgo-instr-gen -instrprof -S | FileCheck %s --check-prefixes=LOWER ; RUN: opt < %s -passes=pgo-instr-gen -S | FileCheck %s --check-prefix=GEN -; RUN: opt < %s -passes=pgo-instr-gen,instrprof -use-old-memop-value-prof=true -S | FileCheck %s --check-prefixes=LOWER,LOWEROLDMEMOPVP -; RUN: opt < %s -passes=pgo-instr-gen,instrprof -use-old-memop-value-prof=false -S | FileCheck %s --check-prefixes=LOWER,LOWERNEWMEMOPVP +; RUN: opt < %s -passes=pgo-instr-gen,instrprof -S | FileCheck %s --check-prefixes=LOWER ; This test is to verify that PGO runtime library calls get created with the ; appropriate operand bundle funclet information when a memory intrinsic @@ -65,8 +63,7 @@ ; GEN-SAME: [ "funclet"(token %tmp1) ] ; LOWER: catch: -; LOWEROLDMEMOPVP: call void @__llvm_profile_instrument_range( -; LOWERNEWMEMOPVP: call void @__llvm_profile_instrument_memop( +; LOWER: call void @__llvm_profile_instrument_memop( ; LOWER-SAME: [ "funclet"(token %tmp1) ] declare dso_local void @"?may_throw@@YAXH@Z"(i32)