From d9be2c7e64a28f359433942f57756a6408ca023c Mon Sep 17 00:00:00 2001 From: Wei Mi Date: Tue, 12 Jun 2018 05:53:49 +0000 Subject: [PATCH] [NFC] Change sample profile format enum name SPF_Raw_Binary to SPF_Binary. Some out-of-tree targets depend on the enum name SPF_Binary. Keep the name can avoid unnecessary churn to those targets. llvm-svn: 334476 --- llvm/include/llvm/ProfileData/SampleProf.h | 4 ++-- .../llvm/ProfileData/SampleProfReader.h | 2 +- llvm/lib/ProfileData/SampleProfWriter.cpp | 4 ++-- llvm/tools/llvm-profdata/llvm-profdata.cpp | 21 +++++++++---------- llvm/unittests/ProfileData/SampleProfTest.cpp | 2 +- 5 files changed, 16 insertions(+), 17 deletions(-) diff --git a/llvm/include/llvm/ProfileData/SampleProf.h b/llvm/include/llvm/ProfileData/SampleProf.h index 5221540c63d7..0cd6dd2c2c0e 100644 --- a/llvm/include/llvm/ProfileData/SampleProf.h +++ b/llvm/include/llvm/ProfileData/SampleProf.h @@ -83,10 +83,10 @@ enum SampleProfileFormat { SPF_Text = 0x1, SPF_Compact_Binary = 0x2, SPF_GCC = 0x3, - SPF_Raw_Binary = 0xff + SPF_Binary = 0xff }; -static inline uint64_t SPMagic(SampleProfileFormat Format = SPF_Raw_Binary) { +static inline uint64_t SPMagic(SampleProfileFormat Format = SPF_Binary) { return uint64_t('S') << (64 - 8) | uint64_t('P') << (64 - 16) | uint64_t('R') << (64 - 24) | uint64_t('O') << (64 - 32) | uint64_t('F') << (64 - 40) | uint64_t('4') << (64 - 48) | diff --git a/llvm/include/llvm/ProfileData/SampleProfReader.h b/llvm/include/llvm/ProfileData/SampleProfReader.h index f15336fefea4..0617b05e8d4f 100644 --- a/llvm/include/llvm/ProfileData/SampleProfReader.h +++ b/llvm/include/llvm/ProfileData/SampleProfReader.h @@ -426,7 +426,7 @@ private: public: SampleProfileReaderRawBinary(std::unique_ptr B, LLVMContext &C) - : SampleProfileReaderBinary(std::move(B), C, SPF_Raw_Binary) {} + : SampleProfileReaderBinary(std::move(B), C, SPF_Binary) {} /// \brief Return true if \p Buffer is in the format supported by this class. static bool hasFormat(const MemoryBuffer &Buffer); diff --git a/llvm/lib/ProfileData/SampleProfWriter.cpp b/llvm/lib/ProfileData/SampleProfWriter.cpp index 092139d4aa9c..b4de30118b8b 100644 --- a/llvm/lib/ProfileData/SampleProfWriter.cpp +++ b/llvm/lib/ProfileData/SampleProfWriter.cpp @@ -294,7 +294,7 @@ ErrorOr> SampleProfileWriter::create(StringRef Filename, SampleProfileFormat Format) { std::error_code EC; std::unique_ptr OS; - if (Format == SPF_Raw_Binary || Format == SPF_Compact_Binary) + if (Format == SPF_Binary || Format == SPF_Compact_Binary) OS.reset(new raw_fd_ostream(Filename, EC, sys::fs::F_None)); else OS.reset(new raw_fd_ostream(Filename, EC, sys::fs::F_Text)); @@ -317,7 +317,7 @@ SampleProfileWriter::create(std::unique_ptr &OS, std::error_code EC; std::unique_ptr Writer; - if (Format == SPF_Raw_Binary) + if (Format == SPF_Binary) Writer.reset(new SampleProfileWriterRawBinary(OS)); else if (Format == SPF_Compact_Binary) Writer.reset(new SampleProfileWriterCompactBinary(OS)); diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp index cab1237f7aa9..1a0b9e127bbc 100644 --- a/llvm/tools/llvm-profdata/llvm-profdata.cpp +++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp @@ -39,7 +39,7 @@ enum ProfileFormat { PF_Text, PF_Compact_Binary, PF_GCC, - PF_Raw_Binary + PF_Binary }; static void warn(Twine Message, std::string Whence = "", @@ -242,7 +242,7 @@ static void mergeInstrProfile(const WeightedFileVector &Inputs, if (OutputFilename.compare("-") == 0) exitWithError("Cannot write indexed profdata format to stdout."); - if (OutputFormat != PF_Raw_Binary && OutputFormat != PF_Compact_Binary && + if (OutputFormat != PF_Binary && OutputFormat != PF_Compact_Binary && OutputFormat != PF_Text) exitWithError("Unknown format is specified."); @@ -324,7 +324,7 @@ static void mergeInstrProfile(const WeightedFileVector &Inputs, static sampleprof::SampleProfileFormat FormatMap[] = { sampleprof::SPF_None, sampleprof::SPF_Text, sampleprof::SPF_Compact_Binary, - sampleprof::SPF_GCC, sampleprof::SPF_Raw_Binary}; + sampleprof::SPF_GCC, sampleprof::SPF_Binary}; static void mergeSampleProfile(const WeightedFileVector &Inputs, StringRef OutputFilename, @@ -471,14 +471,13 @@ static int merge_main(int argc, const char *argv[]) { cl::values(clEnumVal(instr, "Instrumentation profile (default)"), clEnumVal(sample, "Sample profile"))); cl::opt OutputFormat( - cl::desc("Format of output profile"), cl::init(PF_Raw_Binary), - cl::values( - clEnumValN(PF_Raw_Binary, "binary", "Binary encoding (default)"), - clEnumValN(PF_Compact_Binary, "compbinary", - "Compact binary encoding"), - clEnumValN(PF_Text, "text", "Text encoding"), - clEnumValN(PF_GCC, "gcc", - "GCC encoding (only meaningful for -sample)"))); + cl::desc("Format of output profile"), cl::init(PF_Binary), + cl::values(clEnumValN(PF_Binary, "binary", "Binary encoding (default)"), + clEnumValN(PF_Compact_Binary, "compbinary", + "Compact binary encoding"), + clEnumValN(PF_Text, "text", "Text encoding"), + clEnumValN(PF_GCC, "gcc", + "GCC encoding (only meaningful for -sample)"))); cl::opt OutputSparse("sparse", cl::init(false), cl::desc("Generate a sparse profile (only meaningful for -instr)")); cl::opt NumThreads( diff --git a/llvm/unittests/ProfileData/SampleProfTest.cpp b/llvm/unittests/ProfileData/SampleProfTest.cpp index bc19eb5f07c2..3ebfd0e500fe 100644 --- a/llvm/unittests/ProfileData/SampleProfTest.cpp +++ b/llvm/unittests/ProfileData/SampleProfTest.cpp @@ -180,7 +180,7 @@ TEST_F(SampleProfTest, roundtrip_text_profile) { } TEST_F(SampleProfTest, roundtrip_raw_binary_profile) { - testRoundTrip(SampleProfileFormat::SPF_Raw_Binary); + testRoundTrip(SampleProfileFormat::SPF_Binary); } TEST_F(SampleProfTest, roundtrip_compact_binary_profile) {