Rollback r257547 -- buildbot failure TBI
authorXinliang David Li <davidxl@google.com>
Wed, 13 Jan 2016 00:27:24 +0000 (00:27 +0000)
committerXinliang David Li <davidxl@google.com>
Wed, 13 Jan 2016 00:27:24 +0000 (00:27 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257549 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ProfileData/CoverageMapping.h
lib/ProfileData/CoverageMappingReader.cpp

index a353e1f86ac3f8fc994bd180033eb72db6ce6f5a..2386442d28b424e0967956f717f277a645f306cd 100644 (file)
@@ -20,9 +20,8 @@
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/Triple.h"
 #include "llvm/ADT/iterator.h"
-#include "llvm/ProfileData/InstrProf.h"
+#include "llvm/ProfileData/InstrProfData.inc"
 #include "llvm/Support/Debug.h"
-#include "llvm/Support/Endian.h"
 #include "llvm/Support/ErrorOr.h"
 #include "llvm/Support/raw_ostream.h"
 #include <system_error>
@@ -480,50 +479,14 @@ inline std::error_code make_error_code(coveragemap_error E) {
 // [Encoded Region Mapping Data]
 LLVM_PACKED_START
 template <class IntPtrT> struct CovMapFunctionRecord {
-#define COVMAP_FUNC_RECORD(Type, LLVMType, Name, Init) Type Name;
-#include "llvm/ProfileData/InstrProfData.inc"
-
-  // Return the structural hash associated with the function.
-  template <support::endianness Endian> uint64_t getFuncHash() const {
-    return support::endian::byte_swap<uint64_t, Endian>(FuncHash);
-  }
-  // Return the coverage map data size for the funciton.
-  template <support::endianness Endian> uint32_t getDataSize() const {
-    return support::endian::byte_swap<uint32_t, Endian>(DataSize);
-  }
-  // Return function lookup key. The value is consider opaque.
-  template <support::endianness Endian> IntPtrT getFuncNameRef() const {
-    return support::endian::byte_swap<IntPtrT, Endian>(NamePtr);
-  }
-  // Return the PGO name of the function */
-  template <support::endianness Endian>
-  std::error_code getFuncName(InstrProfSymtab &ProfileNames,
-                              StringRef &FuncName) const {
-    IntPtrT NameRef = getFuncNameRef<Endian>();
-    uint32_t NameS = support::endian::byte_swap<IntPtrT, Endian>(NameSize);
-    FuncName = ProfileNames.getFuncName(NameRef, NameS);
-    if (NameS && FuncName.empty())
-      return coveragemap_error::malformed;
-    return std::error_code();
-  }
+  #define COVMAP_FUNC_RECORD(Type, LLVMType, Name, Init) Type Name;
+  #include "llvm/ProfileData/InstrProfData.inc"
 };
 // Per module coverage mapping data header, i.e. CoverageMapFileHeader
 // documented above.
 struct CovMapHeader {
 #define COVMAP_HEADER(Type, LLVMType, Name, Init) Type Name;
 #include "llvm/ProfileData/InstrProfData.inc"
-  template <support::endianness Endian> uint32_t getNRecords() const {
-    return support::endian::byte_swap<uint32_t, Endian>(NRecords);
-  }
-  template <support::endianness Endian> uint32_t getFilenamesSize() const {
-    return support::endian::byte_swap<uint32_t, Endian>(FilenamesSize);
-  }
-  template <support::endianness Endian> uint32_t getCoverageSize() const {
-    return support::endian::byte_swap<uint32_t, Endian>(CoverageSize);
-  }
-  template <support::endianness Endian> uint32_t getVersion() const {
-    return support::endian::byte_swap<uint32_t, Endian>(Version);
-  }
 };
 
 LLVM_PACKED_END
index aa794b080bb7ae434e94db1d6b1ef7668a44cc1a..af6c616fa0311bf0bb0f6d67e6df32f0d066d6f0 100644 (file)
@@ -319,10 +319,13 @@ static std::error_code readCoverageMappingData(
     if (Buf + sizeof(CovMapHeader) > End)
       return coveragemap_error::malformed;
     auto CovHeader = reinterpret_cast<const coverage::CovMapHeader *>(Buf);
-    uint32_t NRecords = CovHeader->getNRecords<Endian>();
-    uint32_t FilenamesSize = CovHeader->getFilenamesSize<Endian>();
-    uint32_t CoverageSize = CovHeader->getCoverageSize<Endian>();
-    uint32_t Version = CovHeader->getVersion<Endian>();
+    uint32_t NRecords =
+        endian::byte_swap<uint32_t, Endian>(CovHeader->NRecords);
+    uint32_t FilenamesSize =
+        endian::byte_swap<uint32_t, Endian>(CovHeader->FilenamesSize);
+    uint32_t CoverageSize =
+        endian::byte_swap<uint32_t, Endian>(CovHeader->CoverageSize);
+    uint32_t Version = endian::byte_swap<uint32_t, Endian>(CovHeader->Version);
     Buf = reinterpret_cast<const char *>(++CovHeader);
 
     if (Version > coverage::CoverageMappingCurrentVersion)
@@ -357,8 +360,11 @@ static std::error_code readCoverageMappingData(
         reinterpret_cast<const coverage::CovMapFunctionRecord<T> *>(FunBuf);
     while ((const char *)CFR < FunEnd) {
       // Read the function information
-      uint32_t DataSize = CFR->template getDataSize<Endian>();
-      uint64_t FuncHash = CFR->template getFuncHash<Endian>();
+      T NamePtr = endian::byte_swap<T, Endian>(CFR->NamePtr);
+      uint32_t NameSize = endian::byte_swap<uint32_t, Endian>(CFR->NameSize);
+      uint32_t DataSize = endian::byte_swap<uint32_t, Endian>(CFR->DataSize);
+      uint64_t FuncHash = endian::byte_swap<uint64_t, Endian>(CFR->FuncHash);
+      CFR++;
 
       // Now use that to read the coverage data.
       if (CovBuf + DataSize > CovEnd)
@@ -369,18 +375,16 @@ static std::error_code readCoverageMappingData(
       // Ignore this record if we already have a record that points to the same
       // function name. This is useful to ignore the redundant records for the
       // functions with ODR linkage.
-      T NameRef = CFR->template getFuncNameRef<Endian>();
-      if (!UniqueFunctionMappingData.insert(NameRef).second)
+      if (!UniqueFunctionMappingData.insert(NamePtr).second)
         continue;
 
-      StringRef FuncName;
-      if (std::error_code EC =
-          CFR->template getFuncName<Endian>(ProfileNames, FuncName))
-        return EC;
+      // Finally, grab the name and create a record.
+      StringRef FuncName = ProfileNames.getFuncName(NamePtr, NameSize);
+      if (NameSize && FuncName.empty())
+        return coveragemap_error::malformed;
       Records.push_back(BinaryCoverageReader::ProfileMappingRecord(
           CoverageMappingVersion(Version), FuncName, FuncHash, Mapping,
           FilenamesBegin, Filenames.size() - FilenamesBegin));
-      CFR++;
     }
   }