Create a typedef GlobalValue::GUID for uint64_t and RAUW  (NFC)

Summary: This should make the code more readable, especially all the map declarations.

Reviewers: tejohnson

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D18721

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 265215
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 4543596..3598deb 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -446,7 +446,7 @@
   // call graph edges read from the function summary from referencing
   // callees by their ValueId to using the GUID instead, which is how
   // they are recorded in the summary index being built.
-  DenseMap<unsigned, uint64_t> ValueIdToCallGraphGUIDMap;
+  DenseMap<unsigned, GlobalValue::GUID> ValueIdToCallGraphGUIDMap;
 
   /// Map to save the association between summary offset in the VST to the
   /// GlobalValueInfo object created when parsing it. Used to access the
@@ -502,7 +502,7 @@
   std::error_code initStream(std::unique_ptr<DataStreamer> Streamer);
   std::error_code initStreamFromBuffer();
   std::error_code initLazyStream(std::unique_ptr<DataStreamer> Streamer);
-  uint64_t getGUIDFromValueId(unsigned ValueId);
+  GlobalValue::GUID getGUIDFromValueId(unsigned ValueId);
   GlobalValueInfo *getInfoFromSummaryOffset(uint64_t Offset);
 };
 } // end anonymous namespace
@@ -5444,7 +5444,8 @@
 
 void ModuleSummaryIndexBitcodeReader::releaseBuffer() { Buffer.release(); }
 
-uint64_t ModuleSummaryIndexBitcodeReader::getGUIDFromValueId(unsigned ValueId) {
+GlobalValue::GUID
+ModuleSummaryIndexBitcodeReader::getGUIDFromValueId(unsigned ValueId) {
   auto VGI = ValueIdToCallGraphGUIDMap.find(ValueId);
   assert(VGI != ValueIdToCallGraphGUIDMap.end());
   return VGI->second;
@@ -5540,7 +5541,7 @@
       // VST_CODE_COMBINED_GVDEFENTRY: [valueid, offset, guid]
       unsigned ValueID = Record[0];
       uint64_t GlobalValSummaryOffset = Record[1];
-      uint64_t GlobalValGUID = Record[2];
+      GlobalValue::GUID GlobalValGUID = Record[2];
       std::unique_ptr<GlobalValueInfo> GlobalValInfo =
           llvm::make_unique<GlobalValueInfo>(GlobalValSummaryOffset);
       SummaryOffsetToInfoMap[GlobalValSummaryOffset] = GlobalValInfo.get();
@@ -5551,7 +5552,7 @@
     case bitc::VST_CODE_COMBINED_ENTRY: {
       // VST_CODE_COMBINED_ENTRY: [valueid, refguid]
       unsigned ValueID = Record[0];
-      uint64_t RefGUID = Record[1];
+      GlobalValue::GUID RefGUID = Record[1];
       ValueIdToCallGraphGUIDMap[ValueID] = RefGUID;
       break;
     }
@@ -5787,7 +5788,7 @@
              "Record size inconsistent with number of references");
       for (unsigned I = 4, E = CallGraphEdgeStartIndex; I != E; ++I) {
         unsigned RefValueId = Record[I];
-        uint64_t RefGUID = getGUIDFromValueId(RefValueId);
+        GlobalValue::GUID RefGUID = getGUIDFromValueId(RefValueId);
         FS->addRefEdge(RefGUID);
       }
       bool HasProfile = (BitCode == bitc::FS_PERMODULE_PROFILE);
@@ -5796,11 +5797,11 @@
         unsigned CalleeValueId = Record[I];
         unsigned CallsiteCount = Record[++I];
         uint64_t ProfileCount = HasProfile ? Record[++I] : 0;
-        uint64_t CalleeGUID = getGUIDFromValueId(CalleeValueId);
+        GlobalValue::GUID CalleeGUID = getGUIDFromValueId(CalleeValueId);
         FS->addCallGraphEdge(CalleeGUID,
                              CalleeInfo(CallsiteCount, ProfileCount));
       }
-      uint64_t GUID = getGUIDFromValueId(ValueID);
+      GlobalValue::GUID GUID = getGUIDFromValueId(ValueID);
       auto InfoList = TheIndex->findGlobalValueInfoList(GUID);
       assert(InfoList != TheIndex->end() &&
              "Expected VST parse to create GlobalValueInfo entry");
@@ -5821,10 +5822,10 @@
           TheIndex->addModulePath(Buffer->getBufferIdentifier(), 0)->first());
       for (unsigned I = 2, E = Record.size(); I != E; ++I) {
         unsigned RefValueId = Record[I];
-        uint64_t RefGUID = getGUIDFromValueId(RefValueId);
+        GlobalValue::GUID RefGUID = getGUIDFromValueId(RefValueId);
         FS->addRefEdge(RefGUID);
       }
