diff options
author | Xinliang David Li <davidxl@google.com> | 2016-01-22 05:48:40 +0000 |
---|---|---|
committer | Xinliang David Li <davidxl@google.com> | 2016-01-22 05:48:40 +0000 |
commit | 876c2024e2aacedc21c78d74eb5ab6854b3e8d38 (patch) | |
tree | 15e58c606c124aa4c100bd724fa90b1342407bfc /llvm/lib/ProfileData | |
parent | b56e5d231f291fa6075d0c6a898d751167e79edf (diff) | |
download | bcm5719-llvm-876c2024e2aacedc21c78d74eb5ab6854b3e8d38.tar.gz bcm5719-llvm-876c2024e2aacedc21c78d74eb5ab6854b3e8d38.zip |
[PGO] eliminate use of static variable
llvm-svn: 258486
Diffstat (limited to 'llvm/lib/ProfileData')
-rw-r--r-- | llvm/lib/ProfileData/InstrProfWriter.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/llvm/lib/ProfileData/InstrProfWriter.cpp b/llvm/lib/ProfileData/InstrProfWriter.cpp index 4c7f5de26aa..7945469268c 100644 --- a/llvm/lib/ProfileData/InstrProfWriter.cpp +++ b/llvm/lib/ProfileData/InstrProfWriter.cpp @@ -14,12 +14,16 @@ #include "llvm/ProfileData/InstrProfWriter.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Support/EndianStream.h" #include "llvm/Support/OnDiskHashTable.h" #include <tuple> using namespace llvm; +static cl::opt<bool> WriteVPInBE("write-vp-data-in-big", cl::ReallyHidden, + cl::init(false)); + // A struct to define how the data stream should be patched. For Indexed // profiling, only uint64_t data type is needed. struct PatchItem { @@ -74,8 +78,6 @@ public: } namespace { -static support::endianness ValueProfDataEndianness = support::little; - class InstrProfRecordTrait { public: typedef StringRef key_type; @@ -134,17 +136,18 @@ public: std::unique_ptr<ValueProfData> VDataPtr = ValueProfData::serializeFrom(ProfileData.second); uint32_t S = VDataPtr->getSize(); - VDataPtr->swapBytesFromHost(ValueProfDataEndianness); + VDataPtr->swapBytesFromHost( + InstrProfWriter::getValueProfDataEndianness()); Out.write((const char *)VDataPtr.get(), S); } } }; } -// Internal interface for testing purpose only. -void InstrProfWriter::setValueProfDataEndianness( - support::endianness Endianness) { - ValueProfDataEndianness = Endianness; +support::endianness InstrProfWriter::getValueProfDataEndianness() { + if (WriteVPInBE) + return support::big; + return support::little; } std::error_code InstrProfWriter::addRecord(InstrProfRecord &&I, |