[llvm][automemcpy] Allow distribution filtering in analysis

Differential Revision: https://reviews.llvm.org/D120037
This commit is contained in:
Guillaume Chatelet 2022-02-17 11:51:59 +00:00
parent d74f15faff
commit 48e0e6cedc
2 changed files with 17 additions and 2 deletions

View File

@ -613,7 +613,7 @@ llvm::ArrayRef<MemmoveConfiguration> getMemmoveConfigurations() {
// Stores `VolatileStr` into a cache and returns a StringRef of the cached
// version.
StringRef getInternalizedString(std::string VolatileStr) {
static llvm::StringSet<> StringCache;
static llvm::StringSet StringCache;
return StringCache.insert(std::move(VolatileStr)).first->getKey();
}

View File

@ -20,6 +20,12 @@ namespace llvm {
static cl::list<std::string> InputFilenames(cl::Positional, cl::OneOrMore,
cl::desc("<input json files>"));
// User can filter the distributions to be taken into account.
static cl::list<std::string>
KeepOnlyDistributions("keep-only-distributions", cl::ZeroOrMore,
cl::desc("<comma separated list of distribution "
"names, keeps all if unspecified>"));
namespace automemcpy {
// This is defined in the autogenerated 'Implementations.cpp' file.
@ -48,7 +54,7 @@ static const FunctionDescriptor &getFunctionDescriptor(StringRef FunctionName) {
// Functions and distributions names are stored quite a few times so it's more
// efficient to internalize these strings and refer to them through 'StringRef'.
static StringRef getInternalizedString(StringRef VolatileStr) {
static llvm::StringSet<> StringCache;
static llvm::StringSet StringCache;
return StringCache.insert(VolatileStr).first->getKey();
}
@ -121,6 +127,15 @@ int Main(int argc, char **argv) {
llvm::append_range(Samples, Result.Samples);
}
if (!KeepOnlyDistributions.empty()) {
llvm::StringSet ValidDistributions;
ValidDistributions.insert(KeepOnlyDistributions.begin(),
KeepOnlyDistributions.end());
llvm::erase_if(Samples, [&ValidDistributions](const Sample &S) {
return !ValidDistributions.contains(S.Id.Distribution.Name);
});
}
// Extracts median of throughputs.
std::vector<FunctionData> Functions = getThroughputs(Samples);
fillScores(Functions);