-      uint64_t GUID = getGUIDFromValueId(ValueID);
+      GlobalValue::GUID GUID = getGUIDFromValueId(ValueID);
       auto InfoList = TheIndex->findGlobalValueInfoList(GUID);
       assert(InfoList != TheIndex->end() &&
              "Expected VST parse to create GlobalValueInfo entry");
@@ -5855,7 +5856,7 @@
              "Record size inconsistent with number of references");
       for (unsigned I = 4, E = CallGraphEdgeStartIndex; I != E; ++I) {
         unsigned RefValueId = Record[I];
-        uint64_t RefGUID = getGUIDFromValueId(RefValueId);
+        GlobalValue::GUID RefGUID = getGUIDFromValueId(RefValueId);
         FS->addRefEdge(RefGUID);
       }
       bool HasProfile = (BitCode == bitc::FS_COMBINED_PROFILE);
@@ -5864,7 +5865,7 @@
         unsigned CalleeValueId = Record[I];
         unsigned CallsiteCount = Record[++I];
         uint64_t ProfileCount = HasProfile ? Record[++I] : 0;
-        uint64_t CalleeGUID = getGUIDFromValueId(CalleeValueId);
+        GlobalValue::GUID CalleeGUID = getGUIDFromValueId(CalleeValueId);
         FS->addCallGraphEdge(CalleeGUID,
                              CalleeInfo(CallsiteCount, ProfileCount));
       }
@@ -5883,7 +5884,7 @@
       FS->setModulePath(ModuleIdMap[ModuleId]);
       for (unsigned I = 2, E = Record.size(); I != E; ++I) {
         unsigned RefValueId = Record[I];
-        uint64_t RefGUID = getGUIDFromValueId(RefValueId);
+        GlobalValue::GUID RefGUID = getGUIDFromValueId(RefValueId);
         FS->addRefEdge(RefGUID);
       }
       auto *Info = getInfoFromSummaryOffset(CurRecordBit);
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index 84bdd8c..4ee53b5 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -2397,11 +2397,10 @@
 
 /// Emit function names and summary offsets for the combined index
 /// used by ThinLTO.
-static void
-WriteCombinedValueSymbolTable(const ModuleSummaryIndex &Index,
-                              BitstreamWriter &Stream,
-                              std::map<uint64_t, unsigned> &GUIDToValueIdMap,
-                              uint64_t VSTOffsetPlaceholder) {
+static void WriteCombinedValueSymbolTable(
+    const ModuleSummaryIndex &Index, BitstreamWriter &Stream,
+    std::map<GlobalValue::GUID, unsigned> &GUIDToValueIdMap,
+    uint64_t VSTOffsetPlaceholder) {
   assert(VSTOffsetPlaceholder > 0 && "Expected non-zero VSTOffsetPlaceholder");
   // Get the offset of the VST we are writing, and backpatch it into
   // the VST forward declaration record.
@@ -2427,7 +2426,7 @@
   SmallVector<uint64_t, 64> NameVals;
 
   for (const auto &FII : Index) {
-    uint64_t FuncGUID = FII.first;
+    GlobalValue::GUID FuncGUID = FII.first;
     const auto &VMI = GUIDToValueIdMap.find(FuncGUID);
     assert(VMI != GUIDToValueIdMap.end());
 
@@ -3052,7 +3051,8 @@
 /// Emit the combined summary section into the combined index file.
 static void WriteCombinedGlobalValueSummary(
     const ModuleSummaryIndex &I, BitstreamWriter &Stream,
-    std::map<uint64_t, unsigned> &GUIDToValueIdMap, unsigned GlobalValueId) {
+    std::map<GlobalValue::GUID, unsigned> &GUIDToValueIdMap,
+    unsigned GlobalValueId) {
   Stream.EnterSubblock(bitc::GLOBALVAL_SUMMARY_BLOCK_ID, 3);
 
   // Abbrev for FS_COMBINED.
@@ -3445,7 +3445,7 @@
   // in writing out the call graph edges. Save the mapping from GUID
   // to the new global value id to use when writing those edges, which
   // are currently saved in the index in terms of GUID.
-  std::map<uint64_t, unsigned> GUIDToValueIdMap;
+  std::map<GlobalValue::GUID, unsigned> GUIDToValueIdMap;
   unsigned GlobalValueId = 0;
   for (auto &II : Index)
     GUIDToValueIdMap[II.first] = ++GlobalValueId;