diff options
author | Xinliang David Li <davidxl@google.com> | 2017-04-14 17:48:40 +0000 |
---|---|---|
committer | Xinliang David Li <davidxl@google.com> | 2017-04-14 17:48:40 +0000 |
commit | 4a5ddf8038a58ea1c05f83601a9cea445ca288bb (patch) | |
tree | c0d637885db0706ad9ab456e27919822eddc8155 /llvm/lib/ProfileData | |
parent | 9c27d79520a2f22121b33fb2815fe8e9a5e19b8e (diff) | |
download | bcm5719-llvm-4a5ddf8038a58ea1c05f83601a9cea445ca288bb.tar.gz bcm5719-llvm-4a5ddf8038a58ea1c05f83601a9cea445ca288bb.zip |
[Profile] Make host tool aware of object format when quering prof section names
Differential Revision: https://reviews.llvm.org/D32073
llvm-svn: 300352
Diffstat (limited to 'llvm/lib/ProfileData')
-rw-r--r-- | llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp | 21 | ||||
-rw-r--r-- | llvm/lib/ProfileData/InstrProf.cpp | 17 |
2 files changed, 26 insertions, 12 deletions
diff --git a/llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp b/llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp index 515f19a3b40..dab602afd25 100644 --- a/llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp +++ b/llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp @@ -12,23 +12,24 @@ // //===----------------------------------------------------------------------===// +#include "llvm/ProfileData/Coverage/CoverageMappingReader.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" -#include "llvm/ADT/Triple.h" +#include "llvm/ADT/Triple.h" #include "llvm/Object/Binary.h" +#include "llvm/Object/COFF.h" #include "llvm/Object/Error.h" #include "llvm/Object/MachOUniversal.h" #include "llvm/Object/ObjectFile.h" -#include "llvm/ProfileData/Coverage/CoverageMappingReader.h" #include "llvm/ProfileData/InstrProf.h" #include "llvm/Support/Casting.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/Endian.h" #include "llvm/Support/Error.h" #include "llvm/Support/ErrorHandling.h" -#include "llvm/Support/Endian.h" #include "llvm/Support/LEB128.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/raw_ostream.h" @@ -648,15 +649,13 @@ static Error loadBinaryFormat(MemoryBufferRef ObjectBuffer, : support::endianness::big; // Look for the sections that we are interested in. - // TODO: with the current getInstrProfXXXSectionName interfaces, the - // the coverage reader host tool is limited to read coverage section on - // binaries with compatible profile section naming scheme as the host - // platform. Currently, COFF format binaries have different section - // naming scheme from the all the rest. - auto NamesSection = lookupSection(*OF, getInstrProfNameSectionName()); + bool IsCoff = (dyn_cast<COFFObjectFile>(OF.get()) != nullptr); + auto NamesSection = + lookupSection(*OF, getInstrProfNameSectionNameInObject(IsCoff)); if (auto E = NamesSection.takeError()) return E; - auto CoverageSection = lookupSection(*OF, getInstrProfCoverageSectionName()); + auto CoverageSection = + lookupSection(*OF, getInstrProfCoverageSectionNameInObject(IsCoff)); if (auto E = CoverageSection.takeError()) return E; diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp index d66d25eb190..a8f5b7f3d0e 100644 --- a/llvm/lib/ProfileData/InstrProf.cpp +++ b/llvm/lib/ProfileData/InstrProf.cpp @@ -173,8 +173,11 @@ const char *InstrProfSectNamePrefix[] = { #include "llvm/ProfileData/InstrProfData.inc" }; -std::string getInstrProfSectionName(const Module *M, InstrProfSectKind Kind) { +std::string getInstrProfSectionName(bool isCoff, InstrProfSectKind Kind) { + return isCoff ? InstrProfSectNameCoff[Kind] : InstrProfSectNameCommon[Kind]; +} +std::string getInstrProfSectionName(const Module *M, InstrProfSectKind Kind) { if (!M) return InstrProfSectName[Kind]; @@ -206,10 +209,18 @@ std::string getInstrProfNameSectionName(const Module *M) { return getInstrProfSectionName(M, IPSK_name); } +std::string getInstrProfNameSectionNameInObject(bool isCoff) { + return getInstrProfSectionName(isCoff, IPSK_name); +} + std::string getInstrProfDataSectionName(const Module *M) { return getInstrProfSectionName(M, IPSK_data); } +std::string getInstrProfDataSectionNameInObject(bool isCoff) { + return getInstrProfSectionName(isCoff, IPSK_data); +} + std::string getInstrProfValuesSectionName(const Module *M) { return getInstrProfSectionName(M, IPSK_vals); } @@ -222,6 +233,10 @@ std::string getInstrProfCoverageSectionName(const Module *M) { return getInstrProfSectionName(M, IPSK_covmap); } +std::string getInstrProfCoverageSectionNameInObject(bool isCoff) { + return getInstrProfSectionName(isCoff, IPSK_covmap); +} + void SoftInstrProfErrors::addError(instrprof_error IE) { if (IE == instrprof_error::success) return; |