From 876c2024e2aacedc21c78d74eb5ab6854b3e8d38 Mon Sep 17 00:00:00 2001 From: Xinliang David Li Date: Fri, 22 Jan 2016 05:48:40 +0000 Subject: [PGO] eliminate use of static variable llvm-svn: 258486 --- llvm/lib/ProfileData/InstrProfWriter.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'llvm/lib/ProfileData/InstrProfWriter.cpp') diff --git a/llvm/lib/ProfileData/InstrProfWriter.cpp b/llvm/lib/ProfileData/InstrProfWriter.cpp index 4c7f5de..7945469 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 using namespace llvm; +static cl::opt 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 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, -- cgit v1.1